Breaking Bellman: repair broken reinforcement learners in your browser
Breaking Bellman is a free browser game for learning reinforcement learning. Real algorithms train in your browser and fail, and you fix them one word at a time.
Reading a clean explanation of Q-learning feels a lot like understanding it. Can you predict what a broken learner will do? In Breaking Bellman, you predict, watch it train in your browser for a few seconds, then repair its update rule by swapping words. There are 17 levels, playable in any order. Menu repairs are easier than inventing PPO, but you still have to find the broken word.
Take CartPole: push a cart left or right to keep its pole upright. The network's guess of future discounted reward is called Q. One run reached 4,700,000 and was still climbing. Hmm. Each step pays 1, each later reward counts 0.99 as much, and episodes stop after 200 steps. Before looking below, pick the largest possible discounted return: (a) 200, (b) about 86.6, (c) unlimited.
Show the return answer
Answer: (b). Add 200 terms: 1 + 0.99 + 0.99² + … = (1 − 0.99²⁰⁰)/(1 − 0.99) ≈ 86.6. Choice (a) is the undiscounted score ceiling. Choice (c) would require both no discount and no time limit. Even with unlimited time, this discount caps the return at 100.
Toy simulations using the game's engine; CartPole differs from physical robot control. The rule paraphrases the game's wording. CartPole rows summarize 5 seeds; training budget, hyperparameters, dispersion and aggregation are unspecified. Panel ④ also lacks run counts, horizons and smoothing. An AI assistant wrote most code and helped run 250+ experiment configurations. Source: EXPERIMENTS.md.
A stable learner can still learn the wrong thing. The bonus level's 2D dog uses PPO to fetch a stick, with +1 for retrieval, −0.01 per step and up to +0.05 per step for facing it. It learned to face the stick and sit, earning about 2.12 per throw. Three times more training made it a better sitter. Let's compare what sitting and fetching actually pay.
Sit or fetch?
Assume a 60-step throw and the full 0.05 facing bonus every step.
Sitting wins above a bonus of 0.01 + 1/(60 − 15) = 0.032222… per step; equality gives a tie.
Facing bonus: no retrieval after 60 steps; 0% of test throws retrieved, with test count unspecified. Inspired by Huggy, in a simpler 2D world.Replace the facing bonus with potential-based shaping: pay in proportion to progress toward the stick and charge for moving away. The same PPO dog retrieves in 16 steps in this depiction.
Show the shaping answer
Answer: (a). Scheme 1 pays 0 out and +1 back. Scheme 2 pays −1 out and +1 back. Over longer trips, each middle potential is added once and subtracted once, leaving Φ(end) − Φ(start), which is zero on a closed loop. Choice (b) misses scheme 1's free outward movement; (c) misses scheme 2's outward charge.
More from the casino and the cliff
The casino image shows the greedy trap from panel ④ during a run. Gold bars are true average payouts, blue bars are estimates, and the crown marks the best machine, number 7. The learner has pulled machine 8 a total of 995 times.
Exploring has a price too: near the cliff, falls cost −100 each.
Before your next run, calculate the return ceiling, change one ingredient, and predict what the reward will encourage. Play Breaking Bellman or read the code. The free game is one MIT-licensed HTML file and saves progress in your browser.