Minimax Algorithm Visualizer
Visualize the minimax algorithm for game trees.
Enter leaf values and see how Max and Min players choose optimally in a 2-level or 3-level tree.
The Minimax Algorithm
Minimax is the core algorithm used in two-player zero-sum games like chess, checkers, and tic-tac-toe. It assumes both players play perfectly.
The Two Players
- Max (maximizer): tries to get the highest score possible (e.g., the AI player)
- Min (minimizer): tries to get the lowest score possible (e.g., the opponent)
How It Works
At each node in the game tree:
- If it’s a Max node: choose the maximum of child values
- If it’s a Min node: choose the minimum of child values
- Leaf nodes (terminal states) have fixed values (scores)
2-Level Tree
[Max] ← root picks maximum
/ \
[Min] [Min] ← each picks minimum of its leaves
/ \ / \
v1 v2 v3 v4 ← leaf values (terminal scores)
Max will receive: max(min(v1,v2), min(v3,v4))
3-Level Tree
[Max] ← picks max of Min nodes
/ \
[Min] [Min] ← each picks min of Max children
/ \ / \
[Max] [Max] [Max] [Max] ← each picks max of leaves
/ \ / \ / \ / \
v1 v2 v3 v4 v5 v6 v7 v8
Real-World Use
Minimax powers game AI in:
- Chess engines (with alpha-beta pruning to skip branches)
- Go programs (with Monte Carlo extensions)
- Checkers, Connect Four, Tic-tac-toe solvers
Enter 4 leaf values for a 2-level tree, or 8 leaves for a 3-level tree.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.