How the Atom Reaction bots were built
By Swapnil Shah · Updated 2026-11-24
The computer players in Atom Reaction were one of the most interesting parts to build, mostly because the results kept surprising me. Here is how they work and what I learned from measuring them.
The basic idea
The bots use a classic game-search technique called alpha-beta search. The bot tries each move, imagines the opponent's best reply, then its own, and so on to a fixed depth, scoring the resulting boards. It picks the move that leads to the best score and skips branches that cannot be better, which makes the search much faster.
Four levels
Easy searches two moves deep and picks randomly among its top choices, so it plays sensibly but not perfectly. Medium searches two moves and always takes its best. Hard searches four moves deep with a time limit of about a second and a half. Nightmare also searches four moves, with two seconds and a stronger way of scoring the board.
Running in a web worker
A deep search can take a second or more. On the main thread that would freeze the screen. So the search runs in a web worker, a background thread in the browser, and the interface stays smooth while the bot thinks. There is a fallback to the main thread, and a minimum delay so the bot does not respond so quickly that it feels robotic.
Surprise 1: deeper was not stronger
I assumed searching six moves deep would give a stronger bot than four. In tests with swapped sides and random openings, depth six and odd depths like three and five were actually weaker than four. I checked the search against a brute-force version to prove it was correct, so the cause was the way the board is scored, not a bug.
Surprise 2: pruning moves hurt
I tried to speed things up by considering only the best few replies, a technique called beam search. A depth-four bot with this shortcut lost to a plain depth-two bot. Cutting the moves it considered removed exactly the surprising replies that a strong player finds.
How I measured
Each level was tested against the next with random openings and the sides swapped, over many games, split across all CPU cores. I learned not to use fixed random seeds, because identical seeds replay the same game over and over and make results look more certain than they are.
In the end I chose the strongest setup I could actually measure, even though I had planned a deeper search for Nightmare. A bot you can prove is stronger is better than one you merely hope is.