Alpha–beta pruning

Also known as: alpha-beta search

On this page 7

Alpha–beta pruning is an optimization of minimax search that stops examining a branch of a game tree as soon as it is proven that the branch cannot influence the final decision. It returns exactly the same move and value as plain minimax while visiting far fewer positions. As a classic technique of Symbolic AI & reasoning, it underpins adversarial search in chess, checkers, Othello and many other two-player games of perfect information.

The method is also known as alpha-beta search. Its power comes from two running bounds, alpha and beta, that record the best outcomes each player is already guaranteed elsewhere in the tree. When those bounds cross, the remaining siblings of a node are irrelevant and are cut off without evaluation.

How alpha–beta pruning cuts the game tree

Alpha–beta pruning works by carrying a search window of two values down the tree during a depth-first minimax traversal. Alpha is the best score the maximizing player can already secure on the current path, and beta is the best score the minimizing player can already secure. Any node whose value is proven to fall outside the interval between alpha and beta cannot be reached under rational play.

At a maximizing node, the algorithm raises alpha whenever a child returns a higher value. If alpha reaches or exceeds beta, the opponent would never allow play to enter this node, so the remaining children are skipped; this event is a beta cutoff. The symmetric event at a minimizing node is an alpha cutoff. The pruning is sound: it never changes the root value, because every discarded line is provably no better for the player who would have to choose it.

The table below summarizes the core quantities that the algorithm maintains during a search.

QuantityMeaningUpdated at
AlphaLower bound guaranteed to the maximizerMaximizing nodes
BetaUpper bound guaranteed to the minimizerMinimizing nodes
Search windowOpen interval between alpha and betaPassed to every child
Cutoff conditionAlpha is greater than or equal to betaAfter each child returns
Root callAlpha at minus infinity, beta at plus infinityStart of the search
Core quantities in alpha–beta search

Why move ordering decides the speedup

The efficiency of alpha–beta pruning depends almost entirely on move ordering, the sequence in which children are examined. If the best move at every node is searched first, the number of leaf positions drops from roughly b to the power d to about b to the power d/2, where b is the branching factor and d is the depth. In practice, perfect ordering allows a program to search about twice as deep as plain minimax in the same time.

With the worst possible ordering, no branch is ever cut and alpha–beta degenerates into full minimax. With random ordering, the effective cost lies in between, close to b to the power 3d/4 for many game trees. The following table compares these cases for a chess-like branching factor of about 35.

Ordering qualityApproximate leaf countPractical consequence
Perfect orderingb to the power d/2Roughly doubles reachable depth
Random orderingAbout b to the power 3d/4Moderate gain over minimax
Worst orderingb to the power dNo gain at all
Typical engine with heuristicsClose to the perfect caseMost of the theoretical gain
Effect of move ordering on nodes searched

Engines approach the ideal case with ordering heuristics: trying the move stored in a transposition table first, then captures sorted by value, then killer moves that caused cutoffs at the same depth, and finally moves ranked by the history heuristic.

Alpha–beta pruning is one member of a family of game-tree algorithms, and its strengths are clearest beside its neighbors. It is an exact refinement of minimax, whereas sampling methods trade exactness for broader coverage when no reliable evaluation function exists.

AlgorithmCore ideaTypical use
MinimaxExhaustive evaluation of every lineTeaching, very small games
Alpha–beta pruningMinimax with provably safe cutoffsChess and checkers engines
Principal variation searchNull-window tests for non-first movesStrong modern engines
MTD(f)Series of zero-window alpha–beta callsEngines with good memory tables
ExpectiminimaxAdds chance nodes for dice or cardsBackgammon-style games
Monte Carlo tree searchStatistical sampling of playoutsGo and games without good heuristics
Alpha–beta pruning and neighboring algorithms

Principal variation search and MTD(f) are not replacements but enhancements built on alpha–beta: they narrow the window deliberately to produce more cutoffs and re-search only when a narrow test fails.

Practical enhancements in game engines

Real programs almost never run plain alpha–beta to a fixed depth. They wrap it in iterative deepening, searching depth 1, then 2, then 3 and so on, so that each shallower iteration supplies a good move ordering for the next and a usable answer exists whenever time runs out. A depth-limited search then relies on a static evaluation function that scores non-terminal positions.

  • Transposition tables store results for positions reached by different move orders, avoiding repeated work.
  • Quiescence search extends the search through captures and checks so that evaluation happens only in quiet positions.
  • Aspiration windows start the root search with a narrow window around the previous score.
  • Null-move pruning and late move reductions are heuristic, not exact, and accept a small risk of error for much greater depth.

The distinction between exact and heuristic pruning matters: classic alpha–beta is provably correct, while forward-pruning techniques such as null-move pruning can, in rare positions, miss the best move.

Limitations and common misconceptions

Alpha–beta pruning assumes a two-player, zero-sum game with perfect information and alternating moves. It does not handle hidden information directly, and its benefits shrink in games with very high branching factors, such as Go, where a reliable evaluation function is hard to write. The table lists frequent errors and their remedies.

MistakeSymptomFix
Swapping alpha and beta incorrectlyWrong moves or no cutoffsNegate and swap bounds in negamax form
No move orderingSpeed close to plain minimaxAdd transposition and killer heuristics
Evaluating noisy positionsHorizon effect blundersAdd quiescence search
Storing bounds as exact valuesCorrupted transposition dataRecord bound type with each entry
Frequent mistakes when implementing alpha–beta

A common misconception is that alpha–beta pruning is an approximation. It is not: given the same depth and evaluation function, it always returns the minimax value. Another misconception is that it removes the need for heuristics; in fact, the quality of the evaluation function still determines playing strength.

In everyday language

Imagine planning a game move by move. You look at your options and the replies your opponent could make. Soon you find a reply that ruins one of your options. You do not need to study the other replies to that option. One bad answer is enough to reject it.

Alpha–beta pruning teaches a computer this habit. It keeps track of the best result each side can already count on. When a line of play is clearly worse, it stops looking at that line. The final choice stays exactly the same. The computer simply wastes less time, so it can look further ahead.

Seen in the real world

A university team builds a checkers program for a course project. Their first version uses plain minimax and reaches depth 8 in about ten seconds per move on a laptop. Opponents easily set traps one move beyond that horizon.

The team adds alpha–beta pruning, then orders moves so that captures come first and the best move from the previous iteration is tried before all others. With iterative deepening and a small transposition table, the same ten seconds now reach depth 15 or 16. Because the pruning is exact, the program chooses the same moves minimax would at each depth, only far faster.

In a class tournament, the improved program wins every game against the minimax version and avoids the shallow traps that defeated it before. The students also learn that most of the gain came from better move ordering, not from the pruning rule alone.