Minimax is a search algorithm for two-player, zero-sum games that chooses the move maximizing a player’s guaranteed outcome, assuming the opponent always replies with the move that is worst for that player. Within Symbolic AI & reasoning, it is the foundational method of adversarial search: the game is represented explicitly as states, legal moves and outcomes, and the algorithm reasons over that symbolic structure rather than learning from data.
The idea dates to John von Neumann’s minimax theorem of 1928 and entered computer game playing through the chess programs of Claude Shannon and Alan Turing. Not to be confused with the Minimax family of AI models, which is an unrelated product name.
How the minimax algorithm evaluates a game tree
The minimax algorithm works by recursively exploring a game tree, in which each node is a position and each edge is a legal move. Levels alternate between the MAX player, who seeks the highest value, and the MIN player, who seeks the lowest. Values flow upward from the leaves, a process called backing up the values.
- Generate the tree from the current position down to a fixed depth or to terminal positions.
- Score each leaf with the utility function (win, loss, draw) or, at a depth cutoff, with a heuristic evaluation function.
- At every MIN node, take the minimum of the child values.
- At every MAX node, take the maximum of the child values.
- At the root, play the move whose child carries the best backed-up value.
The following table summarizes the roles of the components in a standard depth-limited minimax search.
| Component | Role | Typical form |
|---|---|---|
| Game state | Symbolic description of a position | Board array, bitboard, move list |
| Successor function | Produces legal moves from a state | Rule-based move generator |
| Terminal test | Detects the end of the game | Checkmate, full board, no moves |
| Utility function | Scores finished games | +1, 0, -1 or large constants |
| Evaluation function | Estimates value of non-terminal states | Weighted sum of features |
| Depth limit | Bounds the search horizon | Plies chosen by time budget |
Complexity, depth and the negamax formulation
Minimax visits every node of the tree, so its time complexity is O(b^d), where b is the branching factor and d is the search depth in plies. Its space complexity is O(bd) when implemented as a depth-first recursion. This exponential growth is the central practical limitation: a chess branching factor of about 35 means that each additional ply multiplies the work roughly thirtyfold.
Many implementations use negamax, an equivalent formulation that relies on the identity max(a, b) = -min(-a, -b). Each node simply negates and maximizes the values of its children, which removes the separate MIN branch and simplifies the code without changing results.
The figures below show how the branching factor drives the cost of a full-width search in well-known games.
| Game | Average branching factor | Nodes at depth 6 |
|---|---|---|
| Tic-tac-toe | About 4 to 5 | Full tree solvable |
| Connect Four | About 7 | About 120,000 |
| Chess | About 35 | About 1.8 billion |
| Go (19×19) | About 250 | About 2.4 x 10^14 |
Minimax compared with related adversarial search methods
Minimax is the reference semantics for adversarial search; most later methods either compute the same value faster or approximate it differently. Alpha–beta pruning returns exactly the minimax value while skipping branches that cannot affect the decision, and with good move ordering it can search roughly twice as deep in the same time.
| Method | Relation to minimax | Best suited to |
|---|---|---|
| Plain minimax | Defines the optimal value | Small trees, teaching, verification |
| Alpha–beta pruning | Same result, fewer nodes | Chess, checkers, deterministic games |
| Expectiminimax | Adds chance nodes with averages | Backgammon, dice games |
| Monte Carlo tree search | Samples instead of full expansion | Go, very large branching factors |
| Iterative deepening | Repeats minimax at growing depths | Time-limited play |
Minimax also differs from ordinary state-space search such as best-first search: there is no single goal to reach, but an opponent whose choices must be anticipated. This makes it a decision rule under strict adversarial uncertainty rather than a path-finding procedure.
Designing evaluation functions and search enhancements
In real games the tree cannot be searched to the end, so playing strength depends heavily on the evaluation function applied at the cutoff. Classical engines used hand-crafted features such as material balance, mobility and king safety; modern engines often use neural evaluation, but the minimax backup remains the same.
The following table maps common practical needs to the standard enhancements that address them.
| Need | Enhancement | Effect |
|---|---|---|
| Avoid repeated work | Transposition table | Reuses values of identical positions |
| Respect a time limit | Iterative deepening | Always has a best move ready |
| Stabilize tactical positions | Quiescence search | Extends search through captures |
| Search deeper cheaply | Move ordering heuristics | Improves alpha–beta cutoffs |
| Handle forced lines | Search extensions | Adds depth for checks or threats |
Limitations and common misconceptions
Minimax rests on assumptions that do not always hold, and misreading them leads to weak or brittle play. Practitioners should keep the following points in mind.
- Optimal opponent assumption: minimax plays safely against perfect play but may miss chances to exploit a weaker opponent.
- Horizon effect: a fixed depth can push an unavoidable loss just beyond the cutoff, so the search believes the danger is gone.
- Evaluation errors propagate: backed-up values are only as reliable as the heuristic at the leaves.
- Not for imperfect information: poker and similar games require game-theoretic methods such as counterfactual regret minimization.
- Zero-sum requirement: with more than two players or non-opposing payoffs, variants such as max^n are needed.
A common misconception is that alpha–beta pruning is a different algorithm with a different answer. In fact it is an exact optimization of minimax, and any disagreement between the two indicates a bug in the implementation.
Understanding it simply
Minimax is a way for a computer to plan moves in a game like chess. It looks ahead at its own moves. It also looks at every answer the opponent could give. It then assumes the opponent will always pick the reply that hurts most.
Think of a careful chess player who asks, before each move, what the worst thing is that could happen next. That player picks the move whose worst case is still the best. Minimax chooses the safest strong move, not the most hopeful one.
Applied in practice
A small team builds a Connect Four engine for an educational puzzle app. The developers implement negamax with alpha–beta pruning, a transposition table and a simple evaluation that counts open three-in-a-row patterns. On a mid-range phone, the engine searches about 10 to 12 plies within a one-second budget using iterative deepening.
To support beginners, the team limits the hardest level to the full depth and lowers the depth to 2 to 4 plies for easier levels. Testing against a known perfect solver shows that the hardest level never loses from the opening position when it moves first, while the easier levels make realistic, human-like mistakes. The minimax framework let the team tune difficulty by changing one parameter rather than writing separate opponents.