Alpha-Beta Pruning — Beginner-Friendly Notes
1. What It Fixes
Minimax visits all leaves — too many. Alpha-Beta skips branches that cannot affect the final decision, yielding same move much faster. It is an optimisation, not a different algorithm — result identical to Minimax.
2. Intuition in One Line
If you already have a move that guarantees score , and opponent has a reply that limits another branch to , you don't need to examine other replies in that branch — they are irrelevant.
3. How It Works (two bounds)
- α (alpha): best value MAX can guarantee so far along the path to root (lower bound). Initial .
- β (beta): best value MIN can guarantee so far (upper bound). Initial .
During DFS traversal:
- At MAX node: update ; if → β-cutoff (prune remaining children — MIN won't let MAX reach this node).
- At MIN node: update ; if → α-cutoff (prune — MAX has a better alternative elsewhere).
AlphaBeta(node, α, β, isMax):
if terminal: return utility
if isMax:
for child:
α = max(α, AlphaBeta(child, α, β, false))
if α >= β: break # prune
return α
else:
for child:
β = min(β, AlphaBeta(child, α, β, true))
if β <= α: break
return β
4. Example That Clicks
MAX root (α=-∞,β=+∞)
├─ MIN A → returns 3 → α=3 at root
└─ MIN B
├─ child 2 → β becomes 2 ≤ α(3) → prune! (even without checking other children, B will be ≤2 <3, so root prefers A)
You saved exploring a whole subtree.
5. Properties
| Property | Value |
|---|---|
| Correctness | Same result as Minimax (pruning is safe) |
| Best-case time | — effectively doubles searchable depth (perfect ordering) |
| Worst-case | (bad ordering — no pruning) |
| Ordering matters | Sort children with best moves first → most pruning |
6. Exam Tips
- Move ordering is key — use heuristic to order moves (e.g., captures first in chess).
- Alpha-Beta + evaluation function + cutoff depth = practical game AI (Deep Blue, chess engines).
7. One-Line Summary
Alpha-Beta prunes Minimax branches that cannot influence the root decision using α/β bounds, preserving optimal play while reducing best-case time to .
8. Quick Self-Check
- Why does α start at and β at ?
- Give a state where pruning happens and where it doesn't.