Alpha–beta pruning
Alpha–beta pruning is a tree search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree.[src] It is an adversarial search algorithm used commonly for machine playing of two-player combinatorial games (Tic-tac-toe, Chess, Connect 4, etc.).[src] It stops evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move.[src] Such moves need not be evaluated further.[src] When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.[src]
Alpha–beta pruning is a tree search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm in its search tree.[src] It is an adversarial search algorithm used commonly for machine playing of two-player combinatorial games (Tic-tac-toe, Chess, Connect 4, etc.).[src] It stops evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move.[src] Such moves need not be evaluated further.[src] When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision.[src] With an (average or constant) branching factor of b, and a search depth of d plies, the maximum number of leaf node positions evaluated (with the worst-case move ordering) is O(b d ) – the same as a simple minimax search.[src] If the move ordering for the search is optimal (meaning the best moves are always searched first), the number of leaf node positions evaluated is about O(b×1×b×1×...×b) for odd depth and O(b×1×b×1×...×1) for even depth, or O\left(b^\frac{d}{2}\right) = O\left(\sqrt{b^d}\right) .[src] In the latter case, where the ply of a search is even, the effective branching factor is reduced to its square root, or, equivalently, the search can go twice as deep with the same amount of computation.[src] The explanation of b×1×b×1×...[src] is that all the first player's moves must be studied to find the best one, but for each, only the second player's best move is needed to refute all but the first (and best) first player move—alpha–beta ensures no other second player moves need be considered.[src] When nodes are considered in a random order (i.e., the algorithm randomizes), asymptotically, the expected number of nodes evaluated in uniform trees with binary leaf-values is \Theta\left(\left(\frac{b-1+\sqrt{b^2+14b+1}}{4}\right)^d \right) .[src] For the same trees, when the values are assigned to the leaf values independently of each other and say zero and one are both equally probable, the expected number of nodes evaluated is \Theta\left(\left(b/2\right)^{d}\right) , which is much smaller than the work done by the randomized algorithm, mentioned above, and is again optimal for such random trees.[src] When the leaf values are chosen independently of each other but from the [0,1] interval uniformly at random, the expected number of nodes evaluated increases to \Theta\left(b^{d/\log(d)}\right) in the d\to\infty limit, which is again optimal for this kind of random tree.[src] Note that the actual work for "small" values of d is better approximated using 0.925 d^{0.747} .[src] A chess program that searches four plies with an average of 36 branches per node evaluates more than one million terminal nodes.[src] An optimal alpha-beta prune would eliminate all but about 2,000 terminal nodes, a reduction of 99.8%.[src] coding simplifications.[src] Normally during alpha–beta, the subtrees are temporarily dominated by either a first player advantage (when many first player moves are good, and at each search depth the first move checked by the first player is adequate, but all second player responses are required to try to find a refutation), or vice versa.[src] This advantage can switch sides many times during the search if the move ordering is incorrect, each time leading to inefficiency.[src] As the number of positions searched decreases exponentially each move nearer the current position, it is worth spending considerable effort on sorting early moves.[src] An improved sort at any depth will exponentially reduce the total number of positions searched, but sorting all positions at depths near the root node is relatively cheap as there are so few of them.[src] In practice, the move ordering is often determined by the results of earlier, smaller searches, such as through iterative deepening.[src] Additionally, this algorithm can be trivially modified to return an entire principal variation in addition to the score.[src] Some more aggressive algorithms such as MTD(f) do not easily permit such a modification.[src] if depth == 0 or node is terminal then return the heuristic value of node if maximizingPlayer then value := −∞ for each child of node do value := max(value, alphabeta(child, depth − 1, α, β, FALSE)) if value ≥ β then break (* β cutoff *) α := max(α, value) return value else value := +∞ for each child of node do value := min(value, alphabeta(child, depth − 1, α, β, TRUE)) if value ≤ α then break (* α cutoff *) β := min(β, value) return value (* Initial call *) alphabeta(origin, depth, −∞, +∞, TRUE) Implementations of alpha–beta pruning can often be delineated by whether they are "fail-soft," or "fail-hard".[src] The pseudo-code illustrates the fail-soft variation.[src] With fail-soft alpha–beta, the alphabeta function may return values (v) that exceed (v β) the α and β bounds set by its function call arguments.[src] In comparison, fail-hard alpha–beta limits its function return value into the inclusive range of α and β.[src]
33 sentences · 33 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Alpha–beta pruning." encyclopegia.org, 2026, https://encyclopegia.org/wiki/alpha-beta-pruning. Accessed 25 November 2026.
Chicago
"Alpha–beta pruning." encyclopegia.org. Accessed November 25, 2026. https://encyclopegia.org/wiki/alpha-beta-pruning.
APA
encyclopegia.org. (2026). Alpha–beta pruning. Retrieved November 25, 2026, from https://encyclopegia.org/wiki/alpha-beta-pruning
Accessed November 25, 2026 · CC BY-SA 4.0 · citation page · JSON