Skip to content
AI360XpertBeta
Playgrounds

Evaluation & RL

Q-Learning

Edit the grid and step through visits to see how a delayed reward changes the value of earlier moves.

Data seed 20260825

Guided steps 1 / 3

Stage 1 of 3: The Environment

Transition 0. Agent at Column 1, row 5. Selected: Column 1, row 5, Open.

  • Agent
Run experiment
Transitions0Transitions: 0
Episodes0Episodes: 0
Goal visits0Goal visits: 0
Penalty visits0Penalty visits: 0

Agent: Column 1, row 5 · move 0 of 100

A wall blocks movement. A penalty ends the episode.

Select a tile to inspect it or change its type. Entering a goal pays +1, entering a penalty pays −1, and all other moves pay zero.

Check your understanding

Q-learning estimates what each action is worth. Step through one update, then watch the goal reward give value to earlier moves.

What does a Q-value measure?

A Q-value estimates the discounted reward from taking a particular action and then making the best choices the agent knows about. Each open tile has four estimates, one per direction. A wall or board edge keeps the agent in place. Entering a goal pays +1 and ends the episode; entering a penalty pays −1 and also ends it. All other transitions pay zero. Use Inspect cell to find the four numbers behind the triangles, or edit a tile and train on the new board.

How does one move update the table?

Q-learning moves the old estimate toward a target. That target is the reward on entry plus the next state's best Q-value multiplied by the discount γ\gamma. When the move ends the episode, the target is just the reward. The learning rate α\alpha determines how far the old estimate moves towards it. For example, a goal entry with an old estimate of zero and α=0.1\alpha=0.1 updates that action to 0.1. An earlier move can later pick up part of that 0.1 even if it earned no reward itself. Step once and open Under the hood to see the actual reward, continuation, target and adjustment from the last transition.

Why can the agent find a goal without learning the route?

In Learning, fast-forward on the original board until the best Q-value at the start rises. The challenge follows the displayed greedy arrows from the start and requires a positive estimate at every move. The agent can visit a goal by chance before the arrows form that route. Select Try zero discount, then fast-forward again. Goal visits can still occur, but no action at the original start earns a positive estimate: the start is too far away to collect the goal reward in one move.

An exploration draw picks uniformly among all four actions with probability ϵ\epsilon. Otherwise the agent picks a highest-valued action, breaking ties randomly. The drawn policy arrows break ties in up, right, down, left order so the displayed route is reproducible. Q-learning is off-policy because the update uses the next state's highest estimate even when the agent's sampled action was exploratory. The original Q-learning paper gives conditions for tabular convergence; a finite run at a fixed learning rate is an illustration, not a convergence guarantee.

What does the return chart show?

The chart records rewards from completed episodes, without discounting. A move limit ends a run that has reached neither terminal tile, recording zero. This is a lab time limit: the final move still bootstraps from the next state. The chart can jump between goal and penalty even after a greedy route appears, because the training policy can keep exploring. Change only playback speed to watch the same run at a different pace. Changing the board, seed, or a learning setting starts a fresh run so a shared link can reproduce its full training history.

Stage recap

  1. The Environment

    Select a tile to inspect it or change its type. Entering a goal pays +1, entering a penalty pays −1, and all other moves pay zero.

  2. Action Values

    Step through a transition and inspect the updated action. Each triangle faces the direction of its action; inspect a cell for the exact numbers.

  3. Learning

    Fast-forward to spread value through visited cells. The arrows show the current greedy choices; training can still explore.

Reference

Bellman Update
Q(s,a) ← Q(s,a) + α [r + γ max Q(s',a') - Q(s,a)]
ε-Greedy
With probability ε, explore randomly. Otherwise, pick argmax Q(s,a).
Discount Factor (γ)
0 = short-sighted, 1 = far-sighted.
Learning Rate (α)
0 = never update; 1 = discard every prior estimate and trust only the newest sample.
Policy
π(s) = argmax_a Q(s,a) — the action with the highest learned value in each state.

Break it on purpose

With discount zero, the target uses only the reward on the entered tile. On the original board, the goal reward cannot give a positive value to any action at the start.