Grow a tree of futures — the four-beat loop
One MCTS "playout" has four beats: select a promising path down the tree, expand one new node at its edge, simulate the rest of the game with random moves, and back up the result along the path. That's it — repeated thousands of times. Below is a real tic-tac-toe position (X to move). Press the button and watch the tree grow: node size = visit count, the mustard trail = the path of the last playout.
Every playout finishes the game with purely random moves — no chess-master rules anywhere. The intelligence comes only from counting which starts led to wins.
The exploration dial — one formula decides where to look next
Inside every tree node lives a tug-of-war: keep visiting the move that looks best (exploit), or give neglected moves another chance (explore)? MCTS settles it with the UCB score: average win rate + c·√(ln N / n). Below are five slot machines with hidden win rates. The white bar is what the algorithm has measured; the mustard cap is its exploration bonus, which shrinks as a machine gets pulled. Drag c and watch the strategy change character.
c = 1.4 — the classic UCB1 balance: mostly exploit, but never let any arm's uncertainty grow unchecked.
The move greedy can't see
Here's a position where X has a forced win — but only via a fork: a quiet move that creates two threats at once, two plies later. A greedy one-step evaluator ("win if you can, block if you must, take center, take a corner") sees nothing special and settles for a corner. MCTS, because it actually plays the futures out, piles its visits on the fork. Run both and compare — green dots mark the moves a perfect game-solver confirms as winning.
The greedy player here uses the standard hand-written tic-tac-toe heuristic. The green ground-truth dots come from an exact minimax solver running live in this page.
Buy better moves with compute — the budget dial
MCTS has a beautiful property: its answer improves smoothly with compute. Same position as EP 03. Pick a simulation budget, then launch 12 independent runs from scratch and see where their recommendations land. Watch two things: how often runs agree with each other, and how often they pick a truly winning move.
At 10 playouts each of the 5 legal moves gets ~2 visits — the "best" move is basically a coin flip, yet the search still reports a high win-rate for it. Confidence is not evidence.
Trap states — when shallow optimism walks into a refutation
The nastiest failure mode: move A looks great to random playouts (it wins against a careless opponent) but has one killer reply that refutes it completely. Move B is honestly decent. Early in the search the opponent's refutation hasn't been discovered, so A's value starts inflated — only as the tree deepens does the in-tree opponent learn to punish it, and A's curve collapses. Run the impatient search, then the patient one, and watch the collapse live.
Abstract two-move game, real UCT search: under A the opponent has 8 replies, one of which wins 95% for them; under B every line gives you a solid 55%. Random rollouts see A at ~75% — a mirage.