Part 7: Game Trees

Adversarial search: minimax values, the minimax algorithm, alpha-beta pruning and the bookkeeping it needs, why child ordering changes the savings but never the answer, bounded lookahead, evaluation functions, and generalized minimax with utility tuples.

Source deck: FAI_Part7_GameTrees_25-26.pdf, 39 PDF pages (p.38 is the summary, p.39 the closing "Questions?" slide). Lecture transcript: T6 covers this Part end to end. Exercise material: FAI_EXERCISES_Game_Trees.pdf sections 1 and 2 with the solution deck Oefenzitting05-games.pdf (sections 3 to 5 of that bundle belong to Part 8).
Page-number convention: this deck carries a printed slide number only on PDF pages 2 and 3, where it happens to equal the PDF index. From PDF p.4 onward nothing is printed. Every citation below is therefore a PDF page index, that is, the page your PDF reader shows, not a printed slide number.

Printing reveals every hidden answer automatically.

Printed copy: all task answers below are revealed. On screen they are hidden behind a click, which is how you should use them first.

Lecturer, T9, on why these links matter

the theory exam... tests both for factual knowledge as well as for synthetic knowledge... we also want to see that you can uh bring things across different chapters uh together because as you know by now uh the course is largely incremental. (Lecturer, T9). The cross-Part links above are examinable content, not decoration. Transcripts are machine-transcribed, so quotes contain artefacts such as "note" for "node" and "miniax" for "minimax". They are reproduced exactly as transcribed.

Drill companion: viz-games.html steps through minimax and alpha-beta on a tree you can edit, lets you reorder children to watch the savings change, and has a three-player mode for the utility-tuple version in section 14.

1. What counts as a game here, and the five axes

Deck p.8 opens with a definition that is deliberately wider than the word "game" suggests: a game is a task environment with more than one agent. The lecturer spells out the consequence in T6: driving a self-driving car among other cars is a game in this sense. Nothing in the algorithms below cares whether the other agent is a chess opponent, a ghost, or a competitor in a market.

Deck p.7 lists the milestones the course wants you to be able to place: checkers (first computer player 1950, Samuel's self-taught program 1959, Chinook beats Tinsley in 1994, solved in 2007 with an endgame database of 39 trillion states), chess (Deep Blue beats Kasparov in 1997, Stockfish rated 3551 in 2021 against 2870 for Magnus Carlsen), Go (branching factor above 300, Monte Carlo tree search from 2005, AlphaGo beating world champions in 2016 and 2017), and Pacman. The pattern the summary slide on p.38 draws from that list is worth remembering: each game donated a technique to the field at large. Reinforcement learning (RL) came out of checkers, iterative deepening out of chess, rational metareasoning out of Othello, and Monte Carlo tree search (MCTS) out of Go.

The five axes on p.8 are the classification questions: deterministic or stochastic, perfect information (fully observable) or not, one, two or more players, turn-taking or simultaneous, zero sum or not. The bottom line of that slide states the goal in a way that separates this Part from Parts 3 to 6: we do not want a path, we want a contingent plan, also called a strategy or a policy, which "recomments a move for every possible eventuality" (the typo is on the slide).

Slide listing the five classification axes for games, with two cartoon robots holding playing cards
Part 7, PDF p.8: Types of games axes.

Task: name the property that fails here

Take the five axes and set them for poker. Which single axis, once set the way poker demands, makes every algorithm in this chapter inapplicable, and which axis, once flipped, is handled by Part 8 rather than by this one?

Answer

Perfect information. Poker is not fully observable (you cannot see the opponent's cards), and minimax as defined on p.15 needs to know which state it is in to evaluate it. The deck's own summary on p.38 files partial-information games separately, under "Solution methods for partial-information games in economics (poker)".

The axis that is merely postponed is deterministic or stochastic. A die or a shuffled deck adds chance nodes, which is exactly the extension in Part 8 (expectimax). The remaining three axes (two players, turn-taking, zero sum) are the "standard game" assumptions of p.9.

Deck p.9 fixes the setting for the rest of the Part: "Standard games are deterministic, observable, two-player, turn-taking, zero-sum", and gives the formulation as initial state s0, Player(s) (whose move it is), Actions(s), Result(s, a), Terminal-Test(s), and Utility(s, p). The last item collapses to Utility(s) when we care about only one player. The lecturer justifies that collapse in T6: we assume the player we are designing for is the one who moves at the root, so the player argument is implicit.

Slide listing the standard game assumptions and the six-part game formulation
Part 7, PDF p.9: Standard games.

Task: complete the half-described mapping

Three items of this formulation are already in your Part 3 vocabulary and three are new. Write the mapping: which three carry over unchanged from a single-agent search problem, and what does each of the three new items do that a search problem never needed?

Answer

Carried over: initial state s0, Actions(s), and the transition model Result(s, a). These are exactly the Part 3 ingredients.

New: (i) Player(s) says whose turn it is, which is required because the backup rule at a node depends on the mover, not on the depth alone; (ii) Terminal-Test(s) replaces the goal test, and it can end the game in a loss as well as a win, so it is not a goal test; (iii) Utility(s, p) returns a number rather than a boolean, so terminal states are ranked instead of merely accepted. A single-agent search problem had a goal test and a path cost; a game has a terminal test and a terminal utility.

2. Zero-sum versus general games, and the scope limit

Deck p.10 sets the two columns side by side. In a zero-sum game agents have opposite utilities, it is pure competition, "one maximizes, the other minimizes". In a general game agents have independent utilities and "cooperation, indifference, competition, shifting alliances, and more are all possible".

Tic-tac-toe on p.14 is the concrete instance, and the utilities are printed on that slide in a row labelled "Utility": −1, 0, +1. A win for the cross player is +1, a win for the circle player is −1, a draw is 0. The two players' utilities sum to zero in every terminal state, which is the literal reason for the name.

Slide contrasting zero-sum games, two robots fighting over one gem, with general games, two robots with separate piles of treasure
Part 7, PDF p.10: Zero-sum vs general games.

Task: name the trap in this setup

A student writes: "the utilities in a zero-sum game must add up to zero, so a game where one player scores +5 and the other +3 in every terminal state is not zero-sum." Is that reasoning sound? What is the property that actually matters for minimax?

Answer

The reasoning is too literal. What minimax needs is that the two players' utilities are strictly opposed, so that maximising one is the same as minimising the other. Any constant-sum game has that property: if UA + UB = c for a fixed c, then UB = c − UA, and the ordering B prefers is exactly the reverse of A's. The deck states the property as "Agents have opposite utilities" and "One maximizes, the other minimizes" (p.10), not as an arithmetic identity.

What genuinely breaks minimax is independent utilities, where B's ranking is not determined by A's. That is the right-hand column, and it is the case handled by generalized minimax in section 14.

Lecturer, T6, on the right-hand column of p.10

out of scope for uh for the course. (Lecturer, T6), said about general games: cooperation, shifting alliances, and the rest of the right-hand column. Read this as a scope limit you can rely on: you will not be asked to solve a non-zero-sum or cooperative game as such. You will be asked about generalized minimax with utility tuples (deck p.37), which is the course's one concession in that direction and is examined in exercise session 5 section 2.

3. From "value of a state" to minimax value

Deck pp.12 to 15 build the central definition in three steps, and it pays to see them as three, because the third one is where the adversary enters.

Step 1, single agent (p.12). A tree of states with numbers at the leaves. Nothing to decide yet.

A search tree for a single Pac-Man agent, with numeric utilities at the leaves
Part 7, PDF p.12: Single-agent tree.

Task: predict the next step

This is the same picture as a Part 4 search tree, but one thing has moved. In Part 4 the numbers lived on the edges. Here they live at the leaves. What does that change about the direction in which information flows through the tree?

Answer

Costs on edges accumulate downward as you extend a path, so g is known the moment you build a path. Utilities at leaves propagate upward, so nothing is known about an internal node until its subtree has been explored. That is precisely why the lecturer argues in T6 that the minimax tree should be built depth first: a breadth-first build would produce a large frontier and still know nothing, because no utility is available until a terminal node is reached.

Step 2, value of a state (p.13). The definition on the slide: "Value of a state: The best achievable outcome (utility) from that state". For terminal states V(s) is known; for non-terminal states V(s) = max over successors of V(s'). With a single agent, every node maximises.

The same tree with the recursive definition V(s) = max over successors, and the terminal case V(s) = known
Part 7, PDF p.13: Value of a state (max over children).

Task: fill the blank

The slide's recursion has exactly two lines. Write both, and then say what would have to be added to make it a definition rather than a recursion that might never stop.

Answer

V(s) = known utility if s is terminal; V(s) = maxs' ∈ successors(s) V(s') otherwise. The missing ingredient is a guarantee that every branch reaches a terminal state in finitely many steps, that is, a finite game tree. Deck p.18 supplies m, the maximum number of steps before a terminal state, and uses it in the complexity bound. Sections 11 and 13 below remove that guarantee deliberately and replace the terminal case with an evaluation function.

Step 3, two players (pp.14 to 15). Tic-tac-toe on p.14 shows the alternation of movers. Then p.15 states the rule that makes this Part different from every Part before it:

The justification, spelled out in T6, is not "the opponent is evil" but "the opponent is rational": you assume the opponent plays the move that hurts you most, because that is the assumption that prepares you best, and because a rational opponent will in fact do that. The deck states the same thing on p.16: minimax "Assumes all future moves will be optimal", which makes it "Rational against a rational player".

A tic-tac-toe game tree with layers labelled MAX (X) and MIN (O) alternating, and a TERMINAL row with utilities minus 1, 0 and plus 1
Part 7, PDF p.14: Tic-tac-toe game tree.

Task: state the property that fails here

Tic-tac-toe's terminal utilities are +1, 0 and −1 from the cross player's point of view. Suppose you keep the same tree but change every terminal value from −1 to −100, leaving +1 and 0 alone. Does the minimax move at the root change? Does the minimax value change?

Answer

The move does not change, the value can. Minimax at every node depends only on the ordering of the values among the children, and rescaling −1 to −100 leaves the order −100 < 0 < +1 identical to −1 < 0 < +1. So max and min pick the same children throughout and the optimal policy is unchanged, while the number backed up to the root may become −100 instead of −1.

Carry this forward: the same "only the ordering matters" argument does not survive contact with chance nodes, because an expectation over utilities is sensitive to the actual magnitudes. That is one of the sharp contrasts in Part 8.

A three-level Pac-Man tree: root MAX with value -8, two MIN children with -8 and -10, four terminal states -8, -5, -10, +8
Part 7, PDF p.15: Minimax values with V(s) formulas.

Task: fill the blank cell of the trace

The four terminals on this slide are −8, −5, −10, +8, left to right. Compute the two MIN values and the root, then answer the question the lecturer asks about this slide: what does the sign at the root tell the agent, and which action does it take?

Answer

Left MIN = min(−8, −5) = −8. Right MIN = min(−10, +8) = −10. Root = max(−8, −10) = −8, which is what the slide prints.

The root is negative, so under the assumption of optimal play by both sides the agent will lose whatever it does. Minimax then buys the smallest loss: it takes the left action, because −8 beats −10. Note that the +8 leaf on the right is irrelevant. It sits under the opponent's choice, and the opponent will never hand it over.

Constructed, in the sample paper's format (2023 theory MC block: one true/false item per lecture)

The minimax value of the root is the largest utility that appears at any leaf of the game tree.

False, and deck p.15 is its own counterexample. Its leaves are −8, −5, −10 and +8, the largest is +8, and the root is −8. The +8 sits under a MIN node, so the opponent never plays into it.

Why True looks right: "the best achievable outcome (utility) from that state" (p.13) is the single-agent definition, and there the root really is the best leaf. From p.15 onwards half the layers are outside your control, so the root is the best outcome you can force, not the best outcome present in the tree.

Marking: +0.5 correct, −0.25 wrong, 0 for a blank (Lecturer, T9), so answer it even on a coin flip.

4. The minimax algorithm and what it costs

Deck p.17 gives the implementation in two functions. The value function is the recursion of p.15 written out; the decision function is the wrapper that turns a value into a move.

function minimax_value(s) returns a value
    if Terminal-Test(s) then return Utility(s)
    if Player(s) = MAX then return maxa in Actions(s) minimax_value(Result(s,a))
    if Player(s) = MIN then return mina in Actions(s) minimax_value(Result(s,a))

function minimax-decision(s) returns an action
    return the action a in Actions(s) with the highest minimax_value(Result(s,a))
Slide with the minimax_value and minimax-decision pseudocode
Part 7, PDF p.17: Minimax pseudocode.

Task: name the trap in this setup

Why are there two functions rather than one? A student who writes only minimax_value and reports its result has answered a different question from the one the exam asks. Which one?

Answer

minimax_value returns a number, the value of the position. minimax-decision returns an action, the move to play. An exam question that says "which move should MAX play" is answered by naming a branch, not by writing 3. The distinction also matters mechanically: after alpha-beta pruning the value returned by a pruned child is only a bound, so the number attached to that child cannot be quoted as its minimax value even though the root's value and the root's best action are both still correct.

Deck p.18 gives the cost, and the phrasing is exact: minimax is "Just like (exhaustive) DFS", Time: O(bm), Space: O(bm), with the chess figures b ≈ 35 and m ≈ 100. Note the asymmetry between the two bounds: time is exponential because every leaf is visited, space is linear because a depth-first walk holds only the current path plus the siblings at each level on it.

Slide: how efficient is minimax, time O(b^m), space O(bm), chess b about 35 and m about 100
Part 7, PDF p.18: Minimax efficiency O(b^m).

Task: predict the number before revealing

Using the slide's own figures for chess, write down (i) the number of leaves an exhaustive minimax would visit, and (ii) the number of nodes the algorithm holds in memory at once. Then say which of the two is the reason chess programs cannot use plain minimax.

Answer

(i) bm = 35100 ≈ 2.55 × 10154, a 155-digit number. (ii) b × m = 35 × 100 = 3500 nodes, which fits in a pocket calculator.

Time is the blocker, not space. That is why the two fixes in this deck both attack the number of leaves visited: alpha-beta (visit fewer of them) and bounded lookahead (stop before reaching them). Neither fix targets memory, because memory was never the problem.

Constructed, in the sample paper's format (2023 theory MC block: one true/false item per lecture)

Minimax on a game tree with branching factor b and maximum depth m needs O(bm) memory, because the whole tree has to be generated before any value can be backed up.

False. Deck p.18 prints Time: O(bm) and Space: O(bm). The walk is depth first, so it holds one root-to-leaf path plus the siblings at each level on it: for chess 35 × 100 = 3500 nodes. A subtree's value is backed up the moment that subtree is finished, so the tree is never held whole.

How the item is built: a true clause (the cost is exponential) welded to a false one (that the cost is memory). Read the halves of a true/false sentence separately; one false clause makes the whole item False.

Marking: +0.5 / −0.25 / 0 for a blank (Lecturer, T9), so never leave it empty.

5. The canonical tree, run 1: pure minimax

Deck p.20 is the object this Part is examined on. Root MAX, three MIN children, nine leaves in three groups: 3, 12, 8 then 2, 4, 6 then 14, 5, 2. Sections 6 and 9 come back to it. Four other trees appear alongside it: Quiz 1 on p.22, Quiz 2 on pp.23 to 24, the three-leaf illustration on p.27, and the tree constructed in section 10 for the open exam question.

Blue triangle root labelled 3 over three red inverted triangles labelled 3, 2, 2, over nine leaves 3 12 8 2 4 6 14 5 2
Part 7, PDF p.20: Canonical minimax tree (3 12 8 / 2 4 6 / 14 5 2).

Task: fill the blank cells of the trace table

Before reading on, fill in the four values: the three MIN nodes left to right, and the root. Then say which action the root plays and how many leaves were evaluated.

Answer

MIN nodes: min(3, 12, 8) = 3, min(2, 4, 6) = 2, min(14, 5, 2) = 2. Root = max(3, 2, 2) = 3, so MAX plays the leftmost action. All 9 leaves were evaluated, because plain minimax has no mechanism for skipping any.

Verified by executing minimax and alpha-beta on this tree in Python; both return 3.

Two observations about this tree, one the lecturer makes and one added by this pack.

Constructed, in the sample paper's format (archetype A12 step 1, exercise-session phrasing)

Exhaustive minimax is run on the tree of deck p.20, leaves 3, 12, 8 then 2, 4, 6 then 14, 5, 2. What value is returned at the root, and how many leaves are evaluated?

C. The MIN nodes are 3, 2 and 2, the root is max(3, 2, 2) = 3, and plain minimax has no mechanism for skipping a leaf, so all 9 are evaluated. Verified by execution.

The three wrong options are the three real mistakes. A reads the biggest number in the picture, which is the decoy this tree is built around: 14 and 12 both sit under a MIN node. B pairs the right value with the alpha-beta leaf count of section 6; the question said exhaustive, and the two runs differ in work, never in value. D takes a min at the root.

In an exercise answer write the value at all four internal nodes and the leaf count, not just the root. The marks are on the working.

6. The canonical tree, run 2: alpha-beta with the bookkeeping written out

Deck p.21 is the same tree with the middle subtree cut short. The definition printed at the top left is the one to memorise: "α = best option so far from any MAX node on this path". Deck p.26 gives the matching pair on two stacked lines above the code: α: MAX's best option on path to root and β: MIN's best option on path to root.

Here is the complete execution, step by step, using the pseudocode of p.26 exactly as printed. The root is called with α = −∞ and β = +∞. In every row, "v" is the running value at the node currently being expanded.

Alpha-beta on the canonical tree of p.20. Verified by executing the p.26 pseudocode in Python: root value 3, 7 leaves evaluated, 2 pruned.
#Node enteredα inβ inEventvTest
1root (MAX)−∞+∞start, v = −∞−∞
2MIN-1−∞+∞start, v = +∞+∞
3leaf 3evaluate33 ≤ −∞? no. β := 3
4leaf 12evaluate33 ≤ −∞? no. β := 3
5leaf 8evaluate3no more children. MIN-1 returns 3
6root (MAX)−∞+∞v := max(−∞, 3)33 ≥ +∞? no. α := 3
7MIN-23+∞start, v = +∞+∞
8leaf 2evaluate22 ≤ α = 3, so return 2 now. Leaves 4 and 6 are never generated.
9root (MAX)3+∞v := max(3, 2)33 ≥ +∞? no. α := 3
10MIN-33+∞start, v = +∞+∞
11leaf 14evaluate1414 ≤ 3? no. β := 14
12leaf 5evaluate55 ≤ 3? no. β := 5
13leaf 2evaluate22 ≤ 3, so return 2. It was the last child, so nothing is saved.
14root (MAX)3+∞v := max(3, 2)3no more children. Root returns 3

Three things in that table are worth naming, because each of them is a place where hand traces go wrong.

The same tree with alpha equals 3 written at the middle and right MIN nodes, a pair of scissors cutting the middle subtree, and the note that the order of generation matters
Part 7, PDF p.21: Alpha-beta on the same tree with annotations.

Task: predict the next step before revealing

The scissors sit under the middle MIN node. The right-hand MIN node keeps all three of its leaves (14, 5, 2). Explain why the algorithm was obliged to look at 14 and 5, given that the value it eventually gets from that subtree is 2, which is no better than what it already had.

Answer

Because the cut condition is checked after each child, and the first child of MIN-3 is 14. At that moment the node's running value is 14, and 14 ≤ α = 3 is false, so the loop continues. Then 5: still false. Only at 2 does the test pass, and by then there is nothing left to skip. Alpha-beta is not clairvoyant; it can only react to values it has already seen. The lecturer makes the same point in T6: those nodes had to be explored further because the branch could still have turned out interesting, and here it did not.

This is also the whole argument for child ordering. Had the 2 come first in that group, its two siblings would have been cut, exactly as in the middle group.

Constructed, in the sample paper's format (2023 theory MC block: one true/false item per lecture)

On deck p.21, the α = 3 written next to the middle MIN node is a bound that this MIN node computed from its own children.

False. It was computed at the root, in row 6 of the trace above: MIN-1 returned 3, the root took max(−∞, 3) and set α := 3. Rows 7 and 10 then carry that 3 down into the middle and right MIN nodes as an inherited parameter. At the moment the middle MIN node receives it, that node has evaluated nothing at all.

The rule behind it: min-value only ever lowers β and max-value only ever raises α (p.26). A MIN node that raises α is the most common bookkeeping error in this archetype, and it is worth marks because the graders read the letters you wrote at each node.

Marking: +0.5 / −0.25 / 0 for a blank (Lecturer, T9).

7. The two quizzes on pp.22 to 24

The deck asks you to do the pruning yourself twice. Both are worth doing before reading the answers, because the second one contains the only cut in this deck that fires at a MAX node.

Small tree: MAX root with arcs a and d to two MIN nodes; left MIN has arcs b and c to leaves 10 and 8; right MIN has arcs e and f to leaves 4 and 50
Part 7, PDF p.22: Alpha-beta quiz 1.

Task: which of the six arcs can be pruned?

Arcs are a (root to left MIN), b and c (to leaves 10 and 8), d (root to right MIN), e and f (to leaves 4 and 50). Exactly one arc is cut. Name it, and say why each of the other five is not.

Answer

Only f. Trace: left MIN evaluates 10 (β := 10), then 8, and returns 8. Root: v = 8, α := 8. Right MIN inherits α = 8, evaluates leaf 4, and 4 ≤ 8, so it returns immediately and f is never followed. Root = max(8, 4) = 8. Three of the four leaves are evaluated.

Why not the others: a and d must be taken because the algorithm knows nothing before descending; b must be taken because the left MIN has no value yet; c must be taken because at that point the left MIN is only "10 or less" and 8 is genuinely lower, so it changes the answer; e must be taken to get any information about the right MIN at all. In T6 the lecturer works exactly this list, and his reason for c is that without expanding it you would never learn that the value is 8, which is what makes the left MIN node worth 8 rather than 10.

Verified by executing the p.26 pseudocode: root 8, 3 leaves evaluated, 1 pruned.

Four-level tree: MAX root, two MIN nodes, four MAX nodes, eight leaves 10 6 100 8 1 2 20 4, arcs labelled a to n
Part 7, PDF p.23: Alpha-beta quiz 2.

Task: which arcs are pruned, and at which kind of node does each cut happen?

Layers are MAX, MIN, MAX, leaves. Arcs: a and h from the root; b and e under the left MIN; i and l under the right MIN; c, d under b; f, g under e; j, k under i; m, n under l. Leaves left to right: 10, 6, 100, 8, 1, 2, 20, 4. Name the pruned arcs and, for each, whether the node where the test fired is a MAX node or a MIN node.

Answer

Two cuts, three leaves saved.

  1. Arc g is cut at a MAX node. Left MIN gets 10 from the b subtree, so β := 10 and the e subtree inherits β = 10. Its first leaf is 100, and 100 ≥ β = 10, so the MAX node at e returns 100 at once and leaf 8 is never seen. This is the β test, the one that lives in max-value.
  2. Arc l is cut at a MIN node. Root now has α = 10. Right MIN inherits α = 10; the i subtree returns 2; and 2 ≤ 10, so right MIN returns 2 and the entire l subtree, leaves 20 and 4, is never generated. This is the α test, the one in min-value.

Root = max(10, 2) = 10. Five of eight leaves evaluated. Verified in Python.

The lecturer introduces the first of those cuts in T6 as the reverse principle of pruning, and points out what changed: there is no longer a MIN node sitting directly above the leaf values, there is a MAX node.

The quiz 2 tree partially revealed with alpha = 10 at the root, beta = 10 at the left MIN, alpha = 10 and alpha = 100 at MAX nodes, beta = 2 at the right MIN, and scissors on two arcs
Part 7, PDF p.24: Alpha-beta quiz 2 answer (alpha=10, beta=10, beta=2).

Task: reconcile two readings of one label

The answer slide writes α = 2 next to the MAX node under arc i. But the pseudocode on p.26 would hold α = 10 at that node, because the root already pushed 10 down. Both statements are true. Explain the difference, and say which of the two numbers is the one that produces the cut on arc l.

Answer

First a caveat about what "the pseudocode's α" even means at a node that returns early. The code tests before it updates: if v ≥ β return v comes before α = max(α, v). So at the MAX node under e, and at the right MIN node, both of which return early, the update line is never reached and those nodes' own α and β are left exactly as they were passed in. Taken literally, the code writes no α = 100 and no β = 2 anywhere. The reading under which the slide's annotations make sense is "the bound this node would hold once the child just returned is folded in", and that is the reading used below.

Under that reading, the letters printed next to a node record that node's own best-so-far among its children: the MAX node under i has seen 1 and 2, so its own best is 2. The pseudocode's α parameter is a different quantity: it is that local best combined with everything inherited, so α = max(10, 2) = 10. At the other annotated nodes on this slide the two readings agree; only this node separates them.

Neither number is the one that cuts arc l. The cut happens one level up, at the right MIN node, and it compares that MIN node's own value (2, the value returned by the i subtree) against the α the MIN node inherited from the root (10). So it is 2 ≤ 10 that does the work. Verified by execution.

8. The general rule, and which cut is called "alpha" and which "beta"

Deck p.25 states the rule in words, from MAX's point of view, and then says the other case is symmetric.

General case (pruning children of MIN node). We're computing the MIN-VALUE at some node n. We're looping over n's children. n's estimate of the childrens' [sic] min is dropping. Who cares about n's value? MAX. Let α be the best value that MAX can get so far at any choice point along the current path from the root. If n becomes worse than α, MAX will avoid it, so we can prune n's other children (it's already bad enough that it won't be played).

Pruning children of MAX node is symmetric. Let β be the best value that MIN can get so far at any choice point along the current path from the root.

The sentence in brackets is the intuition worth carrying into the exam: the pruned subtree is not proved worthless, it is proved unreachable under optimal play. MAX simply will not steer there.

Slide with the general pruning argument in bullets and a schematic path from a MAX root down through a MIN node labelled alpha to a deeper MIN node labelled n
Part 7, PDF p.25: General pruning case at a MIN node.

Task: complete the half-described diagram

In the schematic on the right, α is written at a MIN node high in the tree and n is a MIN node far below it, with the dotted line meaning "any number of levels". Why is α written next to a MIN node when the definition says α belongs to MAX? And why is the vertical distance between the two drawn as arbitrary?

Answer

The α label marks the value of the alternative that MAX already has in hand: it is the value of a child of the MAX node above, and that child happens to be a MIN node. The letter names MAX's best option, and the option is a subtree whose root is a MIN node. That is the same convention as p.21, where "α = 3" is written next to MIN nodes that received the 3 from the root.

The distance is arbitrary because α is defined over "any choice point along the current path from the root", not over the parent. A cut at n can be justified by a MAX node many levels above. This is the single feature that makes alpha-beta a whole-path algorithm rather than a local rule, and it is why the parameters are threaded through every recursive call in the pseudocode.

Deck p.26 gives the code. Reproduced exactly, except that the slide prints the two functions side by side and they are stacked here:

α: MAX's best option on path to root
β: MIN's best option on path to root

def max-value(state, α, β):
    initialize v = -∞
    for each successor of state:
        v = max(v, value(successor, α, β))
        if v ≥ β
            return v
        α = max(α, v)
    return v

def min-value(state, α, β):
    initialize v = +∞
    for each successor of state:
        v = min(v, value(successor, α, β))
        if v ≤ α
            return v
        β = min(β, v)
    return v

Four details in that code decide whether a hand trace is right.

  1. The test comes before the update. In max-value, if v ≥ β is checked, and only if it fails is α raised. A trace that updates first and tests second will still cut in the same places here, but it invites the error of updating the wrong letter.
  2. Each function updates only its own letter. max-value raises α; min-value lowers β. Neither ever touches the other.
  3. The comparisons are not strict. and , so a tie is enough to cut. Section 9 shows this happening on the deck's own illustration.
  4. The returned v may be a bound, not a value. When the loop exits early, v is only known to be at least β (at a MAX node) or at most α (at a MIN node). The root's value is still exact; the pruned children's are not.
Slide with the max-value and min-value pseudocode side by side, and the definitions of alpha and beta at the top
Part 7, PDF p.26: Alpha-beta pseudocode.

Task: name the trap in this setup

A student implements min-value with if v < α instead of if v ≤ α. Does the root value change? Does the number of pruned nodes change? Which of the two matters for the exam?

Answer

The root value never changes: both versions are correct algorithms, because a child whose value merely ties α cannot improve on what MAX already has. The pruning count does change: the strict version keeps expanding on ties and therefore prunes less.

For the exam, use the deck's non-strict version, because the answers you will be compared against were produced with it. The clearest case is p.27, treated in the next section, where a tie of 10 against 10 is enough to cut.

Constructed, in the sample paper's format (2023 theory MC block: one true/false item per lecture)

When min-value returns early because v ≤ α, the number it returns is the minimax value of that node.

False. The returned number is only an upper bound: the node stopped looking, and the children it never saw could have been lower. Smallest counterexample, verified by executing the p.26 pseudocode: a MAX root over MIN[3, 3, 3] and MIN[2, 0]. The left MIN returns 3 and the root sets α := 3; the right MIN evaluates 2, finds 2 ≤ 3 and returns 2, while its true minimax value is min(2, 0) = 0.

What stays exact is the root's value and the root's best action, which is the theorem of p.27 and the reason the discrepancy is harmless. What is not harmless is quoting that 2 as the node's value in an exercise answer. Write it as at most 2, or leave the node blank and mark the cut with its inequality.

Mirror case: at a MAX node returning on v ≥ β, the returned number is a lower bound.

The naming collision you should know about before the exam

The course states the rule twice, and the two statements attach the Greek letters to opposite ends of the same cut. Both are internally consistent; they differ in whether the letter names the inherited bound or the node's own bound.

SourceHow the rule is writtenNode where the loop stopsLetter used to name that cut
Deck pp.25 and 26min-value: if v ≤ α return va MIN nodeα (α is inherited from a MAX ancestor)
Deck pp.25 and 26max-value: if v ≥ β return va MAX nodeβ (β is inherited from a MIN ancestor)
Exercise session 5 solutions, slide 26"Prune: Max node ≥ β"a MIN nodeβ (β is that MIN node's own running bound)
Exercise session 5 solutions, slide 42"Prune: Min node ≤ α"a MAX nodeα (α is that MAX node's own running bound)

I checked both readings against the same tree by running the p.26 pseudocode on the exercise-session tree of section 15: the cut that the solution slide labels "Max node ≥ β" is the same cut the pseudocode makes with v ≤ α inside min-value, and the cut labelled "Min node ≤ α" is the one the pseudocode makes with v ≥ β inside max-value. The algorithm is one algorithm. Only the labels swap.

The practical consequence is in section 10, where the 2023 exam asks you to draw a tree in which "beta pruning" is active. The safe answer draws a tree that exhibits both cuts, labels α and β with the p.26 definitions, and marks each cut with the inequality that produced it. Then the drawing satisfies either reading.

9. The three properties that get examined

Deck p.27 carries the theorem, the ordering claim, and the complexity result on one slide.

The lecturer adds a caution in T6 that is easy to lose: perfect ordering is a thought experiment rather than an achievable state, because ordering children best-first requires knowing their values, which is the thing you were computing. And even the ideal number stays enormous: 3550 is a 78-digit number.

Slide with the no-effect theorem, child ordering, O(b^(m/2)), metareasoning, and a small max-min tree with leaves 10, 10 and 0
Part 7, PDF p.27: Pruning properties and child ordering, O(b^(m/2)).

Task: predict the next step, then check the tie

The little tree on the right is: MAX root, left MIN with the single leaf 10, right MIN with leaves 10 and 0. Run alpha-beta on it. Is the leaf 0 evaluated? What is the root value? What would change if you had used a strict comparison in min-value?

Answer

Left MIN returns 10; root sets α := 10. Right MIN inherits α = 10 and evaluates its first leaf, 10. The test v ≤ α is 10 ≤ 10, which is true, so right MIN returns 10 immediately and the leaf 0 is never evaluated. Root = max(10, 10) = 10.

With a strict test the leaf 0 would be evaluated, the right MIN would return 0, and the root would still be max(10, 0) = 10. Same answer, one more leaf touched. That is the theorem on this slide in miniature: the pruning changed the work, not the value. Verified by execution: 2 of 3 leaves evaluated.

Child ordering, measured on the canonical tree

Rather than assert that ordering matters, here is the measurement. I took the canonical tree of p.20 and enumerated every reordering that preserves its shape: all 6 permutations of the leaves inside each of the three MIN groups, and all 6 permutations of the three MIN subtrees, giving 63 × 6 = 1296 orderings. Each was run through the p.26 pseudocode.

All 1296 shape-preserving reorderings of the canonical tree (leaves 3 12 8 / 2 4 6 / 14 5 2), executed in Python.
Leaves evaluatedLeaves prunedNumber of orderingsExampleRoot value
5448[3,12,8] [2,4,6] [2,14,5]3
6396[3,12,8] [2,4,6] [14,2,5]3
72432[3,12,8] [2,4,6] [14,5,2] ← the deck's order3
81384[3,12,8] [4,2,6] [14,5,2]3
90336[3,12,8] [4,6,2] [14,5,2]3

Read the two columns that matter. The work ranges from 5 leaves to 9 leaves, a factor of nearly two on a nine-leaf tree, and the root value is 3 in all 1296 cases. That is the theorem and the ordering claim of p.27 demonstrated on one object.

The best-first ordering is easy to state. At a MIN node, put the smallest child first; at a MAX node, put the largest child first. Applying it to the canonical tree gives [3, 8, 12] [2, 4, 6] [2, 5, 14]: the first group is expanded in full (its MIN node is the root's first child, so it runs with α = −∞ and the cut test cannot fire), then each of the other two MIN nodes is cut after its first leaf, for 5 leaves evaluated and 4 pruned.

2023 sample theory exam, multiple choice item 1.8, verbatim (FAI_EXAMPLE_Part1_TheoryExam.pdf)

When using alpha-beta pruning, the computational savings are independent of the order in which children are expanded.

False. The table above is the counterexample in one line. Same tree, same algorithm, savings between 0 and 4 leaves depending only on the order. Deck p.21 states it on the slide: "The order of generation matters: more pruning is possible if good moves come first."

Classic mistake: confusing this statement with the theorem on p.27 and marking it True. The theorem says the value is independent of the order; the item says the savings are. One is true and the other is false, and the item is built out of that confusion. If you can say the sentence "order changes the work, never the answer", you have both.

Marking arithmetic: the lecturer states the rule as "you get plus uh a half a point if it is correct, minus a quarter of the point if it is wrong and zero points if uh both of the boxes are empty" (Lecturer, T9). The expected value of answering is 0.75p − 0.25, positive whenever p > 1/3, so on a true/false item even a guess beats a blank. Never leave one empty.

Exam signal: archetype A12, trace plus alpha-beta plus reorder

This is the Part 7 exercise archetype: you are given a tree, and asked to (i) run minimax, (ii) run alpha-beta and mark what is cut, (iii) say whether a reordering would cut more. Exercise session 5 phrases it as "Perform the minimax algorithm on the tree in figure 1, first without and later with αβ-pruning. Can the nodes be ordered in such a way that αβ-pruning can cut off more branches ?"

What earns the marks:

  1. Write α and β at every node you enter, as the pair you received, and update them as the loop runs. Marks are given for the bookkeeping, and a bare set of node values cannot be checked.
  2. Mark the cut with the inequality that caused it, for example "2 ≤ α = 3 at this MIN node", not just with a cross.
  3. Cross out everything below the cut, not only the immediate children. A cut at a node removes its entire remaining subtree.
  4. State the root value and the root's chosen action, and state explicitly that reordering changes the amount of work but not the root value, and not the set of optimal actions. (If two root children tie at the optimal value, reordering can change which of them your trace reports, so say which tie-break you used.)

Classic mistakes: starting the root with α = 0 instead of −∞; letting a MIN node raise α; propagating α and β sideways to a sibling that has already been left (they travel down and are discarded on return, they are not global); quoting a pruned child's returned number as its minimax value; and believing that a node's first child is always explored in full. It is not. The cut test runs only after a child has returned, so a node never prunes its own first child at its own level, but everything inside that first child's subtree is ordinary alpha-beta and can contain cuts. Both trees in this chapter show it: in the constructed tree of section 10 the root's first child M1 contains a beta cut, and in the exercise tree of section 15 the first child of MIN-R, namely MAX4, contains an alpha cut.

The lecturer on what this skill is: "It's also important that you can execute and simulate these algorithms in a pen and paper uh version on a small scale." (Lecturer, T4).

10. Exam signal: the 2023 open question on beta pruning

2023 sample theory exam, open question 3.1, 2 points, verbatim (FAI_EXAMPLE_Part1_TheoryExam.pdf)

"Alpha-Beta pruning is an improvement on MiniMax search for 2-player games. Explain the 'beta' pruning technique by (i) drawing a game tree in which this rule is active, and make it visually clear where it is active; and (ii) explaining the pruning rule with words and/or formulas." The answer space is one full page plus a spare page.

The trap that sinks this question: the tree most students have memorised is the canonical one of p.20, and a beta cut cannot occur in it. In a two-layer tree (MAX root over MIN nodes over leaves) the root's β is +∞ and never changes, so v ≥ β can never hold at the only MAX node present; every cut is at a MIN node via v ≤ α. I checked this by running the p.26 pseudocode over all 1296 reorderings of that tree: not one produced a cut at a MAX node.

Therefore your drawn tree needs at least three plies: MAX root, MIN layer, MAX layer, then leaves. Of the four trees this deck works through (pp.20 to 21, p.22, pp.23 to 24, p.27), the only one in which the β test fires is Quiz 2 on pp.23 to 24. If you want a deck-backed example, that is the one to reproduce.

Model answer: what to draw, what to label, and what earns the 2 marks

Three plies, eight leaves, both cuts visible. This is the tree constructed and verified in the task below, drawn here the way it should appear on the answer sheet, with the bookkeeping written onto it.

                        R (MAX)                  alpha: starts −∞, becomes 8
              /                        \
        M1 (MIN)                        M2 (MIN)     receives alpha = 8
        /      \                        /      \
   X1(MAX)   X2(MAX)              Y1(MAX)   Y2(MAX)  never generated
    /   \     /   \                /   \     /   \
   3     8   9     1              2     6   7     0
                   ^                        ^     ^
   at X2: 9 ≥ beta = 8, BETA CUT, leaf 1 skipped
   at M2: 6 ≤ alpha = 8, alpha cut, Y2 and leaves 7 and 0 skipped

Root value 8; five of the eight leaves evaluated, three skipped. Verified by executing the p.26 pseudocode; the full row-by-row trace is in the task below.

Part (ii) compressed to what must be said: let β be the best (lowest) value MIN can already secure at any choice point on the path from the root. At a MAX node n the running value v is a maximum over the children seen so far, so it can only rise. The moment v ≥ β, the MIN ancestor holding β already has an option at least as good and will never steer into n, so n's remaining children cannot affect the root and are skipped. Formally, at a MAX node: if v ≥ β return v. The mirror rule at a MIN node is: if v ≤ α return v. The full paragraph to copy is in the task below.

What earns the 2 marks: (a) a tree of at least three plies, since the beta test cannot fire in a two-ply tree such as p.20; (b) each cut marked on the drawing with the inequality that caused it, not just a cross; (c) α and β defined as the best value MAX or MIN can already secure on the path to the root, not as a property of the parent; (d) one sentence saying the rule changes how much of the tree is generated and never the value at the root. Drawing both cuts and labelling each with its inequality also makes the answer correct under either of the two namings in section 8.

Task: construct your own tree, then check it

Draw the smallest tree you can in which both cut types fire exactly once: one cut at a MAX node via v ≥ β, one at a MIN node via v ≤ α. Constraints: alternating layers starting with MAX at the root, at most 8 leaves, integer utilities. Then run the p.26 pseudocode on it by hand and write α and β at every node. Only then open the answer, which contains one tree that works and its full trace.

Answer: a tree that works, with the complete trace

Constructed example (not from the course material; built for this chapter and verified by executing the p.26 pseudocode in Python).

Layers: root R is MAX; its children M1 and M2 are MIN; their children X1, X2 and Y1, Y2 are MAX; the leaves are below those.

                        R (MAX)
              /                        \
        M1 (MIN)                        M2 (MIN)
        /      \                        /      \
   X1(MAX)   X2(MAX)              Y1(MAX)   Y2(MAX)
    /   \     /   \                /   \     /   \
   3     8   9     1              2     6   7     0
Verified: root value 8, 5 of 8 leaves evaluated, 3 pruned.
Node enteredα inβ inWhat happens
R (MAX)−∞+∞v = −∞, descend to M1
M1 (MIN)−∞+∞v = +∞, descend to X1
X1 (MAX)−∞+∞leaf 3: v = 3, 3 ≥ +∞? no, α := 3. leaf 8: v = 8, 8 ≥ +∞? no, α := 8. returns 8
M1 (MIN)−∞+∞v = 8, 8 ≤ −∞? no, β := 8, descend to X2
X2 (MAX)−∞8leaf 9: v = 9. 9 ≥ β = 8, so return 9 now. The leaf 1 is never generated. This is the beta cut.
M1 (MIN)−∞8v = min(8, 9) = 8, returns 8
R (MAX)−∞+∞v = 8, 8 ≥ +∞? no, α := 8, descend to M2
M2 (MIN)8+∞v = +∞, descend to Y1
Y1 (MAX)8+∞leaf 2: v = 2, 2 ≥ +∞? no, α := max(8, 2) = 8. leaf 6: v = 6, no cut, α := 8. returns 6
M2 (MIN)8+∞v = 6. 6 ≤ α = 8, so return 6 now. Y2 and both its leaves (7 and 0) are never generated. This is the alpha cut.
R (MAX)8+∞v = max(8, 6) = 8, root value

Sanity check against exhaustive minimax: max( min(max(3,8), max(9,1)), min(max(2,6), max(7,0)) ) = max( min(8, 9), min(6, 7) ) = max(8, 6) = 8. Same value, three fewer leaves.

How to write part (ii) in words. Something close to this earns the marks:

Let β be the best (lowest) value MIN can already secure at any choice point on the current path from the root. While expanding a MAX node n, keep its running value v = max over the children seen so far. Since v can only increase as more children of n are examined, the moment v ≥ β we know MIN, at the ancestor holding β, will never choose the branch leading to n: it already has an option worth at most β. The remaining children of n therefore cannot influence the value backed up to the root, and are skipped. Formally: at a MAX node, if v ≥ β then return v. The mirror rule at a MIN node is: if v ≤ α then return v, where α is the best (highest) value MAX can already secure on the path. Neither rule changes the minimax value at the root; both change how much of the tree is generated.

Draw both cuts on your tree and label each with its inequality. That way the answer is complete under either of the two namings documented in section 8.

11. Resource limits and bounded lookahead

Deck p.29 states the problem and the first solution. "In realistic games, cannot search to leaves!" The fix is bounded lookahead: "Search only to a preset depth limit or horizon" and "Use an evaluation function for non-terminal positions". The slide then says plainly what it costs: "Guarantee of optimal play is gone".

The arithmetic on the same slide is the one worked live in the lecture, and it is entirely printed, so treat it as slide content that the lecturer emphasised rather than as an extra:

The exponent 8/2 is the load-bearing part. It is the perfect-ordering result of p.27 being cashed in: with alpha-beta at its best, searching to depth 8 costs about what depth 4 would cost without it. Drop the pruning and the same budget buys depth 4, since 358 is about 2.25 × 1012, roughly two million times more than the budget.

Slide with the bounded lookahead bullets, the chess timing arithmetic, and a tree whose lower half is hidden behind a cloud with question marks at the bottom
Part 7, PDF p.29: Resource limits with the full chess arithmetic to depth 8.

Task: predict the number, then read off the tree

Two parts. (a) With the same 1M node budget but no alpha-beta, what depth does the arithmetic give for chess? (b) On the tree in the picture, the four numbers just above the cloud are −1, −2, 4, 9 and the two nodes above them are MIN. Fill in the two MIN values and the MAX root, and then say what the cloud represents.

Answer

(a) Without pruning the cost of depth d is 35d. 354 = 1,500,625, already slightly over 1M; 355 is about 5.25 × 107. So the honest answer is depth 4, half of what alpha-beta buys. That is precisely the "Doubles solvable depth!" claim of p.27, restated in seconds instead of in exponents.

(b) Left MIN = min(−1, −2) = −2. Right MIN = min(4, 9) = 4. Root = max(−2, 4) = 4, which is what the slide prints. The cloud is the part of the tree below the horizon: it exists, it would change the true values, and the search simply refuses to look at it. The four numbers are not utilities of terminal states; they are outputs of an evaluation function applied to non-terminal positions.

12. Depth matters, and why it is a trade-off rather than a preference

Deck pp.30 and 31 give four claims, the fourth added on the second slide:

The second and third bullets are the same statement seen from two ends, and together they define a trade-off curve: for a fixed strength of play you can buy depth cheaply and evaluate crudely, or evaluate expensively and search shallowly. What you cannot do is have both cheap. The fourth bullet names the currency: a richer feature set costs time per node, and time per node is nodes not searched.

Pages 32 and 33 are two screen recordings of the same Pacman board at two lookahead depths. Both slides print the same opening frame, so the difference lives in the recording rather than in the printed page; the lecturer narrates both in T6.

Screen recording of the CS188 Pacman window, Pacman in a corridor with an orange ghost above and a blue ghost below
Part 7, PDF p.32: Pacman lookahead depth 2.

Task: predict the behaviour before revealing

Pacman sits in a corridor with an orange ghost above, a blue ghost below, and one food pellet between him and the blue ghost. At depth 2 he can look only two steps into the future. Predict what goes wrong, and name which of the two ingredients (search depth or evaluation function) is responsible for the failure as it appears on this slide.

Answer

He gets trapped. At depth 2 the danger from the second ghost is beyond the horizon, so both moves look equally safe and the tie is broken by whatever the evaluation function rewards, typically getting closer to food. The lecturer describes it in T6: Pacman cannot escape the ghosts because he can reason only two steps into the future.

On this slide the responsible ingredient is the depth: a deeper search on the same board, p.33, solves it. Keep that answer separate from the deeper lesson in the box below, which is about a different situation where depth is not the fix.

The same recording titled depth-10 lookahead, printed at the same opening frame: Pacman in the corridor, orange ghost above, blue ghost below, one pellet
Part 7, PDF p.33: Pacman lookahead depth 10.

Task: state the property that appears only at depth 10

In the recording, the depth-10 Pacman first moves towards the orange ghost, and only then goes for the pellet. Why is moving towards a ghost the optimal first move here, and what does that tell you about reading a single move off a deep search?

Answer

Because at depth 10 the search sees far enough to know that the immediate threat is the blue ghost, and that stepping towards the orange one is safe for now while it changes what the blue ghost does later. The lecturer's account in T6 is that with a depth of 10 the best choice is to move closer to the orange ghost first, since there is no immediate danger from it; the blue ghost then makes a different decision, and Pacman can finally reach the last white pellet.

The general lesson: a move produced by a deep search is part of a contingent plan (deck p.8) and can look locally wrong. Judging an agent by whether its next move looks sensible is not a valid test. This is the same object the course calls a policy in Part 9.

Exercise session, T8, on when depth is not the fix

the real solution is not so much increasing the depth... but rather finding an evaluation function that really does account for everything that is genuinely important. (Exercise session, T8), about a depth-limited Pacman that freezes in place. That exercise belongs to Part 8, but the idea starts on these slides. The failure mode there is not blindness beyond the horizon; it is an evaluation function that scores standing still as well as it scores progress, so no amount of extra depth breaks the tie. Deck p.30's "deeper search => better play" carries the word "(usually)" for exactly this reason.

13. Evaluation functions

Deck p.35 is the definition slide, and it is short enough to know completely:

Two structural points about the linear form. First, a feature is a difference between the two sides, not an absolute count, so that the function is antisymmetric: swapping the colours negates EVAL, which is what a zero-sum game requires. Second, the weights encode the relative worth of the features, and the example weight of 9 for a queen is the familiar chess piece value. The two chess positions printed on the slide are captioned Black to move, White slightly better on the left, and White to move, Black winning on the right, which is the slide's way of saying that whose turn it is can outweigh material.

Quiescence is the one word from this slide most likely to appear in a fill-in question. A quiescent position is one where no major change in the feature values is expected next, so it is safe to stop and evaluate. Stopping in the middle of a queen exchange would score the position as a queen down when it is actually level one move later. The lecturer treats it as a side note for chess in T6, but it is a printed bullet on the slide, so it is examinable content.

Slide with two chess positions either side of a small game tree, the weighted linear sum formula for EVAL, and the quiescence bullet
Part 7, PDF p.35: Evaluation function as weighted features (incl. quiescence bullet).

Task: name the trap in this setup

You are told a chess evaluation function is EVAL(s) = 9(Qw − Qb) + 5(Rw − Rb) + 3(Bw − Bb) + 1(Pw − Pb). Does the play change if you multiply the whole function by 10? If you add a constant +7? What is the general property you have just used, and how much of it survives into Part 8?

Answer

Neither change alters a single move. Minimax uses only max and min, which depend on the order of the children's values and on nothing else. So any strictly increasing relabelling of the utilities, not just scaling and shifting, leaves every choice and therefore the whole policy unchanged.

How much survives Part 8: only the affine part. A chance node takes a weighted average, and averaging commutes with a · x + b when a > 0, so multiplying by 10 and adding 7 are still harmless. The wider claim is not. Constructed counterexample: MAX chooses between a chance node worth 0 or 10 with probability 1/2 each (value 5) and a sure 4, so it prefers the chance node. Relabel utilities with the strictly increasing map 0 → 0, 4 → 100, 10 → 101. The chance node is now worth 0.5(0) + 0.5(101) = 50.5, the sure option is worth 100, and MAX switches. The ordering of the outcomes never changed; only their spacing did. That is one concrete way in which expectimax is not just "minimax with probabilities".

Deck p.36, titled "Evaluation for Pacman", prints one board. The lecturer works it as a comparison in T6: a position with more pellets already eaten but the same level of danger should score better, and the position where Pacman is boxed in between ghosts and walls should score much worse. That last case is the one that shows why "distance to the nearest food" alone is a bad evaluation function: it is blind to being trapped.

14. Generalized minimax: more than two players, or no zero sum

Deck p.37 answers the question "What if the game is not zero-sum, or has multiple players?" with four bullets:

The third bullet is the whole algorithm. There is no minimising player any more, and there is no negation anywhere: a layer belonging to player i selects the child whose i-th component is largest, and copies that child's entire tuple upwards.

Generalized minimax tree: red ghost at the root, blue ghost at the second layer, Pacman at the third, leaves are triples such as 1,1,6 and 8,8,1, root value 8,8,1
Part 7, PDF p.37: Generalized minimax with utility tuples (8,8,1).

Task: fill the blank cells of the trace table

Layers top to bottom: red ghost (component 1), blue ghost (component 2), Pacman (component 3), leaves. Leaves left to right: (1,1,6), (0,0,7), (9,9,0), (8,8,1), (9,9,0), (7,7,2), (0,0,8), (0,0,7). Back the tuples up and state the root. Then answer the harder half: the leaf (9,9,0) is the best available outcome for both ghosts, and it appears twice. Why does neither ghost get it?

Answer

Pacman's layer (maximise component 3): max((1,1,6),(0,0,7)) = (0,0,7); max((9,9,0),(8,8,1)) = (8,8,1); max((9,9,0),(7,7,2)) = (7,7,2); max((0,0,8),(0,0,7)) = (0,0,8).

Blue ghost's layer (component 2): max((0,0,7),(8,8,1)) = (8,8,1); max((7,7,2),(0,0,8)) = (7,7,2).

Red ghost's root (component 1): max((8,8,1),(7,7,2)) = (8,8,1), which is what the slide prints.

Why nobody gets (9,9,0): both copies of it sit under a Pacman node, and Pacman scores 0 there against 1 and 2 in the alternatives, so he never selects it. The ghosts never get the chance to prefer it. This is the "cooperation and competition dynamically" bullet made concrete: the two ghosts have identical interests here and are effectively cooperating, and the outcome is still decided by the player whose turn falls in between.

Verified by executing the tuple backup in Python.

Lecturer, T6, answering a student question about the name

you indeed lose this concept of a min player. It is called generalized miniax because it refers back to the original algorithm... by convention it's called uh in that way. (Lecturer, T6). Worth keeping because it removes a real confusion: there is no MIN node in a generalized minimax tree, and looking for one is a way to get the trace wrong. The name is historical. Two-player zero-sum minimax is the special case in which player 2's component is the negation of player 1's, so "maximise your own component" reduces to "minimise the other's".

Exercise session 5, section 2, verbatim (FAI_EXERCISES_Game_Trees.pdf); exercise archetype A13

"Try to come up with a reformulation of the minimax algorithm that works when three players are involved. Apply your algorithm on the figure below, where each node shows the score for each of the three players."

Model answer: the reformulation, and the exercise tree backed up

The solutions state the reformulation in four printed lines: "All players are Max", "Evaluation function given by vector", "Each layer assigned to 1 player", "Turn: every 3 layers". The spoken version in the exercise session adds that the turn order runs clockwise around the players.

Applied to the exercise figure, whose leaves are (1,2,3), (4,2,1), (6,1,2), (7,4,−1), (5,−1,−1), (−1,5,2), (7,7,−1), (5,4,5) from left to right: player 3's layer returns (1,2,3), (6,1,2), (−1,5,2), (5,4,5); player 2's layer returns (1,2,3) and (−1,5,2); player 1 takes (1,2,3) at the root, because 1 > −1 on the first component. Verified by executing the tuple backup in Python. The full working, and the printing slip on the final solution slide, are in the task below.

What earns the marks: the four reformulation lines or equivalent wording; the layer-to-player assignment stated before you start; the whole tuple copied upward at every node, not just the winning component; and a tie rule named and applied.

Classic mistakes: (i) negating something, on the reflex that minimax involves a min (there is no negation and no min); (ii) maximising the sum of the tuple, or its own player's component at the wrong layer, which is what happens if you index the layers from the leaves instead of from the root; (iii) backing up only the winning number instead of the whole tuple, which destroys the information the layers above need; (iv) leaving a tie unresolved.

On ties: "maximise your own component" says nothing about what to do when two children tie on that component. Deck p.37 and the exercise-session solution slides print no tie rule (I checked both), so state your own rule and apply it consistently, for example "ties broken by the leftmost child". The same exercise bundle does exactly that where it matters, printing "Tie-breaking: choose the left branch" in section 4 of the assignment.

Task: run the three-player exercise tree yourself

The tree is a complete binary tree of depth 3. Root is player 1's move, the next layer player 2, the next player 3, then the leaves. Leaves left to right: (1,2,3), (4,2,1), (6,1,2), (7,4,−1), (5,−1,−1), (−1,5,2), (7,7,−1), (5,4,5). Back up all seven internal nodes and state the root tuple.

Answer

Player 3's layer (maximise component 3): max((1,2,3),(4,2,1)) = (1,2,3) since 3 > 1; max((6,1,2),(7,4,−1)) = (6,1,2) since 2 > −1; max((5,−1,−1),(−1,5,2)) = (−1,5,2) since 2 > −1; max((7,7,−1),(5,4,5)) = (5,4,5) since 5 > −1.

Player 2's layer (component 2): max((1,2,3),(6,1,2)) = (1,2,3) since 2 > 1; max((−1,5,2),(5,4,5)) = (−1,5,2) since 5 > 4.

Player 1's root (component 1): max((1,2,3),(−1,5,2)) = (1,2,3) since 1 > −1.

Note how badly player 1 does out of this: he takes 1 when a leaf worth 7 to him exists in the tree twice. Both are blocked by players 2 and 3 acting on their own components. Verified in Python against the solution slides.

One printing slip to be aware of: the final solution slide writes the comparison as MaxFirstPlayer([1,2,3],[-1,5,4]) = [1,2,3], while the tuple actually carried up from the layer below, and drawn on the same slide, is [-1,5,2]. The winner is unaffected, because the decision uses the first components (1 against −1). Trust the drawn tree.

15. The full exercise-session drill: 27 leaves, twice

Exercise session 5 section 1 gives a four-layer tree with 27 leaves and asks for minimax, then alpha-beta, then a reordering. It is the largest game tree in the course material and the closest thing to an exam-sized object. Structure, layers top to bottom MAX, MIN, MAX, MIN, leaves:

root MAX
 |-- MIN-L
 |    |-- MAX1 : MIN[4,3,5]  MIN[2,1]
 |    |-- MAX2 : MIN[4,2,3]
 |    '-- MAX3 : MIN[5,4]  MIN[7]  MIN[3,2]
 '-- MIN-R
      |-- MAX4 : MIN[1,4,0]
      |-- MAX5 : MIN[5,3]  MIN[0]
      '-- MAX6 : MIN[2,7,4]  MIN[3,6]  MIN[5,3,1]

Task: full drill, do this one on paper before opening

(a) Run plain minimax and write the value of all 21 internal nodes. (b) Run alpha-beta with α and β at every node, mark each cut with its inequality, and count the leaves you never evaluated. (c) Reorder best-first and count again. Then check against the numbers below, which come from executing the p.26 pseudocode.

Answer, with the counts

(a) Minimax. The twelve MIN nodes just above the leaves: 3, 1, 2, 4, 7, 2, 0, 3, 0, 2, 3, 1. The six MAX nodes: 3, 2, 7, 0, 3, 3. The two MIN nodes: 2 and 0. Root = max(2, 0) = 2.

(b) Alpha-beta in the given order: 10 leaves evaluated, 17 pruned. The solution deck's own caption is "17 static evaluations saved". The four cuts, in the order they fire:

  1. At the MIN node [2,1] under MAX1: v = 2 and 2 ≤ α = 3, so the leaf 1 is skipped. 1 leaf.
  2. At MAX3: its first MIN child returns 4, and 4 ≥ β = 2 (β came from MIN-L, which had already collected 3 and 2), so its two remaining MIN children are skipped. 3 leaves (7, 3, 2).
  3. At the MIN node [1,4,0] under MAX4: v = 1 and 1 ≤ α = 2, so leaves 4 and 0 are skipped. 2 leaves.
  4. At MIN-R: MAX4 returned 1, and 1 ≤ α = 2, so MAX5 and MAX6 are skipped whole. 11 leaves.

1 + 3 + 2 + 11 = 17. The 10 leaves actually evaluated are 4, 3, 5, then 2, then 4, 2, 3, then 5, 4, then 1.

(c) Best-first reordering: 8 leaves evaluated, 19 pruned ("19 static evaluations saved" in the solutions). The rule is the same as in section 9: MIN nodes take their smallest child first, MAX nodes their largest. That gives

root MAX
 |-- MIN-L : MAX[2,3,4] , MAX([3,4,5],[1,2]) , MAX([7],[4,5],[2,3])
 '-- MIN-R : MAX[0,1,4] , MAX([3,5],[0])     , MAX([3,6],[2,4,7],[1,3,5])

and the four cuts become: MAX with children [3,4,5],[1,2] stops at 3 ≥ β = 2 (2 leaves); MAX with children [7],[4,5],[2,3] stops at 7 ≥ β = 2 (4 leaves); the MIN node [0,1,4] stops at 0 ≤ α = 2 (2 leaves); MIN-R stops at 0 ≤ α = 2 (11 leaves). 2 + 4 + 2 + 11 = 19.

Root value: 2 in both runs. That is the theorem of p.27 again, now on 27 leaves.

Exercise session 5, section 1, verbatim (FAI_EXERCISES_Game_Trees.pdf); exercise archetype A12

"Perform the minimax algorithm on the tree in figure 1, first without and later with αβ-pruning. Can the nodes be ordered in such a way that αβ-pruning can cut off more branches ?" The spacing before the question mark is the assignment's own; figure 1 is the 27-leaf tree above.

Model answer: the three parts, as the solution deck marks them

Without pruning: root value 2, all 27 leaves evaluated. The twelve MIN nodes above the leaves are 3, 1, 2, 4, 7, 2, 0, 3, 0, 2, 3, 1; the six MAX nodes are 3, 2, 7, 0, 3, 3; the two MIN nodes are 2 and 0.

With pruning, in the drawn order: 10 leaves evaluated and 17 skipped, which is the solution deck's own "17 static evaluations saved". Four cuts produce it: 2 ≤ α = 3 at the MIN node [2,1]; 4 ≥ β = 2 at MAX3; 1 ≤ α = 2 at the MIN node [1,4,0]; and 1 ≤ α = 2 at MIN-R, which removes MAX5 and MAX6 whole.

Yes, and here is how much: ordering smallest child first at MIN nodes and largest first at MAX nodes gives 8 leaves evaluated and 19 skipped, the solutions' "19 static evaluations saved". The root value is 2 in both runs, which is the half of the answer students leave out.

What earns the marks: α and β written at every node as the pair that node received; each cut marked with the inequality that caused it; the whole subtree below a cut crossed out; the leaf count stated; and one sentence saying that reordering changes the work and not the root value. Every number here was produced by executing the p.26 pseudocode, and the step-by-step working is in the task above.

Exercise session, T8, on non-standard game trees

in the past these kind of things sometimes were exam questions and if it was like the first time that you saw this kind of description, people were just confused. (Exercise session, T8). Said about unfamiliar tree descriptions in the game-tree exercises. The defence is to have seen the variants once: a tree whose branching factor differs from node to node (the tree above has MAX nodes with one, two and three children), a tree drawn with values inside nodes rather than beside them, tuples instead of scalars, and layers labelled by player rather than by MAX and MIN. None of these change the algorithm. Read the layer labels first, then the values, then start at the leftmost leaf.

Task: name the trap in the exercise tree

MAX2 has exactly one child and MAX4 has exactly one child. A student says: "a node with one child can be deleted, since max of one value is that value." Is the claim true of the minimax values? Is it true of the alpha-beta trace?

Answer

The claim is true, and it is true of the trace as well. Under the p.26 pseudocode a single-child MAX node is an exact pass-through. It receives (α, β), passes the same (α, β) straight down to its only child, and returns that child's value unchanged: with one child the loop body runs once, so whether the cut test fires or the loop simply ends, the returned value is the child's value and no bound was ever narrowed. Contracting it changes nothing computationally.

Verified by execution: running the exercise tree with MAX2 and MAX4 contracted gives the same root value 2, the same 10 leaves evaluated, the same evaluation order, and the same four cuts (only the path labels shift). Across 4000 randomly generated trees, contracting every single-child node changed the root value or the leaf count in 0 of them. One caveat on how you check this yourself: a node's MAX or MIN role comes from Player(s), a property of the state, not from its depth. If your code alternates by level instead, contraction will flip the roles below the contracted node and you will see spurious differences.

So why trace what is drawn? Not for correctness, but for marks. This archetype is graded on the α and β you write at each drawn node, and an answer that silently deletes nodes the question drew leaves the grader with nothing to check at those positions. Simplify in your head if it helps; write out the drawn structure.

Exam signal: how Part 7 has actually been examined

16. Summary slide, and where the pieces come from

Deck p.38 collects the Part into four claims, and each one is a compressed argument you should be able to unpack.

17. Term box

TermPrecise definitionPlain paraphraseExam phrasing
Standard game Deterministic, observable, two-player, turn-taking, zero-sum (p.9), formulated as s0, Player(s), Actions(s), Result(s,a), Terminal-Test(s), Utility(s,p). Chess-shaped: no dice, nothing hidden, two sides, alternating moves, one wins what the other loses. "Standard games are deterministic, observable, two-player, turn-taking, zero-sum" (p.9)
Zero-sum / general Zero-sum: agents have opposite utilities, pure competition, one maximises and the other minimises. General: independent utilities, allowing cooperation, indifference and shifting alliances (p.10). One pie versus separate pies. "out of scope for uh for the course" (Lecturer, T6, on general games)
Strategy / policy A contingent plan that recommends a move for every possible eventuality, as opposed to a single path (p.8). Not "these moves" but "what to do in every case". "a contingent plan (a.k.a. strategy or policy) which recomments a move for every possible eventuality" (p.8)
Utility Utility(s, p) is the numeric outcome of terminal state s for player p; written Utility(s) when p is the root mover (p.9). The score at the end of the game, from your side. "Terminal values: Utility(s,p) for player p. Or just Utility(s) for player making the decision at root" (p.9)
Minimax value V(s), MAX and MIN nodes V(s) = utility if terminal; max over successors at a MAX node (the mover is the agent being designed, drawn as an upward triangle); min over successors at a MIN node (the mover is the opponent, downward triangle) (pp.15, 20). What the position is worth if both sides play their best, computed as "my turn take the max, their turn take the min". "MAX nodes: under Agent's control ... MIN nodes: under Opponent's control" (p.15); "Max", "Min" as layer labels on the exercise-session trees
α (alpha) MAX's best option on the path to the root: the highest value MAX can already secure at any choice point on the current path (pp.21, 25, 26). The floor you have already locked in. "α = best option so far from any MAX node on this path" (p.21)
β (beta) MIN's best option on the path to the root: the lowest value MIN can already secure at any choice point on the current path (pp.25, 26). The ceiling the opponent has already locked in. "β: MIN's best option on path to root" (p.26)
Alpha cut Inside min-value: when the running v satisfies v ≤ α, return v and skip the node's remaining children (p.26). The cut is at a MIN node; the exercise session writes the same cut from the parent's side. This MIN branch is already no better than what MAX has, so stop reading it. "Prune: Max node ≥ β" (exercise session 5 solutions, slide 26, cutting a MIN node)
Beta cut Inside max-value: when the running v satisfies v ≥ β, return v and skip the node's remaining children (p.26). The cut is at a MAX node and needs at least three plies to occur; the exercise session writes the same cut from the parent's side. This MAX branch is already too good for MIN to allow, so stop reading it. "Explain the 'beta' pruning technique by (i) drawing a game tree in which this rule is active" (2023 sample theory 3.1); "Prune: Min node ≤ α" (exercise session 5 solutions, slide 42, cutting a MAX node)
Pruning theorem Alpha-beta returns the same value at the root as exhaustive minimax, for every child ordering (p.27). You skip work, not answers. "Theorem: This pruning has no effect on minimax value computed for the root!" (p.27)
Child ordering, perfect ordering The order in which successors are generated. Under perfect ordering (best move first everywhere) time falls from O(bm) to O(bm/2), doubling the reachable depth; iterative deepening is the practical approximation (p.27). Look at the good moves first and you can ignore more of the rest. "the computational savings are independent of the order in which children are expanded" (2023 sample theory MC 1.8, False)
Bounded lookahead, horizon Searching only to a preset depth limit and applying an evaluation function to the non-terminal positions there; the optimality guarantee is lost (p.29). Stop early and guess the score. "Search only to a preset depth limit or horizon"; "Guarantee of optimal play is gone" (p.29)
Evaluation function EVAL(s) = w1f1(s) + ... + wnfn(s), a weighted linear sum of features scoring non-terminal positions; may be replaced by a nonlinear function such as a neural network trained by self-play (p.35). A heuristic for positions instead of for distances. "Evaluation functions score non-terminals in depth-limited search"; "w1 = 9, f1(s) = (num white queens − num black queens)" (p.35)
Quiescent position A position in which no major change in the feature values is expected next, and therefore a safe place to stop a depth-limited search (p.35). Nothing is about to explode, so the score is trustworthy. "Terminate search only in quiescent positions, i.e., no major changes expected in feature values" (p.35)
Generalized minimax Terminals and internal nodes carry utility tuples; the layer belonging to player i selects the child with the largest i-th component and copies its whole tuple up. No MIN node, no negation (p.37). Everyone maximises, each in their own column. "All players are Max"; "Each layer assigned to 1 player"; "Turn: every 3 layers" (exercise session 5 solutions)

Constructed, in the sample paper's format (2023 theory fill-in block: 2.1 and 2.2 are one-line definitions)

Deck p.26 prints two one-line definitions above the pseudocode. Which one is the definition of β?

A, verbatim from p.26. B is α, the other printed line. C is a different variable: v is local to one node and is compared against β, so a trace that merges them cuts in the wrong places. D is wrong in kind: β is a bound carried down the path from a MIN ancestor, and it says nothing about what lies below the node, which may well contain values far under it.

Why the phrase on path to root is the marked part: it is what makes α and β whole-path quantities rather than properties of a parent, which is the point section 8 makes with the arbitrary vertical distance on p.25. Open question 3.1 asks you to explain the rule, and this line is half the explanation.

One caution: the exercise-session solutions attach the letters to the opposite end of the same cut (section 8's table). If the exam wording follows that convention, name the inequality you used and you are safe under either reading.

Chapter index: index.html  ·  Previous: Part 6, Constraint Satisfaction Problems  ·  Next: Part 8, Game Trees with Uncertainty  ·  Drill: viz-games.html  ·  Search by question: question-index.html