Minimax Algorithm with Alpha-Beta Pruning
Complete step-by-step analysis of game tree evaluationConsider a two-player, zero-sum strategy game between MAX and MIN:
Goal: MAX wants to guarantee the best possible outcome, assuming MIN plays optimally.
Each path from root to leaf represents one possible way the game could unfold.
MAX chooses Left → MIN chooses A → Game ends: Score = 3
MAX chooses Right → MIN chooses D → Game ends: Score = 10
The Problem: MAX doesn't know which path MIN will choose! MAX needs a strategy that guarantees the best possible result regardless of what MIN does.
Now that you understand the game, you'll solve MAX's strategy problem using two approaches:
Key insight: Both methods find MAX's optimal strategy, but Alpha-Beta does it faster!
By completing this exercise, you will be able to:
Complete tree evaluation without pruning (8 points)
| Node | Type | Children Values | Operation | Result |
|---|---|---|---|---|
| A | MIN | [3, 12] | MIN(3, 12) | 3 |
| B | MIN | [8, 2] | MIN(8, 2) | 2 |
| C | MIN | [14, 5] | MIN(14, 5) | 5 |
| Left MIN | MIN | [3, 2, 5] | MIN(3, 2, 5) | 2 |
| D | MIN | [2, 10] | MIN(2, 10) | 2 |
| Right MIN | MIN | [2] | 2 | 2 |
| ROOT | MAX | [2, 2] | MAX(2, 2) | 2 |
Total nodes evaluated: All 8 leaf nodes + 6 internal nodes = 14 nodes. The standard minimax algorithm examines every possible terminal position to determine the optimal play, guaranteeing the best possible outcome for MAX assuming optimal play from both players.
Optimized search with branch elimination (8 points)
After the β-cutoff at D, the entire Right MIN node's value is fixed at 2.
| Step | Node | α | β | Action | Result |
|---|---|---|---|---|---|
| 1 | Root | -∞ | +∞ | Initialize | Start search |
| 2 | A | -∞ | +∞→3 | Evaluate [3,12] | 3 |
| 3 | B | -∞ | +∞ | Evaluate [8,2] | 2 |
| 4 | C | -∞ | +∞ | Evaluate [14,5] | 5 |
| 5 | Left MIN | -∞→2 | +∞ | min(3,2,5) = 2 | 2 |
| 6 | D | 2 | +∞→2 | Found 2, β≤α, prune 10 | 2 |
| 7 | Root | 2 | +∞ | MAX(2,2) | 2 |
Standard Minimax: 8 leaf evaluations
Alpha-Beta Pruning: 7 leaf evaluations
Pruned nodes: 1 leaf (D's second child: 10). This represents a 12.5% reduction in evaluated nodes while maintaining the same optimal result.
Understanding the benefits and trade-offs (4 points)
Alpha-beta pruning optimizes the minimax search by maintaining bounds on achievable values (α for MAX's guaranteed minimum, β for MIN's guaranteed maximum) and eliminating branches that cannot influence the final decision. When the algorithm determines that a subtree cannot produce a better result than alternatives already found, it prunes that entire subtree without evaluation, significantly reducing search time while maintaining the same optimal result as standard minimax.
Standard minimax explores every path to completion before making decisions, while alpha-beta pruning uses partial information to eliminate unpromising branches early in the search process.
Alpha-beta maintains running bounds (α and β) that represent the best outcomes each player can guarantee, allowing immediate recognition when a branch cannot improve upon already-found alternatives.
Both algorithms produce the same optimal decision, but alpha-beta achieves this with significantly fewer node evaluations, making it practical for deeper searches in real-time game applications.
Essential concepts and practical implications