Interactive Lab · Deep Reinforcement Learning

When the world is too big for a table, hand it to a neural net

The Q-Learning agent kept a value for every cell. But this world has no cells, the agent lives at a real-valued position (x, y), so there are infinitely many states and no table can hold them. DQN's fix: replace the Q-table with a small neural network that takes (x, y) and predicts the value of each move. Press Train and watch it learn a path from raw coordinates, then flip the two switches from the paper and watch training fall apart.

▶ The playground, train an agent that has no map

episodes 0 success rate avg return steps (last) status untrained
goal +1 pit −1 start tint = the network's value V(x,y) · arrows = greedy policy
Experience replayON

Store past moves in a memory and train on a random mix of them, instead of only the latest, correlated step.

Target networkON

Aim at a frozen copy of the network that only updates occasionally, so the agent isn't chasing a target that moves every step.

0.0003 · slowfast · 0.006
0.5 · short-sightedfar-sighted · 0.99
0.05 · greedyall random · 1.0

🧭 Where this fits

DQN is how an agent learns to act from raw reward, no labeled “right answer,” just trial, error, and a score. It's the lineage behind game-playing AI (Atari, Go), robotics, recommendation, and the RL that fine-tunes LLMs. Reach for RL when you can't hand a model examples, only a goal and feedback.

The code that's actually running



  

🔮 Predict, then test

Train once with both switches ON until it says policy found, note how the value tint spreads smoothly across the whole board even though the net only ever visited a handful of points (that's the network generalizing). Now Reset, turn Target network OFF, and retrain. Before you do: predict what happens to the success rate. Why does aiming at a target that shifts every single update make the learning wobbleeven diverge, instead of settling?

The takeaway

Your new mental model of DQN