4.12 Adversarial search: minimax and alpha-beta pruning
You can build a game tree, run minimax and alpha-beta pruning by hand, and cut a search off with an evaluation function when the tree is too large to finish.
Before:01a. Linear Algebra01b. Calculus and Optimisation01c. Probability01d. Statistics and Inference02. Python — Basics to Advanced
A second agent changes the problem: you no longer choose a sequence of moves, you choose a policy that survives an opponent choosing against you. Minimax is that idea written down, alpha-beta is the observation that most of the tree cannot change the answer and need not be looked at, and the evaluation function is the admission that real games do not fit in memory.
Work through these
Formulate a game: players, moves, terminal states and a utility for each outcome
The pieces a two-player game needs before any algorithm can run, and the one that matters most is the number attached to each ending. Everything the search does is an attempt to reach a good one of those numbers.
Run minimax on a small game tree by hand
Working the values up from the endings, taking the largest at your own turn and the smallest at the opponent's. Doing it by hand once is what makes the alternation stop feeling arbitrary.
Apply alpha-beta pruning, and show it returns the same answer
Skipping parts of the tree that cannot change the result, using the best values found so far on each side. The saving is large and the answer is identical, which is the point worth proving to yourself.
Explain why move ordering decides how much alpha-beta saves
Looking at strong moves first lets the cutoffs happen early, and a good ordering roughly squares the depth reachable in the same time. A bad ordering leaves you with plain minimax and extra bookkeeping.
Cut the search off with a depth limit and an evaluation function
Real games do not end within reach, so the search stops early and scores the position with a hand-built or learned estimate. Every practical player is this compromise, and its quality is the estimate's quality.
Explain the horizon effect and what is done about it
A cut-off search can push a bad outcome past the depth it looks at and report a position as safe when it is not. Quiescence search and deeper looks at unstable positions are the standard answers.
Sign in to keep your progress.
Free resources
We haven't checked most of these for screen reader use yet.
Links last checked 29 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.