Home field — flawless in the maze it grew up in
Meet Maze A and its resident agent. Train it — you'll see value spreading backwards from the goal, the way RL training converges — then run it. It takes the mathematically shortest path, every time. By every benchmark measured inside this maze, training is a total success.
We compute the converged policy exactly (the arrows are the true optimal action in every cell) so you can see the end state of training without waiting through thousands of episodes. That's what "trained to convergence on one environment" means.
One maze swap — the champion is lost
Same agent, same weights — new maze. During training, Maze A never changed, so the agent never needed to look at the walls: it just memorized "at position (3,4), go right." Drop it somewhere new and those memorized moves chain into walls, circles, and dead stares. Click repeatedly — every maze breaks it differently.
This models an agent whose observations were constant during training, so it effectively learned position → action. Deep RL agents do the visual equivalent: they key on incidental features (background, layout, timer position) that were accidentally constant in the simulator.
The diversity dial — train on N mazes, watch skill appear
Now train a smarter agent that senses its local surroundings (nearby walls + a goal compass) and learns which move works in each situation, pooled across N different training mazes. Drag the dial. With N = 1 its situation table is tiny and maze-specific. As N grows, situations repeat across mazes, maze-specific quirks get outvoted, and real maze-solving emerges — measured live on 30 mazes it has never seen.
Everything recomputes live as you drag: the agent is retrained on N procedurally generated mazes and re-tested on 30 held-out ones. "Situations recognized" is how often the test threw a local situation the agent had seen in training — when it hasn't, it can only guess. (The agent also prefers not to re-tread cells it has already visited — a standard trick that keeps any policy from dithering in circles.)
The gap chart — recreating the CoinRun lesson
OpenAI's CoinRun study made this famous with one chart: score on seen levels vs score on unseen levels, as training levels increase. Agents trained on few levels aced them while failing new ones — a gap invisible if you only test where you train. Run the same experiment right here on our maze agent and watch both curves get computed point by point.
Live simulation, not a stock chart — numbers vary slightly run to run. In CoinRun (Cobbe et al., 2019) agents needed on the order of 10,000 levels before the seen/unseen gap closed; our toy closes faster because mazes are far simpler than platformer levels.
The race — specialist vs generalist on a maze neither has seen
Final exam. The Specialist (red) trained to perfection on Maze A alone. The Generalist (green) trained on 40 random mazes and never scored a perfect run on any of them. Now both wake up in a brand-new maze. Race them — as many times as you like.
The generalist isn't guaranteed to win every maze — it fails sometimes, honestly. Run several races and keep score.