Minimax Algorithm Visualizer
Score Tic-Tac-Toe moves with minimax, compare candidate outcomes, and inspect the best move under optimal play.
Board setup
Step controls
Step 1 of 7: X to move. Evaluate 5 legal moves with minimax.
Tic-Tac-Toe game tree
X to move. Evaluate 5 legal moves with minimax.
Candidate moves
Result
X maximizes the score. O minimizes it. A score of 1 favors X, 0 is a draw, and -1 favors O.
What is a Minimax Algorithm Visualizer?
A minimax algorithm visualizer shows how a two-player game tree is scored when one player tries to maximize the result and the other tries to minimize it.
This tool uses Tic-Tac-Toe because the states are compact and the winner is easy to inspect. X is the maximizing player, O is the minimizing player, and each legal move is scored by recursively searching the remaining game tree.
For the full cluster of related tools, browse the Data Structure Visualizers hub.
How to use this minimax visualizer
- Start from a preset mid-game board or click squares to edit the board.
- Run the search to score each legal move.
- Step through candidate moves and compare their minimax scores.
- Pick the highest score when X moves and the lowest score when O moves.
- Inspect search counts for terminal wins, losses, draws, and visited nodes.
Minimax scoring
This visualizer scores terminal boards from X’s perspective:
- X win:
+1 - Draw:
0 - O win:
-1
When X moves, minimax chooses the candidate with the highest score. When O moves, it chooses the lowest score. That alternating choice models optimal play from both sides.
Compare this page with the Backtracking Visualizer, Recursion Tree Visualizer, and the Find Winner on a Tic Tac Toe Game article.