Minimax Algorithm Visualizer

Score Tic-Tac-Toe moves with minimax, compare candidate outcomes, and inspect the best move under optimal play.

Player
X
Moves
5
Nodes
181
Step
1/7

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 Best
player = X
best = row 2, col 2
score = 1
X wins
0
O wins
0
Draws
0

Candidate moves

row 0, col 2 score 0
row 1, col 0 score 1
row 1, col 2 score 1
row 2, col 1 score 0
row 2, col 2 score 1

Result

X maximizes the score. O minimizes it. A score of 1 favors X, 0 is a draw, and -1 favors O.

Best move: row 2, column 2, score 1.

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.

Frequently Asked Questions

What does minimax optimize?
Minimax chooses the move that gives the best guaranteed outcome if both players play optimally.
Why does this minimax visualizer use Tic-Tac-Toe?
Tic-Tac-Toe has simple rules and small boards, so each move score can be understood without a large game engine.
What do minimax scores mean here?
A score of 1 means X can force a win, 0 means best play leads to a draw, and -1 means O can force a win.
Why does the tool limit empty squares?
The full empty Tic-Tac-Toe game tree is large for an interactive page. Mid-game boards keep the visualization readable.

Related tools