Static Evaluation, Alpha-Beta Pruning, and Monte Carlo Tree Search
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Static evaluation functions - introduced in Lecture 7, where minimax trees were first solved with static evaluation values
- Adversarial search and game playing - zero-sum games and game trees from Lecture 7
- The minimax algorithm - depth-first in-order value propagation and the "not the worst" guarantee from Lecture 7
- Pruning - the general pruning idea for search spaces first met in Lecture 4
This module completes the game-playing story. First, we find out where all those numbers in the minimax game trees actually come from — the static evaluation function and the static evaluation value. Then we look at alpha-beta pruning, which is the same minimax algorithm with a small smart addition that skips parts of the tree without changing the answer. Then we meet Monte Carlo Tree Search, a probabilistic search algorithm that uses simulations to guide which parts of the game tree to grow. The session ends with a complete walkthrough of the mid-semester exam: format, syllabus, marking, and study advice.
The path of this session is easy to keep track of if you hold on to one thread: every tree diagram from the last session was full of numbers, and every one of those numbers was a static evaluation value computed from a board by a static evaluation function. Once you know how those numbers are produced (Section 8.1), you can ask the question that drives Section 8.2: does the search really need to look at every one of them? Alpha-beta pruning answers "no". Section 8.3 then asks an even bigger question: what if we do not want to evaluate every board at all, because each evaluation is too slow — and Monte Carlo Tree Search answers that with simulation and statistics. The last section switches from the algorithms to the exam itself, so the same material doubles as your revision checklist for the mid-semester paper.
8.1 Static Evaluation Functions and Values
8.1.1 Recap: Adversarial Search and Minimax
Hook. Every minimax tree you solved in the last session was full of numbers — a 3 here, a −7 there, a 6 at the root. Where do those numbers actually come from? Nobody told you, and the session never asked. That question is exactly where this section starts: those numbers are static evaluation values, and once you can compute them yourself, the whole game tree becomes something you can build from a real board, not a gift from the slides.
The last session finished the neuroevolution line (NEAT, Deep NEAT, and CoDeepNEAT) and then opened up game playing, or adversarial search. In the problems we solved before, the problem-solving agent was alone in the environment. In games, there are usually two or more players, and the situation gets interesting: in adversarial search one person's gain is another person's loss. These are zero-sum games — the total payoff to both players adds to zero, so a win for me is exactly a loss for you. The key point we made: each agent does not just ask "which action gets me closer to my goal"; it also asks "what will my opponent do to reduce my chance of success, and how do I respond to that?" That second question is what adversarial search is really about.
The most important algorithm from that session is minimax. Minimax never promised to take you to the best reward or the best utility. Its guarantee is narrower and more defensive: it will never take you to the worst possible outcome. If you attend every class, I do not promise you will top the course — but I do promise you will not fail the course. That is exactly minimax's mindset: it will not necessarily find the best path, but it guarantees you will not end up in the worst state. Keep this promise straight, because a later question in this session turns on it: minimax is a "not the worst" guarantee, not a "definitely the best" one.
We propagated values through the trees using a traversal. Which traversal was it? Depth-first search, which in this tree setting is the in-order traversal: go all the way down to the left end, then start filling values up, and complete the whole tree that way. We solved several examples this way and stopped at one open question: why do we not search the whole tree? For small games like tic-tac-toe, a complete search is still possible. For large games like chess, the game tree is enormous — the branching factor is about 35 and games can run roughly 80 ply deep, which means far more positions than any machine could ever visit. We simply cannot afford to predict "if I do this move, the opponent will do this move, and so on" to full depth. Instead we use a depth limit (only a few depths) plus a static evaluation function, and that is where we had stopped.
One clarification about the numbers in all those tree diagrams: the values written at the nodes are not the final utility. Final utility just says who is winning the game — in zero-sum games it is one of a few outcomes, for example win/lose/draw as or a similar scheme. The intermediate values are static evaluation values, and in the entire last session we took those values for granted and never asked where they come from. This session answers exactly that question.
8.1.2 What the Static Evaluation Function Is
A static evaluation function estimates the utility of a non-terminal game state. That small sentence carries a lot of weight, so unpack it. A terminal state is the goal state — the game is over. For tic-tac-toe, the goal states are: X has won, O has won, or the whole board is filled and nobody has won. For all the intermediate, non-terminal states — "I have just started playing, there are many moves possible for me" — we want an estimate of the utility. The static evaluation function provides that estimate.
Static evaluation value (SEV). The number that estimates how good a board is for one player, computed as the score of the max player's material minus the score of the min player's material, without any look-ahead:
Here is the utility (score) assigned to a single piece by the piece-value table, means "add up the values over every piece the max player still has on the board", and means the same for the min player. A positive value favors the max player; a negative value favors the min player. The word static means the board is scored exactly as it sits right now, with zero searching ahead.
Why "static"? Because it evaluates the board position as it is, without searching further. It does not look ahead; it looks at the current configuration and scores it. That score answers the question "among the options available to me, which one is most promising?" A promising move is one that leads to a better utility for me — or, equivalently, one that will not lead my opponent to a better utility. The static evaluation value is more like a reward or a heuristic: how good is this particular board for me, right now.
The utility is the final thing you get when the game ends: if you won, if you lost, if the game was a draw. In zero-sum games like chess and tic-tac-toe, exactly these three results are possible — you win, you lose, or it is a draw. Utility is what you get at the end; the static evaluation value is what you compute at every intermediate stage.
Q: Can I say that static evaluation is only used when the game cannot finish — to evaluate who is in a better position? A: Not really, and not only for a win. In every situation we want to evaluate the position. There are a bunch of options available to me; which one is most promising is what static evaluation does. "Static" does not mean "when the game is stuck" — it means the board is evaluated as it is, without searching further. Every non-terminal board you ever score is being scored with a static evaluation value.
| Static evaluation value | Utility | |
|---|---|---|
| When is it computed? | At every intermediate (non-terminal) board | Only when the game ends |
| What does it say? | An estimate: how good is this board for me right now | The final result: who actually won |
| How is it produced? | From a feature table (e.g., piece values) by an equation | From the rules of the game |
| Example (win/lose/draw) | Any number, e.g., −7 or 3 | One of , , |
8.1.3 Properties of a Good Evaluation Function
A good evaluation function should satisfy four things:
- Give higher values to better states for the max player.
- Give lower values to better states for the min player.
- Be fast to compute.
- Correlate reasonably well with the actual chance of winning.
The first two properties make the score usable by minimax: whichever player is at a node, the number ranks the state from that player's perspective. The third property matters because the whole reason we use static evaluation is that searching deep is too expensive — an evaluation that takes a minute per board would defeat its own purpose. The fourth property is what makes the score meaningful — a score that disagrees with the real chance of winning would mislead the search.
Scope — when the four properties hold and when they break. Properties 1 and 2 assume the evaluation is written from a fixed player's perspective (say, max = white). If you silently swap the perspective halfway, a "high score" becomes a "bad score" and minimax picks the wrong moves — this is why the max-player role must be stated out loud. Property 3 assumes the evaluation is a cheap function of a few features; a weighted combination of piece counts is exactly that. Property 4 is the fragile one: evaluation is only an estimate. A board where white is ahead by a knight and two pawns (roughly ) is usually a white win, but a single tactical move can flip the game — for example white's next move captures the queen for free. The evaluation cannot see that if the queen capture lies beyond the depth limit. A position with such a pending, evaluation-swinging move is called non-quiescent, and strong engines keep searching in those positions (a quiescence search) rather than trusting the static score. For this course: treat the static value as a reliable ranking of similar boards, not a prophecy about the final result.
The fourth property also has a textbook meaning worth knowing. For terminal states, a good evaluation must agree exactly with utility: . For non-terminal states, the evaluation must sit somewhere between a loss and a win. One clean way to think about a good evaluation: imagine it returns the expected value of the game from this state — if 82% of similar positions lead to a win , 2% to a loss , and 16% to a draw , a good evaluation for the category is . In practice we cannot estimate such probabilities for every category of board, so we add up feature contributions instead — which is exactly the material-counting function of the next section.
8.1.4 Worked Examples: Chess Material Counting
The simplest evaluation function for chess counts material. First we need a table of piece values. These values are empirical: some experts, or an algorithm that has played chess many times, settled on them. The values used in the example:
| Piece | Points |
|---|---|
| Queen | 9 |
| Horse (knight) | 3 |
| Bishop | 3 |
| Soldier (pawn) | 1 |
| Any piece off the board | 0 (you have already lost it) |
Professor's power intuition. If you still have your queen, you still have your most powerful piece, so it scores the most. Horse and bishop are equally powerful, so both score 3. A soldier can only move one or two squares, so it scores 1. This "power" reading makes the table easy to remember — the standard material values used by chess programs are the same numbers, with a rook worth 5: pawn 1, knight/bishop 3, rook 5, queen 9. On the exam, the piece symbols and their values will be provided to you, or the evaluation function will be described.
The static evaluation value is computed as:
In words: the static evaluation value is nothing but the summation of the utility of the max player minus the summation of the utility of the min player. If I am the white player, I take white as max and black as min, I total up the white pieces using the table, total up the black pieces, and subtract. Positive scores are good for max; negative scores are good for min.
Worked example 1 — board where white is behind. White has a horse and a bishop: . Black has a horse (3), a soldier (1), and a queen (9): , plus 3, gives 13. So:
The board is drawn from the white player's point of view, and −7 is exactly the value shown for that configuration. Sense-check: black is more dominant — more pieces, and a queen while white has none — so the negative score for white makes sense.
Worked example 2 — board where white leads. White has a horse (3), a bishop (3), and a soldier (1): , plus 1, gives 7. Black has a bishop (3) and a soldier (1): . So:
Sense-check: white has three pieces against black's two and the values add to 7 against 4, so white is modestly ahead — +3 for white is consistent with the material difference of one horse's worth.
Worked example 3 — the same arithmetic on another board. White has a horse (3), a soldier (1), and a bishop (3): , plus 3, gives 7. Black has only a soldier (1) and a horse (3): . So:
Sense-check: white's total is 7 against black's 4 again — same gap, same score of +3. Different arrangement, same material difference, same value; that is the point of a feature-based evaluation.
The narrative while filling these boards: first add up the white coins — "this horse will give me three, this bishop will give me three, this soldier will give me one" — then add up the black coins, then subtract. Once the table is known, computing the static evaluation value for any board is quick: total the max side, total the min side, subtract.
Roles must be fixed before you subtract. Which side is max and which is min is not baked into the table; it is a role you assign. Either it is fixed for you, or you assume it and say so: "I am the max player, and I am white." That choice decides what you subtract from what, and so the sign of every value in the whole tree. If you swap the roles, every +3 becomes −3 and minimax will happily walk into the worst positions. The professor's advice: state the assumed role explicitly, because it determines the sign of the entire computation.
Why is this significant? Suppose I am the white player and I have four possible board configurations to choose from (there are many more — the "dot dot dot"). The static evaluation value tells me which configuration is more promising. Minimax will never take me to the worst one — for example a configuration at −9, where black still has a queen, a horse, and a soldier while I have lost my queen. It will steer me away from the −7 configurations too. So the values we saw in every earlier tree diagram are computed exactly this way: someone defined a utility function, evaluated each board, and produced those numbers.
There is also a weighted variant. Instead of just subtracting, you can assign weights to the two sides and multiply:
The weights and are parameters; per configuration you can assign some weights, multiply, and the final value is that board's score. The professor's example phrasing: "maybe here it's five, here it's three" — the weight on one side is 5, the other 3, and you multiply before combining.
Standard form (from the reference text). Texts write the weighted form as a weighted linear function of features:
where each is a feature of the position (number of white bishops, number of black queens, and so on) and each is the weight saying how important that feature is. The professor's two-term form is the same idea specialized to two sides: weighs "my material" and weighs "your material". The unweighted material count is the special case , with a minus instead of a plus between the terms. Either way, the empirical part is only the per-piece table; computing the board's value from the table is just evaluation, not empirical guessing.
Pitfalls (this concept is examinable):
- Treating the static value as the final utility. The value in a tree node is an estimate for a non-terminal board, not the game's final result. Final utility only says who wins.
- Forgetting to fix the max-player role. The sign of every value depends on which side you declare max. Say "I am the max player and I am X/white" before computing.
- Hunting for an "iteration" over the board. There is no iteration: for each configuration you compute the total of max minus the total of min, once, and that is the value. (This confusion came up in class — see the questions below.)
- Thinking static evaluation is only for games that cannot finish. It is used at every decision point to rank the options; "static" means no look-ahead, not "stuck game".
Recap. The static evaluation value is the score of a board computed from a predefined piece table: total the max player's pieces, subtract the total of the min player's pieces. It ranks your options at every non-terminal state, it is cheap to compute, and it is what fills the numbers into minimax trees. Next we look at the same ideas from a different angle — tic-tac-toe, where you cannot count coins — and then at how these values behave in a two-player race on a single board.
Real-world: this exact material count is the base evaluation of essentially every chess engine — Stockfish and similar engines use piece values of the same shape as the table above (often tuned to slightly different numbers, like 3.05 for a knight) and then layer positional features on top. Material counting is also how chess engines "know" that trading a bishop for a pawn is bad unless there is a tactical reason — the static score drops by two points, and only the search can justify it.
8.1.5 Worked Example: Tic-Tac-Toe Winning Configurations
Chess counting is straightforward because you can count coins. In tic-tac-toe you cannot, so a different static evaluation works. The example board has six cells already filled: an O, an O, an X, an X, an O, and an X, with three empty cells left. (The exact layout of the filled cells is not needed for the method — what matters is what the counting produces, exactly as in class.)
Worked example — evaluating a tic-tac-toe board by counting win configurations.
Step 1 — count X's chances. Copy the board, fill all three empty cells with X, and count how many winning configurations X can complete. With X's in all the empty spots, X has two win possibilities — one full row and one diagonal. That is 2 for max.
Step 2 — count O's chances. Copy the same board again, fill all empty cells with O, and count. O gets only one winning configuration — a single row. That is 1 for min.
Step 3 — combine. The board value is:
Sense-check: X's value 1 is positive, so X is in the better position. And that agrees with the play: X has placed its marks cleverly — even if O plays next, X can still place an X and have a win possibility. If O plays cleverly, it becomes a draw — but O cannot force a win, and X never loses from here.
Q: Why do we fill all the empty slots with X or O to calculate the static evaluation value? Is that not a valid game play? A: It is a valid way — otherwise what other option do you have in order to compute it? The static evaluation value asks: at that position, who is at a better place, X or O? So we put all X's and see how many win possibilities we get, then all O's and see. The filled board is a counting device, not a claim about how the game will actually be played. Even without doing anything, just look at the board: X has positioned itself cleverly — even if O plays here, X can play there and still have a win possibility. If O plays cleverly it is a draw. So X is at an advantage.
Why fill the empty cells with X or O instead of counting X's and O's directly? Because the number of X's versus O's is not a good metric in tic-tac-toe. In chess you can eliminate pieces and throw them off the board; in tic-tac-toe you cannot — every cell gives both players equal opportunity, and the nine grids get filled turn by turn. So we count win possibilities instead.
A second way to reason about the same board: go through each winning line that is still open (rows, columns, diagonals that do not already contain both symbols) and check who already occupies it. The first row is gone — nobody can win there. The second row is gone too. The third row is still open, and it already has an X — X has even more chances. The principal diagonal is gone (it has both O and X already). The other diagonal is still open, and it also has an X. In every open win possibility you see X's and no O's — so X is at an advantage, and you can award points accordingly. That is the same conclusion, , reached by a different route.
Pitfalls on the tic-tac-toe evaluation:
- Counting coins in tic-tac-toe. The number of X's and O's on the board is a bad metric: there are only two kinds of marks, nothing gets eliminated, and both players fill cells turn by turn — the counts are always nearly equal, so they cannot rank positions.
- Skipping the "copy the board" step. The X-count and the O-count must be computed on the same starting configuration; if you let X's placement leak into O's count, the numbers become meaningless.
- Calling the filled board a played game. Filling empty cells is a computational trick, not an actual sequence of legal moves — the professor corrected exactly this misunderstanding in class.
8.1.6 A Two-Player Tile Game
A different flavor: the tile game (the sliding-tile puzzle, like the 8-puzzle) played with two players. In single-player search we used heuristics like the number of tiles out of place for this game. Now take the same tile game with two players: one board, and both players race to the same goal configuration — whoever first achieves the goal pattern wins, and the other player loses. I might move the 8 tile here, my opponent moves another tile there to block or catch up, and so on.
Q: Will there be two boards in this two-player tile game? A: No, there will be only one board. Each player plays on that same board — one tries to make the goal configuration first, the other tries to make the same goal. If one wins, the other has lost. The final move that achieves the goal pattern wins.
There is only one board; all players play on that same board. The static evaluation value again tells us how good or bad the current board is for each player — in this case, the same score assigned to the current board shows how good or bad it is for the player. Think of a Sudoku handed to two people where you are competing, not cooperating: I put a number, my opponent blocks that number, and so on. Who is reaching the goal faster — or who is positioned to — is the question the evaluation function scores.
8.1.7 Student Questions and Answers
Q: Are those values in the table predefined? A: Yes, they are predefined. But for each configuration, we will be calculating the static evaluation value from them. The queen, soldier, and bishop values are empirical; the board's final value is computed, not empirical. The empirical part is only the table; applying the table to a board is just arithmetic.
Q: Will we get the icons with names too for the values? A: Yes — if it is a chess game the piece symbols will be given, or it will be told there. In the exam, the values and the formula will be given; you will not have to invent them.
Q: Can you please explain the second iteration in the chess problem? A: There is no iteration here. You have a bunch of board configurations and you are asked for the static evaluation value of each board. What was given to you is, for each coin, its points: bishop 3, soldier 1, queen 9, and so on. For each configuration, compute the total of the max player (white, in my assumption) minus the total of the min player (black). For the first board, white had a horse and a soldier, ; black had several, ; so gave −7. For another board, on one side. That is how we went about computing it — for each configuration you compute that value once; there is no iteration.
Q: How do we decide who is the max player — X or O? A: That should be given to you, or you can assume: "I am the max player, and I am X." You can also assume you are the min player and take O, or the other way around. Either it is given, or you start with the line "I am the max player and I am assuming the role of X." That decides what you subtract from what — a very good question, because it determines the sign of the whole computation.
Q: In the chessboard we computed whites and blacks on the same board, but in tic-tac-toe we fill with X because there is no other way — correct? A: Correct, because in tic-tac-toe you cannot count coins. There are only two possible coins, and the number of X's and O's is not a good metric — in chess you can eliminate and throw a coin out of the board, but here you cannot; all cells get equal opportunity, and the nine grids get filled by taking turns.
Q: Can you explain the eval of s equation? A: That is just some weightages — don't worry about it. Some people put weights to it, more like parameters: assign some weights, multiply them with the utility, and the final value is that board's score. In the chess example we just subtracted white minus black; with weights, maybe one side gets weight 5 and the other 3, and you multiply before combining. So the eval function can also be a weighted function.
Q: If all the leaf nodes have the same static evaluation value, can we pick any one? A: Yes, you can pick any one. But that is not the point — in any game it is very rare that all leaves have the same value, because the game itself is designed so that one player is at an advantage at every stage. It is rare that both boards have the same number of white and black coins of the same type.
Q: In the exam, do we need to show the steps of the in-order traversal? A: Yes, of course — show the traversal steps when you solve a minimax or alpha-beta tree on paper.
8.1.8 Exam Notes
Exam note: in a minimax problem the static evaluation values are either given directly in the tree, or an explanation of the evaluation function (the formula) is given so that you can substitute and compute the values yourself. You must be ready to compute the value for each configuration — chess-style material counting or tic-tac-toe-style win configurations. State your max-player assumption explicitly: "I am the max player, I am X." The exam version of these games is straightforward: you are given the static values, or the equation to compute them.
Exam note: the practice exercises given with the materials — the minimax practice tree and the evaluation exercises — are exactly the exam style, and most students have likely not tried them yet. Please do them: they are the closest thing to the paper you will see before the paper.
8.2 Alpha-Beta Pruning
8.2.1 The Motivation: Minimax Inspects Everything
Hook. Minimax finds the right move, but at a price: it insists on looking at every leaf of the tree. A chess tree has about 35 branches at every level — a full minimax search would need positions for a whole game, which is more than the number of atoms in the universe. The question of this section: can we get the same answer while looking at fewer leaves?
Before alpha-beta, recall exactly what minimax does. Take a tree with three min nodes under a max root:
| Node | Leaves | Min picks |
|---|---|---|
| First min node | 3, 12, 8 | 3 |
| Second min node | 2, 4, 6 | 2 |
| Third min node | 14, 5, 2 | 2 |
| Max root | values 3, 2, 2 | 3 |
The first min node looks at leaves 3, 12, and 8 and picks 3 — the minimum. The second looks at 2, 4, and 6 and picks 2. The third looks at 14, 5, and 2 and picks 2. The max root then picks the maximum among 3, 2, and 2, which is 3.
The straightforward question: to fill in the intermediate nodes and the root, did we touch every static evaluation value? Yes. We went to every leaf, picked the min among each group, then the max at the top. If the tree is big, that is computationally intensive — we inspected all the leaf nodes. Worse, the cost grows exponentially: with branching factor (moves per state) and depth (plies searched), minimax visits leaves — every extra ply multiplies the work by . So the question naturally becomes: can we do better?
8.2.2 What Alpha-Beta Pruning Is
Alpha-beta pruning is the same minimax algorithm, only with a small addition that is smarter. It is an improved minimax using a heuristic: it stops evaluating a move when it makes sure that the move is worse than a previously examined move. Such moves need not be evaluated further — you prune them. Pruning is a simple computer-science concept: you do not want to go down that branch at all, you do not want to evaluate it, you just ignore it.
Alpha-beta pruning. The same minimax algorithm with one addition: whenever the search proves that a branch can never improve the best value already found, the whole subtree below it is cut off without being evaluated. The answer it returns is identical to minimax — the pruning only skips work, never changes the decision.
When added to a plain minimax algorithm, alpha-beta gives the same output but cuts off certain branches that cannot possibly affect the final decision, dramatically improving performance. Give a tree to minimax, or give the same tree to alpha-beta: the final answer is identical. The difference is in the details — minimax does no pruning and checks every evaluation value; alpha-beta does some smart thinking and eliminates certain branches. The algorithm was discovered independently by a few researchers in the mid-1900s.
Where does the improvement come from? In the best case, with good move ordering, alpha-beta inspects only leaves instead of — it can solve a tree about twice as deep in the same time. In the worst case, when nothing can be pruned, it inspects exactly as many leaves as minimax. So applying alpha-beta is never worse than minimax — the professor's rule: "applying alpha-beta is always at least as good."
8.2.3 Alpha, Beta, and the Two Pruning Formulas
Two variables carry the pruning knowledge.
Alpha . The best already-explored option for the max player — the highest value max is guaranteed to reach along the path explored so far. It is initialized to negative infinity () at the start, because before anything is explored max has no guarantee at all.
Beta . The best already-explored option for the min player — the lowest value min is guaranteed to reach along the path explored so far. It is initialized to positive infinity (), because before anything is explored min has no guarantee at all.
The association is fixed: max nodes are associated with alpha, min nodes are associated with beta. This cannot change — max is always alpha and min is always beta. What can change is the order of layers: the root may be max or min; it will be given to you, or you infer it from the node shapes.
Speaking of shapes: the convention in the textbook and in many question papers is that a square means a max node and a circle means a min node. If the node types are not written, you should interpret the diagram using that convention. These subtle conventions in the slides and materials deserve attention — the instructor repeatedly stressed them.
The general principle of alpha-beta pruning: at a node , if the player has a better option at the parent of , or further up the path, then there is no meaning in exploring 's children — that node will never be chosen, so you prune the entire subtree rooted at . The two formulas tell you exactly when that condition holds:
- After an alpha update (a max node's alpha value changes): check whether
If true, prune — the current max node can only deliver , which the parent min node (wanting less than ) will never pick.
- After a beta update (a min node's beta value changes): check whether
If true, prune — the current min node can only deliver , which the parent max node (wanting more than ) will never pick.
Whenever you update an alpha, go check the first property; if it holds, you can prune. Whenever you update a beta, check the second; if it holds, you can prune. If the property does not hold, you cannot prune and you must keep exploring.
Assumption — why nothing prunes at the start. Initially all alphas are and all betas are , so no comparison can fire: is false and is false. That is why the leftmost branch of the tree always has to be explored fully — there is nothing to compare against yet, so the first value simply gets put into its parent. Only after real numbers exist can a prune happen.
If the root is a min node instead of a max node, the formulas still work as long as you keep the intuition straight — the direction of the inequality (or the parent/current roles) flips. The instructor's advice was to prefer the intuition over the formulas: the parent–child contradiction is the same no matter which player is at the root.
8.2.4 Worked Example 1: Pruning the 10
The tree: root is a max node with two min children, and . Each of those has two max children. Leaves under the first max child of : 6 and 5. Leaves under the second max child of : 8 and 10. Under 's first max child: 2 and one more value. Under 's second max child: unknown values.
Step 1 — Initialize. Write alpha next to every max node and beta next to every min node. Set all alphas to and all betas to .
Step 2 — First leaf. In-order traversal: first max child, leaf 6. The max node's alpha goes from to 6. This is an alpha update, so check: is the parent's beta () current alpha (6)? No. No pruning.
Step 3 — Second leaf under the same max node. Leaf 5. The node already has alpha 6; 5 is not greater than 6, so nothing changes. The left child of is complete with value 6, so propagate: 's beta becomes 6. This is a beta update: check (6) of ()? No. No pruning yet.
Step 4 — The prune. Move to 's second max child, leaf 8. Alpha updates from to 8. Alpha update check: is the parent's beta (6) current alpha (8)? Yes — 6 8 is true. Prune: the second leaf of this max node, value 10, is never inspected. The reasoning: this max node can only deliver a value at least 8; the min parent already holds a value of 6 and wants something less than 6; even if the max node succeeds, its result will never be picked. So 10 is cut off.
Step 5 — Back up. This max child is 8, and . The whole left side of is complete, so 's alpha becomes 6.
Step 6 — The second prune. Move to , then to its first max child, leaf 2. Alpha becomes 2. Check: parent's beta () 2? No. The sibling leaf is inspected but is not greater than 2 (say its value is 1 — the exact value does not matter, because any value leaves the max child at 2), so that max child stays 2. Now the left child of is complete, so propagate: 's beta becomes 2. Beta update check: (2) of (6)? Yes — 2 6. Prune: the whole second max child of is cut off without inspecting any of its leaves.
Result. , . Minimax would have returned exactly 6 as well, but alpha-beta never looked at the 10 and never looked at any leaf of 's second subtree.
A discussion moment during the walkthrough: what if the pruned leaf were 4 instead of 10? Irrelevant. The max node already has alpha 8 and delivers at least 8; the min parent wants less than 6. Whether the leaf is 4, 1, or 100, that branch is never picked — the contradiction is already established, so the value does not matter. If it had been 4, the max node would not have adopted it anyway (4 is not greater than 8), and exploring it would have been wasted computation.
Pitfall — pruning is not gambling. Pruning never risks the answer. The only reason a branch is cut is that no matter what value the hidden leaves hold, the branch cannot be chosen: the max node below a min parent can only deliver values that the min parent would reject. If that "no matter what" argument is not yet available, you must keep exploring — the moment you prune without it, you break the algorithm. This is also why the leftmost child can never be pruned: at the start there is no parent value to argue with.
8.2.5 Worked Example 2: The Classic Deck Tree
The second example is the one traditionally used in the course deck: root max node with three min children. The first min child has leaves 3 and 4. The second min child has leaves 2 and 1. The third min child, , has two max children: the first has leaves 7 and 8 (and then more unlisted children), and the second, , has two min children — one with leaves 2 and 11, one with leaf 1 (and then more unlisted children). The stated leaves are 3, 4, 2, 1, 7, 8, 11, 2, and 1, with the remaining children hidden behind "dot dot dot". This walkthrough follows the narrated sequence exactly.
Step 1 — Initialize. Same as before: all alphas , all betas , max nodes get alpha, min nodes get beta.
Step 2 — Leftmost branch. In-order: first leaf 3. The first min node's beta updates from to 3 — a beta update. Check: (3) ()? No. The second leaf is 4: the min node wants something 3, and 4 does not qualify, so nothing changes. The first min child of the root is complete with value 3, and the root's alpha becomes 3 — an alpha update; the parent beta above the root is treated as , so no prune.
Step 3 — The second min child. Its first leaf is 2, so its beta updates from to 2. Beta update check: (2) of the root (3)? Yes — 2 3. The moment this beta is updated to 2, the walkthrough pauses and retrospects: this min node wants something less than 2, while the root already guarantees a path to 3 and wants something greater than 3. Contradiction — the sibling leaf (1) is pruned without being adopted into the value, and this min child is worth 2. (Minimax would have inspected the 1 and still returned 2 — alpha-beta simply skips the pointless inspection.)
Step 4 — Seed the bound for the right side. The left side of the root is complete with value 3. The root's alpha value, 3, is now the bound that governs the right side: it is carried down as the starting beta of the next min node — "this alpha's value, which is now beta, becomes three." In plain words, is explored knowing that the root already has a path worth 3, so anything delivers that is not better than 3 will never be picked.
Step 5 — The third min child, left branch. Go to the left child, left child: leaf 7. This max node's alpha becomes 7. Come to the next leaf: 8 is not greater than 7, so it remains 7. This left part is complete, so propagate: 's beta becomes . Pause and retrospect: this max node is looking for something greater than 7, while its min parent already wants something less than 3. Even if the max node succeeds, it can only deliver at least 7, and the min parent prefers its guaranteed 3 — this path will never be picked. So the max node's remaining children are pruned: why explore further when the branch is already known to be dead?
Step 6 — The third min child, right branch. Its second max child goes left to a min node with leaf 2: the min node's beta updates from to 2. The next leaf is 11: 11 is not a minimum less than 2, so the value stays 2, and the min node is worth 2. Propagate up: 's alpha becomes 2 — this was an alpha update; check the parent beta against it: is not true, so nothing can be pruned yet. 's other min child receives leaf 1: its beta becomes 1. Pause and retrospect: is looking for something greater than 2, while this child wants something less than 1. Even if the child succeeds, its value will not be picked — prune the child's remaining branches. The child is worth 1, and .
Step 7 — The final prune. The value 2 propagates up to : beta update, 's beta becomes . Now check: (2) (3)? Yes — 2 3. At the root we are looking for something greater than 3, and at this node level we are looking for something less than 2 — contradiction. Even if 's remaining children were successful, the path would not be picked. Prune the whole remaining right side of the root.
Result. The root takes — the same answer minimax would give, but with several whole branches never inspected: the 1 under the second min child, the unlisted children of the first max child of , the unlisted children of the second min child of , and the entire remaining right side of the root.
Standard form (from the reference text). The standard formulation does not seed the child's beta from the parent's alpha; instead the parent's bound is carried down the recursion and the cut fires when a node's value reaches the bound carried from above. The professor's two formulas are the same condition written as a parent–child comparison: "after an alpha update, prune when " and "after a beta update, prune when ." On this tree both formulations inspect the same leaves, produce the same prunes, and return the same root decision, 3.
Practice tip from the session: redo this tree from the left side on your own — the two formulas are your backup, but the intuition is the real tool.
8.2.6 The Heart of the Algorithm: The Parent–Child Contradiction
The formulas are fine, but this is the heart of alpha-beta pruning. A min node is trying to find something less than its beta value. A max node is trying to find something greater than its alpha value. When a parent and its child want opposite things, the child's whole search becomes pointless:
- The parent min node already holds a path to value and will only pick something less than .
- The child max node already holds alpha and is searching for something greater than .
- Even if the child succeeds — even if it finds 100, or 8, or anything — that result will never be picked by the parent, because the parent is looking for something less than and the child can only deliver at least .
That contradiction is the prune signal. Say it again slowly with example 1: the min node has beta 6 and wants something less than 6. Below it, a max node has alpha 8 and wants something greater than 8. These two goals contradict each other. Do not bother searching — whatever the max node digs up will be thrown away by the min node above it. The same pattern repeats in the other direction: a max parent holding alpha 3, and below it a min node holding beta 2 — the min node wants less than 2, the max parent wants more than 3; if the min node succeeds, the max parent still prefers its guaranteed 3. Prune.
The very first time you update a value, you cannot prune, because you have no parent values to compare against — the parent's beta is still or the parent's alpha is still . The leftmost child of the tree can never be pruned, because that is where the traversal starts. After that, every update is followed by a pause and a retrospect: what is this node looking for, what is its parent looking for, do they contradict?
Pitfalls (the professor called out most of these):
- Pruning the left child. The leftmost branch of the tree can never be pruned — the traversal starts there, and the initial bounds give nothing to compare against.
- Pruning a node before its own bound exists. You cannot prune the whole of a node's subtree until that node's own alpha or beta has been established from its explored left part — only then can parts below it be cut.
- Using the formulas blindly. If the root is a min node, the formula's inequality direction (or the parent/current roles) flips. The professor's advice: prefer the parent–child contradiction intuition; the formulas are only a backup.
- Thinking pruning can change the answer. Alpha-beta returns exactly what minimax returns; pruning only skips branches that provably cannot matter. If no pruning occurs, the complexity is the same as minimax — which is why applying alpha-beta is always at least as good.
8.2.7 Student Questions and Answers
Q: What if, instead of three, we had two in that first min node — would we definitely reach the lowest static evaluation value? A: Minimax should be very clear from the last session: it will never take you to the worst possible thing. It might get you to the best, or it might not — but it will never get you to the lowest. If the first min node had 2, 12, and 8, then each min node gives 2, and the max node picks among 2, 2, 2 — all of them are the same now, which is the rare case. Then you pick any branch; usually we follow the depth-first in-order preference and take the first one, but technically you can pick anyone.
Q: Why can't we prune the left child? A: Because that is where the traversal starts. The first value is taken and put into the parent; initially all alphas and betas are infinity, so there is nothing to compare against. Only the right children can get pruned.
Q: What if we had four instead of 10 in example 1? A: It does not matter whether it is 10, 100, 4, or 1. At that stage the min node has beta 6 — it is looking for something less than 6 — and the max node already has alpha 8, so it is looking for something greater than 8. There is a contradiction; whatever value sits there will not be picked. If it had been 4, the max node would not have adopted it anyway, since 4 is not greater than 8 — inspecting it would have been wasted time and computation.
Q: Why did we not prune the whole C node in example 1? A: Because we could not jump to that conclusion — the beta value of that node had to be established first. We cannot prune a node before its own bound is known. Only once the left subtree is explored and the beta value exists can some parts below it be pruned.
Q: Should the formulas change if the root node is a minimum? A: The formulas will work as long as your intuition is clear, but the symbols vary: the less-than-or-equal-to direction (or the parent/current roles) must flip. The instructor's own advice: do not go with the formula mechanically — prefer the intuition, where the parent–child contradiction is the same no matter which player is at the root.
Q: How is beta replaced on the right side — and when do we go to the parent? A: Once the whole left child is explored, the value propagates to the parent — that is when a beta (or alpha) gets replaced. Otherwise you never go up: after an alpha update you check the alpha formula, after a beta update you check the beta formula, and only if the property is true do you prune.
Q: Can we convert this game tree to a BST to perform pruning? A: No. These are all game trees — from this board configuration I can do either this move or that move. If you convert to a BST you can end up with boards that are not even legal moves from the current board — you may create illegal operations. The tree structure encodes legality, so it cannot be transformed.
Q: In the exam, how do we show the pruning part? A: You can just cross out the pruned branches. If a tree comes in the exam, cross the branches that get pruned and show the traversal.
Q: How do we know when to use alpha-beta? What if no pruning occurs at all? A: In those cases you cannot do anything — but if it were me, I would use alpha-beta anyway. Even if no pruning happens, the complexity becomes the same as minimax. If pruning does happen, you get better. So applying alpha-beta is always at least as good.
Q: Why did we not compare with the root-level alpha while evaluating beta on the left? A: We did compare — but at that time the values were positive infinity on one side, so nothing could be pruned. The comparison happens at every update; pruning only fires when the numbers are concrete.
Q: Is the traversal left-heavy, with pruning on the right? A: That's correct. The traversal for alpha-beta is usually left-heavy, and pruning happens heavily on the right side.
Q: In the last step, if the right node value is less than the left node at a min beta node, will we choose the right node value to traverse above? A: No — we never just traverse above. We always go by those two formulas: whenever I update a beta, I check the beta update formula; whenever I update an alpha, I check the alpha update formula. You go to the parent only when the left subtree has been exhausted, to update the value. Otherwise you stay with this logic: beta current less than or equal to alpha parent — if true, prune.
8.2.8 Exam Notes
Exam note: expect to apply alpha-beta on a given tree. Show the in-order traversal, initialize alphas to and betas to , and cross out the pruned branches. If no pruning occurs, the complexity is the same as minimax — so applying alpha-beta never hurts. Practice the two deck trees until the contradiction intuition is automatic; the two formulas are the backup.
Exam note: marks are awarded per step — a mistake at a node means the evaluation (and the marks) stop at that point, exactly like pruning stops an unpromising branch. A single wrong number costs exactly that step's mark, so write every alpha and beta update explicitly.
Real-world: alpha-beta pruning is the reason chess engines can search 30–40 ply deep in the few seconds of a blitz game. With move ordering (try captures and checks first), the best case is nearly reached in practice — the same tree that would take minimax a million positions takes alpha-beta a few thousand. The technique generalizes far beyond games: any two-sided optimization where one side maximizes and the other minimizes (negotiation systems, adversarial planning, minimax control) can use the same cut.
8.3 Monte Carlo Tree Search
8.3.1 What Monte Carlo Tree Search Is
Hook. Chess and Go have tree sizes that would take centuries to explore, and alpha-beta still needs a static evaluation function to guess board values. What if a game has no good static evaluation at all — for example Go, where material value is nearly meaningless? Monte Carlo Tree Search answers with a different idea: do not evaluate positions; play games and count who wins.
Monte Carlo Tree Search (MCTS) is a heuristic search algorithm for decision processes, most notably employed for games. Unlike minimax and alpha-beta — which contain no probability at all — MCTS is probabilistic. It is a heuristic search that relies on intelligent search, and it combines classic tree search alongside machine-learning principles like reinforcement learning.
The motivating picture is a game like Go. From the current board state I can make several moves; from each resulting state, more moves; and finally I reach outcomes. The leaves of the full tree are terminal states — utilities: black wins, black loses, and so on. A full expansion of that tree is exactly what we cannot afford. MCTS's answer: do not draw the whole search tree first and then search it. Instead, run simulations, and use the results of those simulations to guide the growth of the game tree. That is the key idea in one line: the tree grows where the simulations say it is promising, not everywhere.
8.3.2 Why Naive Simulation-Based Evaluation Is Too Expensive
A naive approach would be to use simulations directly as an evaluation function for alpha-beta: for a given board, generate all possible moves and all the children they lead to, simulate the game from each, and then apply alpha-beta over that tree. Why is that a bad idea? Three reasons. First, a single simulation is very noisy — one random play-through is a poor estimate of a position's value. Second, running many simulations for one evaluation is very slow. Third, doing this for every node of the tree is computationally very expensive.
The numbers make it concrete. Typical chess programs evaluate about a million positions per second. Go can generate about a million moves per second, with something like 400 moves per simulation. When your "evaluation" is a full simulation, you end up being able to do only about 25 evaluations per second — the practical budget the session quoted.
Where the numbers come from. A single playout in Go needs about 400 moves, and each move needs the board updated and checked — that is 400 units of work per playout, against the roughly 1,000,000 raw move generations the machine can do per second. At the raw ceiling that is about simulated games per second, and the practical figure of ~25 evaluations per second reflects everything else a real playout costs on top of move generation (state updates, legality checks, bookkeeping for both players) and the fact that one reliable "evaluation" of a position needs many repeated plays, not one. Compared with chess's 1,000,000 cheap static evaluations per second, simulation-based evaluation is four to five orders of magnitude slower — that is the whole point of the example.
That is why Monte Carlo was ignored for over 10 years — nobody cared about it while it seemed this costly. Monte Carlo methods are used across computing in many places, and you have met them in the deep reinforcement learning course, but in game search it took this simulation-guided form to become practical.
8.3.3 Exploitation versus Exploration
MCTS is driven by two opposing goals. Exploitation means focusing on promising moves — the ones the simulations so far suggest are good. Exploration means focusing on moves where the uncertainty about the evaluation is high — moves that have not really shown their quality yet, but might surprise you. These two are the heart of the algorithm: you do both. You capitalize on your strengths most of the time, but once in a while you step outside your comfort zone.
Professor's analogy — the job versus the PhD. At work you exploit — you have strong zones, you take the role you are good at, and you do well. But once in a while you explore — you go outside your comfort zone, and maybe that works out even better. The example used: you get interested in Monte Carlo, you do a PhD in it, and you become a scientist — which is way better than being in an office. Exploitation gives you a good job; exploration might give you a better life. MCTS works exactly this way: it focuses on the promising moves, but once in a while it picks a non-promising move on purpose, to find out whether something better is hiding there. Where the analogy breaks: in life, exploration costs years; in MCTS, one iteration costs milliseconds, so the algorithm can afford to explore far more aggressively than a person would.
Mechanically, selection picks each node with probability proportional to a quantity called the upper confidence bound (UCB). You have already learned UCB in your deep reinforcement learning or reinforcement learning course, so the session did not go deep into the formula — the intuition is what matters here.
8.3.4 Perfect Information and Combinatorial Games
Where does MCTS apply? It is used in combinatorial games — sequential games with perfect information. The perfect information requirement is important: both agents know the complete configuration at every step, so games like chess, tic-tac-toe, and Go qualify. These approaches cannot be used in games with imperfect information — football, for example, where one person is doing something while another player cannot fully see it.
The preconditions for a combinatorial game: it must be a two-player game (sometimes multiplayer); it must be sequential, with players taking turns; and it must have a finite set of well-defined moves. Examples are chess, Go, tic-tac-toe, checkers, and so on. Finite moves matter: I cannot do something random, and everything is fully known — the whole configuration is visible to both agents.
Scope — when MCTS does not apply. If players hide information (cards held privately, fog of war, a football pitch where you cannot see the other side), the tree no longer represents what a player knows, and simulation counts lose their meaning. If the game is not sequential or the move set is not well defined, there is nothing to simulate. And if a single move can change the whole course of the game, MCTS is risky: its random simulated games might never stumble onto that move, so the search can miss a vital line that a static evaluation would have flagged.
8.3.5 The Four Phases: Selection, Expansion, Simulation, Back Propagation
MCTS searches only a few layers deep — a key property — and prioritizes which parts of the tree to explore. It simulates the outcome rather than exhaustively expanding the search tree. In doing so it limits how many evaluations it has to make. The individual evaluation relies on a playout, or simulation, in which the algorithm effectively plays the game from the given starting point all the way to a leaf state by making completely random decisions. When it completes a simulation, it selects the state that has the best rollout.
Purpose. MCTS answers one question: among the moves available now, which one deserves the most attention? It does this by growing a game tree one iteration at a time, guided by the statistics of past simulations, until a time budget runs out — then it returns the move with the strongest record.
Inputs and outputs. Inputs: the current game state (the root of the tree), the rules of the game (used by the simulator), a time budget or iteration count, and a selection policy such as UCB1. Outputs: a move — specifically, the move whose node has the most simulations behind it. Each node in the tree carries state values and counts: a visit count and a win count, written as the win/play ratio — "2 by 3" means won twice out of three plays.
The algorithm works in four phases, repeated until a set time has elapsed (you set a time budget; until the time lapses you keep iterating, hunting for promising paths instead of exploring the whole tree). The four steps:
1. Selection. Start from the root and choose the most promising child node repeatedly, using a balance between exploitation and exploration. The selection uses UCB1, which you already know: each node is picked with probability proportional to its upper confidence bound. The result of selection is a leaf to work on.
2. Expansion. At the selected node — specifically a node where not all possible moves have been explored — add a new child node for one unexplored legal move, and try to build out from there, with the hope that this move will turn out better. Example from tic-tac-toe: the selected board state still has three legal moves — X can be placed in the top right, the middle left, or the bottom center, all still empty. MCTS chooses one unexplored move; in the example it picks the top right, puts the X there — which gives birth to a new board configuration — and adds this as a new state, initialized to 0 wins out of 0 plays. Then it explores that state further.
3. Simulation (rollout). From the newly expanded node, the algorithm plays the game until the end — only that one state, not all the possible children. The moves during the simulation may be completely random, or they may use some simple rules, or a lightweight heuristic.
Assumption — the playout is deliberately not clever. Crucially, you do not apply minimax, alpha-beta, or MCTS again during the simulation — if you did, there would be no point to the method. The purpose is not to play perfectly. The purpose is to estimate whether the new move may lead to a win, a loss, or a draw. You are exploring to find a better path, and a random play-out is enough to generate that signal. This is also why the naive "simulate everything" idea is expensive while MCTS is not: MCTS runs one playout per iteration and only from the newly expanded node, not from every node of the tree.
4. Back propagation. Once the simulation ends, the result is sent back through all the nodes visited in that iteration — only that path, not everywhere. Each node on the path is updated: the visit count, the win score, the average win rate, and so on. In symbols, if is the number of times node has been visited and is its win count, the back-propagation step is
Notation note (from the reference text). Texts write the same update with (visits) and (wins) for each node on the visited path, and describe the stored value as the average utility — which for win/lose games is just the win percentage. The lecture's win/play notation is the same thing: is the win count, is the play count, and the ratio is the win rate. Keep one notation per problem — in this course, write wins over plays.
Over many iterations, the counts on the promising paths grow, and the counts tell you where to look next.
8.3.6 Worked Example 1: Win-to-Play Ratios
Every circle in the example tree contains two numbers: wins over times played. That is the win/play ratio , the wins in the numerator and the plays in the denominator — a node labelled means I have won twice out of three times played (said aloud as "2 by 3"). This is the whole tree drawn from one player's perspective.
Worked example — the four phases on a tiny tree.
Selection. At the root, three children: 2/3, 1/3, and 0/1. Which is most promising? 2/3 — three times played, twice won. Move to it. Among its children: one shows 1/2 (played twice, won once) and another shows 0/1 (played once, lost). Pick 1/2. Among its children: one shows 1/1 (played once, won once) and another lost its single play. Pick 1/1. That descent — repeatedly picking the most promising child — is selection, done via UCB1.
Expansion. The position marked 1/1 at the bottom has no statistics recorded under it — it has never been explored. Choose a random move and add a new record for it: 0/0, meaning "not played yet, not won yet." That is expansion. The 0/0 is just a denominator, an initialization after exploration — you could denote it with a star; do not overthink the notation.
Simulation. From the new node, a full simulation begins (shown with a dashed arrow). The moves in the simulation may be completely random or use simple calculations. The game is played to a terminal state.
Back propagation. Suppose the player won the simulation. The new node becomes 1/1 — played once, won once. Every node on the path gets its play count incremented by one, and each node matching the winner gets its win count incremented: in the example, a play count of 7 became 8, a count of 3 became 4, and so on up the path. Only the visited path is touched — the other branches keep their old counts.
Sense-check. The newly expanded move went from "never tried" to "won its first game", and the path that led to it now looks slightly better than before — exactly the signal the next selection round needs.
Q: Should it then be one out of three (the ratio)? A: One out of three means three games played and only one won — 1/3. But the node we chose is 2/3: three times played, twice won. That is more promising, so that is what selection picks.
8.3.7 Worked Example 2: The Go Tree from the White Perspective
The second example tree is drawn from the point of view of the white player; all the win counts record white's wins. The root shows 37 wins out of 101 plays — "37 represents that white has won 37 times out of the 101 times I played." The tree is the same shape as the classic example from the reference text (which draws it from black's point of view with the root at 37 wins out of 100 plays); the counts here match the narration of the session.
Worked example — one iteration from the white perspective.
Selection. Pick the most promising child repeatedly. The descent goes through a node like 60/79 and then deeper, always choosing the better ratio, down to a leaf. The principle is what matters: at every level, the child whose win/play ratio looks best gets the next visit.
Expansion. At the chosen node, add a new node: 0/0. It could be added in other promising places too, but this is the most promising spot, and inside the most promising thing you want to explore some other board configuration — so the new node is added here. The 0/0 just indicates a new node; from here you start with some configuration and play till the terminal state.
Simulation. Play a full game. Assume black wins.
Back propagation. Because the tree is drawn from white's point of view and white lost, the new node becomes 0/1 — one game play happened, and white lost. The win counts along the path stay unchanged (white did not win), but every play count along the path increments by one: 35 became 36, 53 became 54, 79 became 80, and 100 became 101.
The perspective flip. The instructor's caution: only black's win was recorded as a loss for white — if the tree had been drawn from black's point of view, this node would be 1/1, and the root would show 64 wins out of 101 plays, because with 37 white wins out of 101, black has won the other . Both representations are valid; you just have to keep the perspective consistent. The numbers do not need to add up to anything special — these are simulation counts.
Q: Only black wins are updated — correct? A: Correct, because the tree is drawn from the point of view of white. When black wins, white has lost, so the new node records 0/1 and the win counts along the path do not change — only the play counts increment. If you draw the same tree from black's point of view, the new node is 1/1, and the root becomes 64/101: 101 plays, 64 black wins, since .
Q: In back propagation, why not "17 by 54" in that example? A: The counts are only incremented for nodes on the visited path, and the win count only when the winner matches. The path node in question had 37 white wins out of 101 plays and white lost this simulation, so its win count stays 37 — it is not updated to 38. The play count is what increments.
Q: Is "1 by 1" a terminal state? A: No. 1/1 means played once and won that game; it is not a terminal state — it is just a node with a record. The terminal state is where the game is over. The 0/0 node added in expansion is also not a terminal — it is a new addition from which the game is freshly played.
After the time budget runs out, the counts tell you which paths are most promising to explore, and you restrict further play — and any alpha-beta search — to exactly those paths.
8.3.8 The MCTS Loop and Handoff to Alpha-Beta
The algorithm in full: start with the tree at the current state. While time remains, (1) select — pick a leaf via UCB1; (2) expand — add a child under it for an unexplored move (you can pick any node to treat as a leaf, and expansion is nothing but adding that child — the exploration step); (3) simulate — play a full game from that child to a terminal result; (4) back propagate — push the result up the visited path, updating win and play counts. Keep doing this until the timer expires.
The loop as pseudocode.
tree <- node for the current state
while time remains:
leaf <- SELECT(tree) # UCB1: exploit promising, explore uncertain
child <- EXPAND(leaf) # add one unexplored move as a new 0/0 node
result <- SIMULATE(child) # random/light playout to a terminal state
BACK-PROPAGATE(result, child) # increment win and play counts on the path
return the move whose node has the highest number of playouts
At the end, return the move whose node has the highest number of playouts — the configuration where the simulations said you win most often. Then, if you want to use alpha-beta, you apply it only in those promising parts of the tree, not everywhere. This is what the example tree was showing: the tree itself is many games' worth of statistics — some paths have three games behind them, some two, some one — and the statistics decide which of those sub-trees deserve the full search.
Complexity and cost. A playout costs time linear in the depth of the game — one move at each choice point — not exponential like a full tree. That linear cost is what makes millions of playouts affordable: the same budget that lets minimax search 6 ply deep lets alpha-beta search 12 ply and MCTS run millions of playouts. The cost to watch: each iteration only improves one path; trees with huge branching factors need many iterations before every child has a reliable sample, which is why the time budget is the real constraint in practice.
When to use MCTS, and the alternatives. Choose MCTS when the branching factor is huge (Go starts at 361 legal moves) or when no good static evaluation function exists — simulation needs only the rules. Choose alpha-beta when the branching factor is modest and a cheap, reliable evaluation exists (chess). The two combine: modern engines use MCTS statistics to decide where to spend alpha-beta search — exactly the handoff the professor describes. Do not use MCTS for tiny trees: minimax on a 9-board tic-tac-toe tree is exact and instant, and simulation would only add noise.
8.3.9 Student Questions and Answers
Q: But Monte Carlo plays a game completely till the last move and then updates the policy — yet here you are saying the game will not be played completely? A: Only one part of the tree is picked, and that part is played. Not all the possible children nodes are expanded. Each board configuration has its own paths to the goal state — each can lead to several possibilities and to terminals — but here we pick only one of them, explore it, go till a terminal state, and update the values all the way up. Not all the possible combinations are played to the end.
Q: Does Monte Carlo work on a complete episode — one complete sample set — or with few levels? A: With few levels first: once it picks one of them from the few levels, it will go all the way and play it to completion. Then the result updates the counts on that path. The four-phase example makes this concrete.
Q: In back propagation, why is the win count not updated when white lost? A: Counts are only incremented on the visited path, and the win count only when the winner matches the tree's perspective. White lost, so the win count stays 37 — it is not updated to 38. The play count is what increments.
Q: Will we explore a random path here, or the first path only? A: After the time budget runs out we have intuition about which paths to explore. We keep iterating — pick some other path, add an expansion node, simulate again — until the set time has elapsed. Then, on the promising paths, we might apply alpha-beta only on those particular parts of the tree, not all the other paths.
Q: Is exploration or expansion always done below the best promising node? A: It can be done in other places too. It is not always necessary to do it only below the best node — you can add an expansion node elsewhere and explore there.
Q: What does the final algorithm return? A: It returns the move whose node has the highest number of playouts — the most promising configuration — instead of exploring everything breadth-wise. That is the whole point of MCTS: simulate certain parts, see which are promising, and explore exactly those.
8.3.10 Exam Notes
Exam note: this topic is not covered in depth — you will not get a full-fledged MCTS problem to solve. Know what the four steps are (selection, expansion, simulation, back propagation) and what each one does: selection uses UCB1, expansion adds an unexplored child, simulation plays to the end with random moves (not perfectly), and back propagation updates win and play counts only on the visited path. Know the win/play notation, the perfect-information requirement, and why the naive simulation-based evaluation is too expensive. That is enough for the exam.
Real-world: MCTS is the algorithm behind modern game AI at the highest level — AlphaGo and its successors combine MCTS with neural networks that guide both selection and the playout policy, and the same simulation-guided search is used in program synthesis, robotics planning, and dialogue systems. The exploitation-versus-exploration trade-off it balances is the same one that drives recommendation systems, A/B testing platforms, and any system that must choose between what is known to work and what might work better.
8.4 The Mid-Semester Exam
8.4.1 Exam Format and Logistics
The mid-semester exam covers everything from classes 1 through 8, plus the webinar sessions. It is two hours long, for 30 marks, and it is a fully subjective exam — there are no MCQs. The exam is written online, but at an exam center: you get a hall ticket telling you where to go, and you go there to write the exam on a machine. There is no code — you will not write Python programs or any program. You may be asked to comment on something or to write an algorithm — a pseudo-code style answer is possible, but not programming.
The format at a glance. Two hours. 30 marks. Fully subjective — no MCQs. Written online at an exam center (hall ticket issued by the operations team). No code of any kind — algorithm or pseudo-code answers are possible. Closed book — no formulas given.
The exam is closed book, and formulas will not be given to you. There are very few formulas to memorize in this course — the advice is that in no class is there a formula you truly need to mug up. Even in alpha-beta pruning, if you understand the logic — the parent node is trying to go up, the child node is trying to find something lesser, there is a contradiction, so you prune — you do not need to memorize the formula.
The detailed syllabus and a sample or past paper will be posted as an announcement on the same day as this session. Have a look at that announcement — it has all the details. But do not treat the past paper as a prediction: do not apply correlation logic to it.
Pitfall — the past paper is not a prediction. Every time the paper changes, it changes considerably, and this course's syllabus has changed a lot — DFS and BFS, for example, are not in the course anymore. If you bet your preparation on the past paper, the utility might be −1. Prepare for the whole syllabus, then give the past paper a glance — do not take it too seriously.
8.4.2 What to Expect: Paper Structure and Difficulty
It will be a tight paper. Tight means you will not have the liberty to think for an hour and write for 10 minutes: if you are prepared well, the paper will take you about 1 hour 50 minutes to 1 hour 55 minutes to complete. This matters especially for working professionals — every week there were practice questions in the course materials, and the concern is that students have not solved them, so their speed has slowed down. If that is the case, you might end up not completing the paper.
It will be a well-balanced paper. The instructor does not believe in papers that are only algorithms, only code, or only one type of question. Expect a balance of theory, practical, numerical, and formula questions. The number of questions will vary — anywhere between 6 and 10 questions, small, medium, or one big question and another with two small parts.
The paper follows Bloom's taxonomy — a technique for assessing exams at different cognitive levels. Concretely: there will be some easy questions that everybody will know; if you do not answer those correctly, something is wrong with the teaching — the instructor takes that on himself. There will be questions you learned in class and then apply. And there will be some questions that push your boundaries. That mix is the design.
Marking — how the answers get scored. For some questions there is step marking; for some questions it is zero or one. For some questions step marking does not make sense — if you make a mistake in the second step, you lose the mark for that step, and it is gone. Some questions are full-or-nothing. The detailed key, released after the exam, will show which is which.
Q: Is it step marking or the whole answer at the end? A: For some questions, there is step marking. For some questions, it is zero or one. That will all be in the key when it is uploaded. For some questions, step marking does not make sense — if you make a mistake in the second step, you lose that mark in that step. Gone. It is a zero.
Q: Will pruning be applied in the evaluation of our answers? A: Yes, of course. You have to optimize your time too. If you have done the wrong thing, why would we keep on evaluating? The first mistake — we stop evaluating. You get the marks up to that point. The grading applies the same logic as alpha-beta: the branch of your solution stops being explored at the first wrong step.
The regular exam and the makeup exam will be almost the same, with slight variations — the makeup will not be identical to the regular paper. Within the regular exam itself, there may be sets: different students may get different questions. Do not worry about that. After all the exams are over, a complete solution with rubrics will be released, and from there, reevaluation concerns can be taken forward. Assignment results will not be released before the exam — assignments are still being evaluated, and they take time because there are more than 250 groups and the code is actually run to evaluate it.
8.4.3 What Is Covered: The Full Course Recap
You can expect any question from any topic — not every small topic, but from all the big pictures there will be questions. The recap of the whole course so far:
- The fundamentals of AI — the basics from the first classes: for a given problem, can you come up with a PEAS specification, an environment specification, and what else the problem needs.
- The problem-solving agent — how do you represent an agent, and the different types of agents.
- A bunch of search techniques — mostly informed search: A-star, GBFS, and the concepts around them.
- Within search, local search — hill climbing, genetic algorithms, ACO (ant colony optimization), and related ideas.
- For large search trees — pattern databases, relaxed constraints, and similar techniques.
- NAS — neural architecture search as an application of genetic algorithms: NEAT, Deep NEAT, and CoDeepNEAT, with theory and examples.
- Game playing — the material you have just covered: adversarial search, minimax, alpha-beta pruning, and Monte Carlo Tree Search.
Questions will come from all of these big areas.
8.4.4 Study Advice
Concentrate on all of it — there will be questions from every big topic. Keep solving: every set of course materials has sample problems, and a full-fledged practice paper will be uploaded. The more you solve, the faster you get; if your speed increases, you do justice to a tight paper. It should feel like: you see the question, you start answering. Do not solve slowly, get stuck, and run out of time.
The exam as an opportunity. Beyond the exam itself: enjoy the paper, forget about the marks. There are plenty of other components — assignment two, quiz two, and the final exam — and they all carry more weight than this mid-semester. So do not be too worried; treat the exam as an opportunity: an exam forces you to prepare, and preparing is learning.
Marks are not the metric. Marks are not always correlated with learning — a personal example: earning poor marks in a course while learning a great deal, and later becoming the faculty for that same course. And the reverse happens too: some courses earned good marks but the learning was questionable. Do not keep marks as your metric — use the forced preparation to learn, not to chase numbers.
8.4.5 Student Questions and Answers
Q: What should I concentrate on? A: Concentrate on all — there will be a question from all of them. Not every small topic, but from all the big pictures there will be questions: the basics, the searches, all of them, for 30 marks.
Q: Any numericals — do we have to mug up formulas? A: The exam is closed book, so you will not have formulas given. But there are not many formulas in this course, and in no class is there a formula you need to mug up. Even alpha-beta pruning: if you understand the logic — the parent node is trying to go up, the child node is trying to find something lesser, there is a contradiction, so you prune — that is enough.
Q: Can we expect programming-level questions, like writing an algorithm or similar things from what we studied? A: Not programming, but algorithms might be there. There is no way you will write Python programs or any program. You may be asked to comment on some things or write some algorithm — like a pseudo-code — that could be there.
Q: Was anything else covered in the webinar? A: The webinar was the same thing — some problems were solved, and a past exam problem was also solved in the webinar. You can have a look at that too.
Q: Where can I find the webinar videos? A: It is in the same folder where all the files are — the same folder where the materials live.
Q: Will the assignment results be released before the exam? A: Not really. Assignments are still being evaluated; there are more than 250 groups and the code is actually run to evaluate them, so it takes time. Focus on the exam; assignments come later.
Q: When will the hall tickets be out? A: That is handled by the operations team, and it should definitely be available within the next few days. Keep an eye out.
Q: Is the makeup exam the same as the regular exam? A: It will be almost the same, maybe slight variations — the difficulty level depends on your preparation level, but it will not be the same as the regular paper. There might be sets within the regular exam itself as well.
Exam Guidance Summary
Everything said in this session about the mid-semester exam, in one place:
- Format: two hours, 30 marks, fully subjective, no MCQs. Written online at an exam center with a hall ticket. No code — no Python programs; algorithm or pseudo-code answers are possible.
- Syllabus: everything from classes 1 through 8 plus the webinars — fundamentals of AI, PEAS and environment specifications, problem-solving agents and agent types, informed search (A-star, GBFS), local search (hill climbing, genetic algorithms, ACO), pattern databases and relaxed constraints, NAS/NEAT/Deep NEAT/CoDeepNEAT, and game playing (minimax, alpha-beta, Monte Carlo Tree Search). Questions come from all the big topics, so concentrate on all of it.
- Materials: the detailed syllabus and a sample/past paper are posted the day of this session. Do not treat the past paper as a prediction — the syllabus changed considerably (DFS and BFS are no longer in the course), so prepare the whole syllabus and glance at the past paper only.
- Closed book: no formulas given; very few formulas to memorize. Alpha-beta is logic, not memorization: parent wants to go up, child wants something lesser, contradiction, prune.
- Pacing: it is a tight paper — well prepared, expect 1 hour 50 minutes to 1 hour 55 minutes of writing. Solve the weekly practice problems to build speed; the goal is "see the question, start answering."
- Structure: a balanced mix of theory, practical, numerical, and formula questions; 6 to 10 questions of small and medium size, or one big question plus a two-part question. Bloom's taxonomy design: easy questions everyone knows, applied questions from class, and boundary-pushing questions.
- Marking: step marking for some questions, zero-or-one for others; a mistake at a step loses that step's marks, and evaluation stops at the first mistake — pruning applied to your answer sheet. Solutions with rubrics are released after all exams.
- Variants: the makeup exam is not identical to the regular paper; sets within the regular exam are possible.
- Mindset: other components (assignment two, quiz two, final exam) carry more weight; enjoy the paper, use the forced preparation as a learning opportunity, and do not use marks as the metric for learning.
Key Industry Applications
- Chess engines: typical chess programs evaluate about 1,000,000 positions per second — static evaluation plus search is the engine behind computer chess. The material-count evaluation of this lecture is the ancestor of the tuned evaluation functions in modern engines like Stockfish, which layer dozens of positional features on top of the same piece values.
- Go engines: Go needs about 1,000,000 moves per second with roughly 400 moves per simulation; full-game simulation as evaluation is far too slow — which is exactly the cost problem that made Monte Carlo search unpopular for over 10 years, until simulation-guided tree search (and later neural-network guidance, as in AlphaGo) made it practical.
- Real-world: simulation-guided search. The idea of letting simulation results guide which part of a search tree to grow — instead of expanding everything — is MCTS's contribution, and the same exploitation/exploration trade-off shows up across decision-making systems: recommenders, A/B testing, robotics planning, and drug-design search pipelines all allocate their next experiment to the most promising and the most uncertain options.
- Real-world: UCB in reinforcement learning. The upper confidence bound used for MCTS selection is standard material in deep reinforcement learning courses and is used broadly in bandit-style decision problems — any setting where a system must balance taking the action that works with trying the action it knows little about.
- Real-world: career decisions. The exploitation-versus-exploration trade-off is a life skill: capitalize on your strengths most of the time, and occasionally explore outside your comfort zone — the office-job-versus-PhD example — because exploration can find something even better.
- Real-world: competitive board gaming. Two-player tile games and Sudoku-style competitions — one board, several players racing for the same goal — are direct real-world settings for adversarial evaluation.
- Real-world: combinatorial games. Chess, Go, tic-tac-toe, and checkers are the canonical perfect-information games for which minimax, alpha-beta, and MCTS are designed; imperfect-information settings such as football cannot use them, because the tree structure encodes what a player is allowed to know as well as what they are allowed to do.
ACI Lecture 8 Notes · Static Evaluation, Alpha-Beta Pruning, and Monte Carlo Tree Search
Sections Breakdown
Where the numbers in minimax trees come from: the static evaluation function, its four properties, chess material counting, and tic-tac-toe win configurations.
Minimax plus one smart addition: alpha and beta bounds, the two pruning formulas, and the parent-child contradiction with two worked trees.
Simulation-guided tree growth: exploitation versus exploration, the four phases (selection, expansion, simulation, back propagation), and win-to-play ratios.
Exam format and logistics, paper structure and difficulty, full course recap, marking, and study advice.
Consolidated mid-semester exam guidance: format, syllabus, closed-book policy, pacing, structure, marking, variants, and mindset.
Where static evaluation, alpha-beta pruning, and Monte Carlo Tree Search appear in real systems.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
8.1 Static Evaluation Functions and Values
Must-know: Static evaluation value = sum of max player's utility minus sum of min player's utility; chess material values (queen 9, horse 3, bishop 3, soldier 1, off-board 0); tic-tac-toe counts win configurations (2 minus 1).
⚠️ Top pitfall: Treating the static evaluation value as the final utility, forgetting to state the max-player assumption, or counting X/O coins in tic-tac-toe instead of counting win configurations.
Self-check: A chess board has white horse + bishop + soldier (7) against black bishop + soldier (4). What is the static evaluation value from white's perspective?
Connects to: 8.2, 7.3, 7.4.
8.2 Alpha-Beta Pruning
Must-know: Alpha = best explored option for max, starts at -infinity; beta = best explored option for min, starts at +infinity. Prune after an alpha update when beta(parent) <= alpha(current); prune after a beta update when beta(current) <= alpha(parent). Root decision identical to minimax.
⚠️ Top pitfall: Trying to prune the leftmost child (the traversal starts there, bounds are infinity), pruning a node before its own beta is established, or flipping the formula direction when the root is a min node.
Self-check: In example 1, why is the leaf 10 under the max node holding alpha 8 never inspected?
Connects to: 8.1, 8.3, 7.3.
8.3 Monte Carlo Tree Search
Must-know: The four MCTS phases in order: selection (UCB1, exploitation vs exploration), expansion (add an unexplored child as 0/0), simulation (random playout to a terminal state, never minimax/alpha-beta), back propagation (increment win and play counts only on the visited path); return the move with the highest number of playouts.
⚠️ Top pitfall: Thinking the whole tree is played to completion (only the picked path is simulated), updating win counts for the losing player, or applying minimax/alpha-beta inside the simulation.
Self-check: A tree drawn from white's perspective has root 37 wins out of 101 plays; black wins the next simulation. What changes on the path, and what does the root read from black's perspective?
Connects to: 8.2, 8.1.
8.4 The Mid-Semester Exam
Must-know: Exam format (two hours, 30 marks, subjective, no MCQs, online at a center, closed book, no code), paper structure (tight, balanced, 6-10 questions, Bloom's taxonomy mix), and marking (step marks or zero/one; evaluation stops at the first mistake).
⚠️ Top pitfall: Treating the past paper as a prediction — the syllabus changed considerably (DFS and BFS are no longer in the course); prepare the whole syllabus instead.
Self-check: How many marks are lost when the first mistake appears in a step-marked question?
Connects to: 8.1, 8.2, 8.3.
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.