↑↓ move · ↵ open · esc close

Tic-tac-toe

A tic-tac-toe opponent that cannot be beaten, built on minimax with alpha-beta pruning.

StatusIn progress
Built withTypeScriptMinimaxAlpha-beta
Live demo

Loading the demo…

Algorithms
Algorithm pages

Each of these has a page of its own, with the steps, the cost and the other places it is used.

How it works
  • 01The AI explores every possible continuation of the game, scoring a win, a draw or a loss at the end of each, and picks the move that leads to the best result against a perfect opponent. That is minimax.
  • 02Alpha-beta pruning drops branches that cannot change the best move, so it plays the same move after looking at far fewer positions. Turn on the scores to see what the AI sees, and switch between plain minimax and alpha-beta to compare.
More in this category
Algorithms and games

Pathfinding

Five grid search algorithms side by side on walls you draw. The search […]

TypeScriptA*+1
Algorithms and games

HEX

The connection game with no draws, against an AI whose search […]

TypeScriptCanvas+1
Algorithms and games

Othello

Outflank and flip your opponent’s discs, against an AI you can switch […]

TypeScriptCanvas+3