Q-learning

Last Updated: July 29, 2026 | By Mihail Sebastian | AI Dictionary

A reinforcement learning algorithm that learns the value of each action in each state, letting an agent find the best strategy without a model of its environment.

What is Q-learning?

Q-learning is a reinforcement learning algorithm that learns the value of taking each action in each state, so an agent can act well without a model of its environment.

The Q stands for quality. The algorithm fills in a table of Q-values, one per state-action pair, and the best strategy falls out of it: in any state, take the action with the highest Q-value.

How Q-learning Works

The Q-table starts at zero (or small random values). The agent then acts in the environment, balancing exploration – trying actions whose value it does not yet know – against exploitation, repeating actions that have paid off.

After every action, one cell of the table is updated:

\[ Q(s, a) = Q(s, a) + \alpha \times [r + \gamma \times \max_{a'}Q(s', a') - Q(s, a)] \]

Where:

“Model-free” means the agent never needs to know how the environment behaves in advance. It learns action values purely from experience.

Example of Q-learning

Put an agent in a maze with a reward at the exit. Early on the Q-table is all zeros, so the agent wanders at random and hits dead ends. Every step feeds the update rule.

Cells along routes that eventually reach the exit gain value, because the reward propagates backward through the max term, one update at a time. After enough episodes the table encodes the maze’s solution: from any square, the highest-valued action points toward the exit, and the agent walks the shortest route without ever having seen a map.

Related AI terms: Reinforcement Learning · Learning Rate · AI Agent · Machine Learning

Did you like the Q-learning gist?

Learn about 250+ need-to-know artificial intelligence terms in the AI Dictionary.

Mihail Sebastian — Writes about AI governance, regulation, and the technology behind them. Placeholder bio — replace with a real credential line. About

Read the Governor's Letter

Stay ahead with Governor's Letter, the newsletter delivering expert insights, AI updates, and curated knowledge directly to your inbox.

By subscribing to the Governor's Letter, you consent to receive emails from AI Guv.
We respect your privacy - read our Privacy Policy to learn how we protect your information.

Browse All AI Terms A–Z

Every term in the dictionary, in alphabetical order. Jump to a letter or scroll the full list.

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z