Updated 28 September with round two: a rebuilt AI player that scores far more and flips far less. Skip to round two.

It started with a reasonable request: could we make a modern version of Space Cadet, the pinball game that came with old copies of Windows?

Then the ball got stuck. Then it kept vanishing down the sides. Then the effects were too much. By the time those were fixed, I realised the table was a bit boring. So I kept going.

Somewhere along the way it stopped being a remake and became Agent Pinball: a browser game with an agentic AI theme, a fork bomb that splits one ball into many, and a small model that plays it. You can play it here on the site, or sit back and watch the AI.

The scope has expanded slightly. The original idea was to have something to relax with. I have spent far more time building it than playing it, which is partly why it now has an AI to play it for me.

Making it worth playing

I built the first version with Codex, mostly by playing it, complaining, and asking for another go. The useful feedback was blunt. The table needed more going on. The flippers felt hectic. There was too much text. Holding the launch button should actually pull the plunger back.

The agent theme gave the table its own identity. Tasks, forks and swarms became things the table could do, and one bonus could turn a single ball into a much less manageable situation.

That was fun, until it happened too often. If every moment is chaos, the big moment stops being big. Most of the iteration since has been about balance: better returns from the sides, calmer effects, a simpler layout, and making the exciting bits feel earned.

Teaching something to play it

The next question was whether I could train a model on my own machine to play the game, and keep the footage and measurements as it learned. That turned into a second project inside the first.

The coding assistant and the player are different things. The assistant builds the game and the training setup. The player was a small reinforcement learning model trained with PPO. Thirty times a second, it read 76 numbers describing the game and chose one of four controls: left flipper, right flipper, both, or neither. It read the game state directly rather than watching the screen, a script handled the launch, and it never learned to nudge.

Training ran the same physics without drawing anything. The model played, got feedback, adjusted, and saved versions along the way so we could see what changed. I assumed my RTX 4070 Ti SUPER would speed this up. It didn’t: the network was so small that the CPU won the benchmark. Measure the thing in front of you.

A 97-second, silent progress reel from the first round: before and after, recorded control decisions, and the score charts. This is an early edit; gameplay was captured at 10 fps. The replays illustrate the policies and are separate from the scored tests.

Better scores, with asterisks

When I first wrote this, the player had made just under 10 million training decisions. That is decisions, not games, and it does not count the branches that went nowhere.

The best experiment of that round rewarded completed ramp and portal shots while a single ball was in play. We picked a candidate on one set of games, froze it, and compared it with the previous player on 128 fresh, matched games:

ScorePrevious playerNew player
Average9.50 million14.68 million
Median6.02 million10.55 million

That is a 54% higher average and a 75% higher median. The new player won 76 of the 128 games, with one tie. Both played for normal points with the training bonuses switched off, and each game ended after three lost balls or two simulated minutes. The individual scores are here.

Good enough to keep, not good enough to call an expert. It still scored under a million in 39 of those games. A good average can hide some terrible afternoons.

The flipper problem

The recurring problem was the flippers. The model was busy in a way that looked ridiculous.

Making flipping more expensive produced a quieter player that was worse at pinball. More training didn’t fix it either: one follow-up added 3.15 million decisions across three branches, and all three failed the score checks. Rewarding what is easy to measure doesn’t get you the behaviour you actually want.

I kept those failures on purpose, along with 113 saved replay checkpoints and 17 raw video takes. It would be easy to edit this into a much neater story than it was.

Round two: plan first, then learn

By late September, the player on the site changed flipper state about 22 times a second, and only about one press in five touched a ball. Looking closely, it had learned a rhythm: press for one 33-millisecond decision, let go, repeat. It worked because the flippers swung at a constant speed, so a quick tap hit as hard as a proper flip. Every penalty we tried gave the same trade: a calmer player that was worse at pinball.

So for round two I stopped turning the penalty dial and changed the approach. This time I worked with Claude Code, running several agents in parallel: some researching, some building, one training.

A planner first. Because the game is a simulation, you can copy its exact state, try a few dozen flip timings a couple of seconds into the future, and keep the best. A quick prototype scored about five times more than the trained player while flipping about nine times less. The catch: it thinks for a quarter to half a second per decision. Fine for producing training data, far too slow for your browser.

Then a better table. The planner kept tripping over the physics. Balls could settle in dead pockets. The ball slid instead of rolling. Catching it on a raised flipper was nearly impossible, because it ran straight off the end. So the physics got a proper rework: flippers that spin up like a coil, rubber that soaks up energy, and a physics engine written for this table that runs several times faster than the general-purpose one it replaced.

Then no cheating. A perfectly deterministic game has a flaw: the planner found a ramp shot it could repeat forever. That isn’t skill; it’s exploiting a simulation that never varies. Real tables have small imperfections, so now this one does too, with a little random variation in every bounce. The planner can’t see which variation is coming, so it has to pick shots that work across several possible futures. That was when it started catching the ball and aiming from a held flipper on its own.

Finally, a network that copies it. The planner played 2,000 games. A network learned to imitate its decisions, then played while the planner corrected its mistakes, then trained further with reinforcement learning on a leash to that copied behaviour. The leash matters: without it, earlier versions gradually forgot their good habits.

On 100 fresh two-minute games:

Old playerPlannerNew player
Average score6.6 million43.1 million237.1 million
Median score4.6 million34.2 million224.4 million
Flipper changes per second21.91.63.9
Presses that touch a ball8%69%57%
Balls lost per minute0.910.450.07

The new player beats its own teacher, mostly by keeping multiball alive for longer. Jackpots stack up the longer it runs.

The usual asterisks apply. The old player was trained on the old table, so this partly measures it on a table it never saw, and its numbers come from a different set of games. The new player rarely catches the ball: 0.2 times a game, against the planner’s 2.5. It still flips about five times a second in multiball, far calmer than before but more than I’d like. And nobody has measured it against people yet.

Still small enough to live in your browser

The first player was about 190 KB. The new network is about 7 MB, roughly 5 MB to download. Either way, it runs entirely in your browser and takes well under a millisecond per decision. There is no AI call behind each flip and no inference server playing every visitor’s game. The site serves the game and the model; your browser does the rest.

Next: get it catching and aiming like the planner, calm it down in multiball, and find out whether people can beat it. Any table change will need fresh checks too. A player trained on one layout shouldn’t be assumed to understand another.

For now, have a go at Agent Pinball. If you find a repeatable way to embarrass the AI, tell me about it. That would be useful data, and probably good footage.

Video text alternative

The reel opens with the shot-learning experiment: three branches trained with different rewards. It shows a saved replay of the previous, 7.86-million-decision player, followed by a diagram of the ball state and the probabilities of its four flipper controls.

The focused, 9.96-million-decision candidate appears next. Its selection results were 14.73 million average points and 11.85 million median points. A chart compares the selection branches. Another recorded state diagram shows the candidate's control probabilities; these are model outputs, not an explanation of its intentions.

The final chart uses the separate 128-game confirmation set: 14.68 million average and 10.55 million median for the candidate, against 9.50 million and 6.02 million for the previous player. The candidate won 76 comparisons and passed the recorded requirements. The closing card notes that human difficulty remains unmeasured. There is no audio.