COMP 3200 - Intro to Artificial Intelligence - Lecture 10 - MiniMax Search Enhancements
Overview
David Churchill explains how to strengthen minimax and alpha-beta game-playing agents through better evaluation, tie-breaking, efficient state handling, move ordering, search extensions, bitboards, and transposition tables. He distinguishes implementation speedups from techniques that reduce search work, and highlights transposition tables as especially powerful, citing an example where they increased completed search depth from 13 to 27.
Key takeaways
- In minimax, terminal outcomes should receive exact scores, while unfinished positions need heuristics; both must be expressed from the maximizing player’s perspective.
- Adding turn-aware tie-breaking makes an agent prefer faster wins and later losses, preventing it from choosing needlessly slow victories or surrendering early.
- Connect Four search can avoid costly state copies by undoing each move after recursion, because removing the top piece restores the prior column.
- Move ordering and search extensions can improve alpha-beta search by prioritizing promising or tactically important branches, but their effects depend on the heuristic and should be tested.
- Transposition tables reuse evaluations and bounds for repeated positions; Churchill’s cited example increased completed search depth from 13 to 27 within a 300,000-node budget.
- Zobrist hashing makes transposition-table lookup practical by assigning random piece-square values and incrementally updating the state hash with XOR.
Chapters
- David Churchill uses “action” and “move” interchangeably for chess and Connect Four, while noting that a card-game turn can contain several ordered actions.
- Minimax relies on evaluation scores to choose moves, so the quality of the evaluation function directly affects an agent’s decisions.
- Terminal states have exact outcomes: a win, draw, or loss can be scored as positive, zero, or negative values.
- Non-terminal states need heuristic estimates because game trees are too large to search to completion under time limits such as five seconds.
- A chess material-count heuristic can be misleading: a player with fewer pieces may still have checkmate.
- The evaluation score is always calculated from the maximizing player’s perspective, so the minimizing player seeks lower scores.
- In the Connect Four assignment, `state.winner` distinguishes player one, player two, a draw, and `player none` for an unfinished game.
- The example exact scores are +10,000 for a win, -10,000 for a loss, and 0 for a draw; unfinished positions use a game-specific heuristic.
- Implementation improvements make each node cheaper to process, while theoretical enhancements such as alpha-beta pruning reduce how many nodes must be searched.
- Faster code can reach greater search depths under the same time limit, but code speedups are usually constant-factor rather than exponential.
- David Churchill uses Sebastian Lague’s chess-engine demonstrations to illustrate how many modest enhancements can compound into a much stronger agent.
- When multiple moves lead to the same forced win or loss score, minimax may choose an unnecessarily slow win or give up early.
- To prefer faster wins, subtract the turn number from the winning score; to prefer later losses, add the turn number to the losing score.
- A secondary turn-number field can break ties without combining the score and timing into one number; Churchill recommends testing this behavior in the assignment.
- With the maximizing player at depth zero, maximizing moves occur at even depths and minimizing moves at odd depths.
- Stopping immediately after your own move can make an evaluation optimistic because it may omit the opponent’s reply, such as a capture or checkmate.
- An 11-ply search can sometimes outperform a 12-ply search because the two depths evaluate positions after different players have moved; Churchill recommends comparing odd and even limits experimentally.
- Applying an action to a shared JavaScript game-state object can alter the state seen by parent recursive calls.
- Without a separate state for each child, later actions in the parent loop may be applied to a corrupted position or may no longer be legal.
- A deep copy prevents this mutation problem, but copying arrays and other state data at every node can be expensive.
- Connect Four moves can be undone by removing the top piece from the column where it was placed.
- Search can apply an action, recurse, and then call `undo_action`, avoiding a full state copy for every child.
- Churchill says undoing moves can be dramatically faster than copying, while noting that games such as chess need extra history to restore captured pieces.
- Alpha-beta pruning can cut more branches when promising actions are searched before weaker ones.
- A heuristic can rank actions, but imperfect rankings do not guarantee a speedup or stronger play.
- Churchill recommends keeping move ordering configurable and comparing versions through repeated games.
- Ordinary minimax searches every branch to the same depth, even when some moves create much more consequential positions.
- A chess engine might search deeper after a checking move; a Connect Four agent might extend lines where either player has three in a row.
- Extensions can focus computation on tactical branches, but their playing-strength benefit should be tested rather than assumed.
- Bitwise AND, OR, and XOR operate across the bits of integer values, while shifts move bits and negation flips them.
- XOR produces 1 when corresponding bits differ and 0 when they match; CPUs can perform these operations efficiently.
- Churchill presents bit operations as optional low-level optimization material, not a required assignment implementation.
- A bit set represents membership using one bit per possible index, allowing many Boolean values to fit in one integer.
- For example, the set {1, 4, 6, 7, 8, 12, 14} can be encoded by setting those indexed bits.
- Bitwise AND gives set intersection, OR gives union, and AND with a negated mask can remove an element; the fixed bit width limits representable indices.
- XOR has useful identities: a XOR 0 equals a, and a XOR itself equals 0, so repeated values cancel in a sequence.
- A parity drive can store the XOR of corresponding bits across several data drives; if one drive fails, XORing the remaining drives with parity reconstructs its data.
- The example illustrates single-drive redundancy; Churchill notes that two-drive redundancy requires more than the simple XOR scheme.
- An 8-by-8 chessboard has 64 squares, so a 64-bit integer can encode one Boolean value per square.
- A full chess position can use 12 bitboards, one for each piece type and color, while OR combines them into occupancy sets.
- Intersecting a queen’s attack mask with an opponent’s occupancy bitboard identifies attacked pieces using bit operations instead of scanning board-array cells.
- A transposition occurs when different move sequences reach the same game state, making the search repeat work unless it stores prior results.
- Iterative deepening also revisits positions as it searches depths one, two, three, and beyond.
- A transposition-table entry can store an evaluation, best action, search depth, and whether the score is exact or a bound.
- Stored exact values can let the search skip a previously computed subtree; stored alpha and beta bounds can also narrow later search windows.
- Churchill cites an example where a transposition table raised the completed depth from 13 to 27 within a 300,000-node budget, with about 98% fewer nodes through depth 13.
- A transposition table needs a hash of each game state to use as its lookup key; Churchill identifies Zobrist hashing as one method.
- Zobrist hashing assigns random values to piece-color-square combinations and XORs the values for pieces currently on the board.
- Adding or removing a piece updates the hash by XORing its associated value; moving a piece removes its old square value and adds its new one.
- The hash can be updated incrementally rather than recomputed from the entire board, though finite hash values can still produce collisions.
Transcript excerpt
0:02 Selection number 10. Uh today, well, last lecture we talked about the minimax search algorithm and alpha-beta pruning, which was an enhancement for minimax. And today we're going to spend the whole lecture talking about um other enhancements that we can put on these search algorithms in what uh as well. But uh before I get into that, I just wanted to uh put in a few useful links here for you. Um one of which that I've actually based a lot of this lecture on. Uh and that is uh the Coding Adventure series by Sebastian Legg. Has anyone seen any of uh their videos? Yeah, they're really really good. I really wish that I could spend as much time on one video as some of these YouTube creators do because it's it's absolutely incredible like the visualizations and the explanation that they go into.
0:50 But I have to give two lectures in a day, not one every 6 months. And so I can't really uh match that sort of quality, but I highly recommend um this second video if you are actually interested in the minimax algorithm or two-player game playing uh because it's a quite a bit uh quite a good video. Uh some other videos here and uh the chess programming wiki has lots of great resources as well. So none of these will be required. Uh like I'm not going to ask questions about those videos on the exam. But if you are uh a nerd like me when it comes to AI programming, you will probably appreciate some of these videos. Okay. Excuse [clears throat] me. I felt absolutely fine when I left my office, but between leaving my office and getting here like it's almost like I got a cold or something. It's really
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Dave Churchill.