Everyone says a minimax Tic-Tac-Toe bot is "unbeatable." I wanted a number, not a vibe — so I benchmarked the exact engine that ships on my game. The code is open source; every figure below reproduces with node benchmark.js, and there's a full writeup with charts.
1. The proof isn't a sample — it's the whole game tree
On 3×3, Hard mode's reply is deterministic (full depth-9 minimax + alpha-beta), so you can enumerate every reachable game. Playing second, as it does in the game: 569 lines → 386 wins, 183 draws, 0 losses. Playing first: 73 lines → 71 wins, 2 draws, 0 losses. Across all 642 lines it never loses. On 3×3, "unbeatable" is literally the game tree, not a claim.
2. Alpha-beta earns its keep
Choosing the opening move at full depth, plain minimax visits 549,945 positions; alpha-beta cuts that to 36,528 — a 93.4% reduction for an identical answer.
3. Does it break on bigger boards?
The engine caps its search depth as boards grow (9 → 7 → 5 → 3). I expected that to open a crack. It didn't: across 628 simulated games up to 6×6, against random and greedy opponents, still 0 losses. What changes isn't losing — it's that forcing a win gets harder, so results drift toward draws (3×3 91.8% win, 4×4 72.5%, 5×5 96.7%, 6×6 100% vs random).
Why it holds up: it always blocks an immediate threat before searching, and 4-in-a-row stays defensible within the depth cap. The interesting fragility is theoretical — a human who can plant a fork beyond the AI's horizon — which is exactly why the full game offers 4×4 up to 10×10.
Engine + benchmark: https://github.com/lucian-devops/tictactoe-ai. Play it: https://lkforge.com/games/tictactoe/. Full writeup: https://lkforge.com/games/tictactoe/blog-how-the-ai-works/.
Top comments (0)