How minimax values a perfect-information game

Short answer: Minimax values a two-player zero-sum game of perfect information by recursion on the game tree. A terminal position returns its payoff to the player about to move, or a fixed score for the player who just lost. A maximizing node takes the maximum of its children. A minimizing node takes the minimum. With optimal play the root value is the value of the game. The time is proportional to the number of leaves, which is O(b^d) for branching factor b and depth d.


What the problem actually asks

If both players play perfectly, the player to move chooses the child whose backed-up value is best for them, and the opponent will do the same on their turn. That alternation is the max and the min. No probability is involved. A chance node, as in a dice game, would average over outcomes and is expectiminimax, not this algorithm.

The tree is usually too large to expand. Depth-limited search replaces a leaf at the horizon with a static evaluation. That evaluation is an approximation. The minimax value of the truncated tree is exact only for the truncated tree, not for the real game.


What the algorithm guarantees

On a finite tree with true terminal payoffs, the backed-up root value equals the game value under optimal play, and the argmax child is an optimal move. Time and memory of a depth-first implementation are O(b^d) time and O(d) memory. Alpha-beta pruning computes the same value and skips branches that cannot change it. Negamax is the same recurrence written so both layers maximize, by negating the child’s value.

The algorithm assumes alternating turns, perfect information, and a zero-sum payoff. Simultaneous moves, hidden cards, or a non-zero-sum payoff need a different solution concept.


The working steps

  1. If the position is terminal, return its payoff to the maximizing player.
  2. If the player to move is the maximizer, return the maximum of the minimax values of the legal children.
  3. If the player to move is the minimizer, return the minimum of those values.
  4. The move to play is any child that attains the root value.
  5. At a depth limit, return a heuristic evaluation instead of a terminal payoff, and treat that number as exact only inside the truncated tree.

The exponential cost is the full tree. Alpha-beta is the pruning that preserves the value. A depth limit plus an evaluation is an approximation. Expectiminimax inserts chance nodes. Minimax itself is deterministic perfect-information backup.


Approaches that look simpler and fail

Approach Why it fails when a depth-limited evaluation is treated as the game value
Stop at a fixed depth and call the evaluation the true value The number is the minimax value of a different, shorter game whose leaves were labeled by the heuristic. The real game can disagree.
Average the children An average is a chance node or a policy that plays randomly. Optimal play selects the extreme, not the mean.
Maximize at both layers The opponent’s layer then cooperates. Negamax maximizes both layers only after negating the returned value.
Explore the whole tree when alpha-beta is available The value is identical and the work is larger. Alpha-beta is the same theorem with pruned branches.

Pruning that preserves the minimax value is alpha-beta. A sampled tree with rollouts is Monte Carlo tree search. Minimax is the exact backup of a perfect-information tree.


A working example

This Python fragment alternates max and min down a complete game tree. On the same leaves 3, 5, 2, 9 the root value is 3.

leaves = [3, 5, 2, 9]

def minimax(i, depth, maximizing):
    if depth == 2:
        return leaves[i]
    kids = (minimax(i * 2, depth + 1, not maximizing), minimax(i * 2 + 1, depth + 1, not maximizing))
    return max(kids) if maximizing else min(kids)

assert minimax(0, 0, True) == 3
print(minimax(0, 0, True))

Where it is used

Minimax values a two-player game such as chess or tic-tac-toe by assuming both sides play perfectly. Engines do not search the full tree: alpha-beta cuts it. Monte Carlo tree search is the sampling alternative used when the branching factor makes the full value impossible.


When you can drop this algorithm

Drop a full minimax expansion of a deep game. Use alpha-beta, a depth limit, or a sampling search, and label a heuristic leaf as a heuristic. Keep full minimax for a small tree whose leaves are true terminals.


Why this stays published

We publish this so a search for minimax returns the alternating max and min and the exponential size of the unpruned tree. Minimax backs up a perfect-information game tree by alternating maximum and minimum, and the root value is the game value when the leaves are true terminal payoffs.

本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。

Leave a Reply

Your email address will not be published. Required fields are marked *