Larger boards, fewer marks to win
So a three-player game isn't always a draw.
Three-player tic-tac-toe on a 3×3 board needing three in a row is a forced draw under good play. This change parameterises the board size (3×3, 4×4, 5×5) and the win length (3–5), so games stay decisive — a 5×5 board won on three in a row drew zero of eight test games. The engines follow: beyond 3×3, exhaustive search gives way to a depth-limited threat search; MCTS and Random scale unchanged.
§1 Intent & scope
The 3-player mode we shipped is almost always a draw: nine cells, three players, three-in-a-row — perfect play blocks every threat. The fix is more room and a shorter goal. This change makes the board and win length configurable, and adapts the engines so the search families still play well (and fast) on the bigger boards. Out of scope: non-square boards, gravity/Connect-Four rules, and boards beyond 5×5.
§2 Deltas
Four typed changes against the spec. Each carries an op and a target.
Configurable board size and win length
The game MUST support a board size of 3×3, 4×4, or 5×5 and a win length of 3 to N marks in a row, chosen independently. The opponent menu and win-length options MUST stay valid for the chosen size.
Two- and three-player modes, any board
Larger boards are decisive
A three-player game on a 5×5 board won by three in a row MUST NOT always draw — measurably decisive across a run of games.
A move resolves under 500 ms — on every board
The < 500 ms budget now spans all board sizes, met by depth-limiting the search beyond 3×3 and bounding the MCTS iteration count per size.
§3 Approach
Win detection generalises to any K-in-a-row on an N×N board. The engines split by tractability:
- 3×3 — unchanged: full-depth search, provably perfect.
- 4×4 & 5×5 — Minimax, Alpha-Beta, MaxN, and Paranoid become depth-limited (depth 4 / 3) with a threat heuristic that rewards near-complete lines, and only search cells adjacent to existing marks.
- MCTS & Random — scale natively; MCTS iterations bounded per size (2,500 / 1,200 / 600).
§4 Risk register
An adversarial pass raised three risks. None block the change; all are resolved.
Beyond 3×3 the search engines are no longer provably perfect. Depth-limiting trades optimality for speed. Accepted and disclosed — the game's legend states plainly that big-board search is "strong, but no longer provably perfect," and the 3×3 guarantee is untouched.
Larger boards could blow the 500 ms budget. First cut of MaxN on 5×5 took ~2.1 s per move. Mitigated by tuning search depth (4→3 on 5×5) and MCTS iterations (1,400→600); re-measured worst-case well under budget.
Some configurations stay drawish. A 4×4 board needing four in a row still tends to draw. Accepted — the decisive target (SC-004) is met on 5×5 / three-in-a-row, and players can pick the ratio they like.
§5 Verification
§6 Change log
One file. Renders anywhere. Degrades to readable static HTML.