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.

Minimax Value

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

Reading the result

The number at the root is a guarantee, not a prediction. It says Max can force at least that score no matter what Min does, and Min can hold Max to no more than it. Neither player can do better against an opponent who is also playing perfectly, which is why it is called the value of the game.

A common misreading is to look for the largest leaf and expect that to be the answer. It usually is not. In the tree 3, 5, 2, 9 the biggest leaf is 9, but Max never reaches it: getting there means going right, and Min will simply pick the 2 instead. Max takes the left branch and settles for 3, because 3 is the better of the two guarantees available.

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

Real engines cannot search a full game tree. Chess has roughly 35 legal moves in a typical position, so a 10-ply search is around 2.7 quadrillion leaves. Alpha-beta pruning cuts that dramatically by abandoning any branch that already cannot beat one the search has committed to, and with good move ordering it examines closer to the square root of the nodes. The values at the leaves then come from an evaluation function rather than from a real win or loss, since the game is nowhere near finished at that depth.

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.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.