Alpha-beta pruning Created 2026-10-20 Updated 2026-11-05
Alpha-beta pruning evaluates a minimax search tree while omitting branches that cannot change an already available decision. The parameter bounds what Max can already secure, and bounds what Min can already enforce along the current search path. Once , further children of that node cannot improve the relevant ancestor's choice.
If Max already has an alternative worth five, and a new Min node has a child worth three, that node's value is at most three. Its remaining children can be skipped. Full-depth pruning preserves the root minimax value; applying it to a depth-limited evaluation preserves that truncated value, not necessarily the true game result. Good move ordering makes cutoffs occur sooner.[ref]
CS 188 minimax notes 2026-10-24
Official course-hosted technical exposition: 3.2 Minimax.
Relevant locator: §3.2.1, Alpha-Beta Pruning, ancestral alternatives and dependence on child order. The solution's alpha-beta pruning code and mathematical comparisons are given explicitly.
Expectiminimax 2026-10-25
Backward induction on a finite game tree containing maximizing choices, minimizing choices and chance nodes. Terminal utilities are backed up by , and , respectively. Exact chance node evaluation generally needs every positive-probability outcome; ordinary alpha-beta pruning does not transfer unchanged because one child's value does not bound the full weighted sum.
Move ordering 2026-10-25
The order in which legal child positions are searched. Good move ordering supplies useful alternatives early and increases alpha-beta pruning; poor move ordering can leave the worst-case time complexity of full minimax search unchanged.
Nearly-zero-sum pruning 2026-10-25
Suppose every terminal pair satisfies . At a B-node with immediate A-parent, let be the A-coordinate of a completed alternative already retained by the parent. If a completed B-child supplies B-coordinate , then every eventual B-selected pair has and hence . Therefore permits discarding this B-option and skipping its remaining children. Equality is also safe if the parent keeps its existing option on a tie.
The inequality remains valid at completed subtrees because max-n search copies one terminal pair. If the observed pair is , then , so and is a weaker sufficient test. At this reduces to the usual MIN-node alpha-beta pruning cutoff. A discarded option is not assigned a fabricated exact pair; the proof uses a certified alternative at the immediate parent.
Depth-first search computes minimax search values with much less live storage and naturally supports alpha-beta pruning. A parent's value needs only its current best child value and the next child to visit. Once a child subtree has been evaluated, its internal search nodes can be discarded; a final value cannot usually be computed from a nonterminal frontier alone.
With branching factor and horizon , breadth-first search stores a frontier of order . A depth-first search implementation storing sibling lists uses space complexity; lazy successor generation can reduce this to frames plus game-state storage. Both unpruned traversals have time complexity for . Depth-first search also supplies a completed sibling outcome early, allowing alpha-beta pruning to reject later subtrees before generating them.
Use utilities from A's viewpoint, with A maximizing and B minimizing. The following alpha-beta pruning code assumes a finite horizon or terminating game tree; leaf evaluation uses terminal utility when available and a specified horizon estimate otherwise.
ALPHABETA(state, depth, alpha, beta, maximizing):
    if state is terminal or depth == 0:
        return EVALUATE(state)
    if maximizing:
        value := -infinity
        for child in SUCCESSORS(state):
            value := max(value, ALPHABETA(child, depth-1, alpha, beta, false))
            alpha := max(alpha, value)
            if alpha >= beta: break
        return value
    else:
        value := +infinity
        for child in SUCCESSORS(state):
            value := min(value, ALPHABETA(child, depth-1, alpha, beta, true))
            beta := min(beta, value)
            if alpha >= beta: break
        return value
Call the root with and record the child giving the greatest root value. In a nonterminal game state, SUCCESSORS must supply the game's legal moves, including any mandatory pass; a player with no moves must be handled according to the rules rather than left as an accidental empty loop.
The bound records an outcome already available to MAX on the active ancestor path; records one already available to MIN. At a MIN node, once a child gives value at most , further children can only decrease the node's minimum, so MAX need not choose that branch. The dual argument applies at MAX when its current value is at least . Returned values from cut-off subtrees can be bounds rather than exact local minimax search values, while the unrestricted root value is exact. Equal-value pruning preserves that value; retaining the first best root action gives a fixed tie rule.[ref]
With excellent move ordering, the new horizon is approximately ; without a move ordering assumption, no doubling is guaranteed. For , a full minimax search to depth visits search nodes, so the budget has . Perfectly ordered alpha-beta pruning evaluates only about leaves at depth . More precisely, for a complete uniform game tree, the best leaf count is . Equating the dominant costs gives
Constant factors and rounding affect the exact horizon. Poor move ordering can leave the cost at , giving no asymptotic depth improvement. For , there is no branching to prune and the doubling argument does not apply.[ref]
Expectiminimax adds chance nodes to the MAX and MIN decisions. A chance node uses
so exact evaluation generally needs all outcomes with positive probability. An unfavorable child does not determine the expected value: a later, sufficiently favorable child can offset it. Ordinary alpha-beta pruning therefore does not directly discard the remaining outcomes.
Random outcomes also enlarge the effective branching factor. If each player decision has choices and each action has chance outcomes, exploring player decisions can require order leaves rather than . Under the same budget, this gives roughly
before additional pruning benefits available in the deterministic game are considered. Exact probability calculations add overhead as well. These effects explain the typically shallower horizon; randomness alone is not a theorem of inevitable slowdown. Known utility bounds permit some expected value bounds and specialized pruning, and chance sampling can trade exactness for speed.[ref]
The usual alpha-beta pruning inference fails because increasing B's utility need not decrease A's utility. A partially explored B-node may have found a child unfavorable to A, but B may prefer an unseen child favorable to A as well. An observed low A-coordinate therefore supplies no upper bound on the A-coordinate ultimately propagated by B.
For a concrete counterexample, let a root A-node already have an alternative outcome . In another B-node, the first explored child yields . A zero-sum-style cutoff would discard its remaining children because . But an unseen child with outcome is preferred by B, and makes the complete B-node return , which A strictly prefers to its incumbent. Such a cutoff changes the answer.
The problem persists even after observing a large B-coordinate: without a known relation between coordinates or useful global utility bounds, an unseen pair may have still larger values for both players. Hence there is no generally valid ordinary scalar alpha-beta pruning rule for unrestricted general-sum games. This does not rule out all search pruning: additional bounds, dominance information or a relationship between players' utilities can justify specific cutoffs, as in (g).
Consider a B-node whose parent is an A-node with an already completed incumbent outcome having A-coordinate . At the B-node, let be the best completed child pair found so far according to B's coordinate. Every remaining child can be skipped, and this B-option discarded by its parent, if
Use a strict inequality if ties must remain open; equality is safe under the fixed rule that the parent retains its already selected child on an A-coordinate tie. This is a nearly-zero-sum pruning rule.
To prove it, note first that a completed max-n search value is some terminal utility pair: each backup copies one entire child pair. Thus the nearly-zero-sum inequality holds at every completed subtree, not just at leaves. Since B maximizes its own coordinate, the ultimately selected pair at this B-node has . Therefore
The already available A-option is at least as good, so remaining children of this B-node cannot alter the parent's selected continuation under the stated tie rule. The second half of the two-sided nearly-zero-sum condition also gives , hence
Consequently is another sufficient cutoff, useful if one phrases the test using the observed A-coordinate. The pair-based test is sharper: the value of can certify a cutoff even when the conservative test cannot.
When , every pair satisfies , and the rule reduces to , the ordinary MIN-node alpha-beta pruning cutoff. The extra in the A-coordinate-only condition is necessary in general: an observed pair satisfies the bound for , but B prefers an unseen for . A increases by almost ; using just as the upper bound would be invalid.
Implementation must discard the ruled-out B-option at its parent rather than return as an exact completed utility pair. The proof uses an actual completed alternative at that parent; it does not authorize passing arbitrary distant ancestor bounds through general-sum game backups as if every scalar alpha-beta pruning invariant still held. With these local certified cutoffs, an induction over completed subtrees preserves the selected pair and hence the root outcome.