Alpha-Beta Pruning
Minimax that skips branches which cannot change the answer.
The idea
Alpha is the best score MAX can already guarantee, beta the best MIN can guarantee. When a branch is shown to be worse for the player choosing than an option already available, the rest of it can be skipped, because a rational opponent would never let the game go there. The answer is identical to minimax, found by looking at far fewer nodes.
prune when α ≥ β
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- MAX
- MIN
- now
- pruned
Alpha-beta pruning gives the same answer while skipping branches that cannot matter. α = best MAX can guarantee, β = best MIN can guarantee.
- leaves evaluated:
- 0
Try new data: alpha-beta always returns the same value as minimax, with fewer leaves.
Step by step
- 1Start with alpha = −∞ and beta = +∞ at the root.
- 2Search a child, updating alpha at MAX nodes and beta at MIN nodes.
- 3If alpha ≥ beta, stop looking at the remaining children (a cut-off).
- 4Return the value up the tree, as in minimax.
Where it is used
The search core of almost every classic chess engine.
Watch out for
Savings depend on move ordering: looking at the best moves first can roughly double the reachable depth.