On this page

The idea

Suppose you could attach a number to every situation-and-action pair in a game: in this spot, doing this is worth about so much. With those numbers in hand, playing is easy. Look at where you are, read off the number for each action, and do the one with the largest.

Nobody hands you the numbers. Q-learning is a way of finding them by playing. Start with every number at zero. Take an action, see what you got for it, and look at what the numbers say about the spot you landed in. Then move the number you started from a little way toward "what I got, plus the best I can expect from here". Play enough, and the numbers settle toward the truth. The letter Q is the traditional name for the table of numbers, and each entry is an action value.

A small example

Four cells in a row, numbered 1 to 4. You start in cell 1. Moving right costs nothing. Reaching cell 4 pays 10 and ends the round. Stepping left from cell 1 goes off a cliff, pays −10, and ends the round too.

  1. Make a table with one row per cell and one column per action, left or right. Eight numbers, all zero.
  2. Play a round. From cell 3 you move right, receive 10, and the round ends. Nudge the entry for (cell 3, right) toward 10. With a step of one tenth it becomes 1.
  3. Next round, from cell 2 you move right to cell 3 and receive nothing. But the best entry available at cell 3 is now 1, so the entry for (cell 2, right) is nudged toward 0 + 1 and becomes 0.1. Value creeps backward along the corridor, one cell per round.
  4. Keep playing, mostly taking the best action, sometimes a random one, so that the cliff and the reward are both discovered and neither is forgotten. Most versions also shrink a reward a little for every step it is away (a discount), so the entries settle into a staircase rising toward the goal.
cliff−10cell 1cell 2cell 3cell 4+10round endsmoving right is free; the agent starts in cell 1Q(cell 1, right)8.1Q(cell 2, right)9Q(cell 3, right)10no move from herebackupbackup
The four-cell corridor. The bars are the learned value of moving right from each cell. The first time the agent reaches the goal, the bar under cell 3 grows toward 10. On the next round the bar under cell 2 grows toward the best value available at cell 3, and so on backward down the corridor: each round moves the news one cell further from the goal. With a discount of nine tenths the values settle at 10, 9 and 8.1.
  1. Replace the table with features. A table is fine for eight numbers. For a board with more positions than anyone could list, describe each situation with a few measurements (distance to the goal, distance to the cliff), give each a weight, and let the value be the weighted sum. The same nudge now moves the weights. This is linear Q-learning.
  2. Replace the features with a network. Let a neural network read the raw situation and output one number per action. Two fixes are standard. A replay buffer stores past steps and learns from a random spread of them instead of only the latest. A lagged copy of the network, in the method called Double DQN, chooses the best next action while the live copy is the one being nudged, so a random overestimate cannot feed itself.

How it works

a tableone entry per cell and actionwhere am I ↓↓ one number per actiona few featuresmeasurements × learned weightswhere am I ↓↓ one number per actiona networklearned measurements, layeredwhere am I ↓↓ one number per actionleftrightcell 1−108.1cell 27.39cell 38.110cell 4··distance to goal× w₁distance to cliff× w₂+weighted sum = valueleftrightevery line is a learned weight
Three places to keep the same numbers. A table has one entry per situation and action, which is fine for eight numbers and impossible for a board. A linear model describes the situation with a few measurements and learns one weight each. A network learns its own measurements. In every case the input is where you are and the output is one number per action, and the same nudge rule trains all three.

Whatever holds the numbers, the loop is the same. Observe the situation. Pick an action, usually the best-valued one, occasionally a random one. Observe the reward and the next situation. Build the target: the reward plus the best value available next, discounted. Move the current value a step toward the target; the step size sets how fast the numbers move and how noisy they stay. Repeat.

The target is built from the learner's own current numbers, which is what makes the method cheap: nobody has to play a game to the end before learning starts. It is also what makes it fragile. If the numbers that define the target are wrong, the learner chases its own errors, and with a function approximator and off-policy data the weights can grow without limit. The lagged copy in Double DQN is one guard against that, and the replay buffer is another.

live copynudged every steppicks the best next actionlagged copyfrozen between refreshesscores that actionwhich action?its value → the targetcopy the weights acrosssteps since the last refreshN steps: refresh
Double DQN keeps two copies of the network. The live copy is nudged every step and picks which next action looks best. A lagged copy, frozen between refreshes, says what that action is worth, and that number goes into the target. Because the copy that chooses is never the copy that scores, a random overestimate cannot pick itself and then confirm itself. The bar counts steps until the lagged copy is refreshed from the live one.

In Drop7

A Drop7 action value is a number for "drop the visible disc in this column, from this board". The situation is the public state: the board, the next disc and the rise clock. The reward is whatever the experiment chose, points or moves survived.

Pages that learn values from experience:

The reward that worked best here was survival. The DQN page explains why learning from raw score gives almost no signal in a game where one lucky chain outweighs fifty ordinary moves, and the blind-spot audit it cites groups the survival-reward models as the ones that predicted held-out games best.

What it cannot do

The clearest record of the learning rule itself is the Klein-Friedmann reproduction. With a step size of one over the number of moves, the weights are effectively frozen after a few hundred games: in the authors' own simulator, a learner stopped after 300 games tests at 49.08 moves over 10,000 games, and the 50,000-game learner tests at 49.08 as well. Two schedules that kept learning for longer blew the weights up, one to about a billion and one to NaN (the reproduction page). A five-second cross-entropy search over the same six weights beat both learned vectors on the site's own rules: 44.8 moves and 138,973 points against 40.5 moves and 123,968 points for the transplanted learned weights, on the same 256 pilot games (RS-20260902T084356Z-784ebf14, pilot tier). The plateau belonged to the optimiser, and the page puts the features' own ceiling under that search at about 45 moves.

For the deep version no number survives at all. The DQN's verdicts are task-record only, with no per-game data, no mean score and no lifetime for the network, for its continuation wrapper, or for the baseline they were compared against (Double-DQN and continuation).