All games

Perfect Information

Tic-Tac-Toe

The classic. Perfectly solved.

2 players1 solverSolved
MinimaxImport stateReplayBest move
Board
Tap a cell to place the current player's mark. Right-click (or long-press) a cell to clear it.
X to move

Each empty cell shows the result with best play (win / draw / loss) and the number of plies until the game ends.

Deep dive

How BoardSolve plays Tic-Tac-Toe

Tic-Tac-Toe is the canonical worked example for adversarial search: the game tree is small enough (765 essentially different positions, 26 830 with symmetries) to enumerate exhaustively, so an unbeatable solver fits in a few dozen lines of code.

What the solver does

BoardSolve runs a complete minimax search from the current position. Each leaf is scored +1 for an X win, −1 for an O win, and 0 for a draw; interior nodes propagate the best score for the side to move.

Because the full tree is searched without depth cutoff, every suggested move is provably optimal and the engine can label the position as a forced win, forced loss, or draw with best play.

Why it works

Tic-Tac-Toe is a finite, two-player, zero-sum game of perfect information. Zermelo's theorem guarantees that one of the three outcomes (win for X, win for O, draw) is forced from the empty board — and the historical analysis confirms it is a draw.

Alpha-beta pruning is unnecessary here, but the same minimax skeleton scales (with pruning, transposition tables, and heuristics) to Connect Four and Barricade elsewhere on BoardSolve.

References & further reading

  1. Zermelo, E. (1913) . Proceedings of the Fifth International Congress of MathematiciansOriginal proof that finite perfect-information games have a determined value.
  2. Russell, S. & Norvig, P. (2020) . PearsonStandard textbook treatment of minimax and alpha-beta used as the implementation reference.
  3. Knuth, D. E. & Moore, R. W. (1975) . Artificial Intelligence 6(4), 293–326