190 likes | 372 Views
Game Trees. William Dotson. Overview. Definitions Minimax Alpha-Beta Pruning More Efficient Pruning Deep Blue – Deep Fritz Conclusion. Definitions. Directed Graph Nodes Paths Position Evaluator “Easy” vs “Hard”. Game Tree Complexity. Tic-Tac-Toe – 9! – 362,280 states
E N D
Game Trees William Dotson
Overview • Definitions • Minimax • Alpha-Beta Pruning • More Efficient Pruning • Deep Blue – Deep Fritz • Conclusion
Definitions • Directed Graph • Nodes • Paths • Position Evaluator • “Easy” vs “Hard”
Game Tree Complexity • Tic-Tac-Toe – 9! – 362,280 states • Connect Four – 10^13 states • Checkers – 10^18 states • Chess – 10^50 states • Go – 10^170 states
Minimax • 2 Players – Max and Min • Generate Graph to depth D • Assign Values to Final Nodes • Build Up Tree Alternating Max/Min
Static Position Evaluator 3 1 2 2 1 1 2 1 2
Static Position Evaluator X 0 X 0 Evaluate from X’s Point of View: State Value of 4
Minmax Example • 3 Looks Ahead – D = 3
Minmax Example • 3 Looks Ahead – D = 3 3 10 4 5 7 Max
Minmax Example • 3 Looks Ahead – D = 3 4 5 Min 3 3 10 4 5 7 Max
Minmax Example • 3 Looks Ahead – D = 3 Max 5 4 5 Min 3 3 10 4 5 7 Max
Minimax Pseudocode • MinMax (GamePosition game) { MinMove (GamePosition game) { return MaxMove (game); best_move <- {}; } moves <- GenerateMoves(game); ForEach moves { MaxMove (GamePosition game) { move <- MaxMove(ApplyMove(game)); if (GameEnded(game)) { if(Value(move) < Value(best_move)){ return EvalGameState(game); best_move <- move; } } else { } best_move <- {}; return best_move; moves <- GenerateMoves(game); } ForEach moves { move <- MinMove(ApplyMove(game)); if (Value(move) > Value(best_move)) { best_move <- move; } } return best_move; } }
Alpha-Beta Pruning • Modification of Minimax • Next move needs consideration • If worse then best, first move which opposition could take will be last move we have to look at.
Alpha-Beta Diagram Player Opponent . . . Player Opponent M n General Case: If M is is better than N for Player, we will never get to N.
Minimax w/ Alpha Beta • MinMax (GamePosition game) { MinMove (GamePosition game) { return MaxMove (game); best_move <- {}; } moves <- GenerateMoves(game); ForEach moves { MaxMove (GamePosition game) { move <- MaxMove(ApplyMove(game)); if (GameEnded(game)) { if(Value(move) < Value(best_move)){ return EvalGameState(game); best_move <- move; } beta <- Value(move); else { } best_move <- {}; moves <- GenerateMoves(game); if(alpha > beta) ForEach moves { return best_move; move <- MinMove(ApplyMove(game)); } if (Value(move) > Value(best_move)) { return best_move; best_move <- move; } alpha <- Value(move); } } if(beta > alpha) return best_move; } return best_move; } }
Other Algorithms • Try to avoid horizon affect • Ignore paths that can be known to be wrong • CCNS – ‘Controlled Conspiracy Node Search’ • Target driven. • Used in Ulysses a 1988 Chess Program.
Deep Blue/Deep Fritz • Prunes Minimax Tree more intelligently • Both use Targets like Ulysses • Deep-Fritz uses Pattern Recognition • Deep-Fritz has 1.3% brute power of Deep Blue, but plays at roughly the same level.
Conclusion • Game Trees • Minimax • Alpha-Beta • Moving Ahead
Resources • Alpha Beta Pruning Nodes. http://sern.ucalgary.ca/courses/CPSC/533/W99/presentations/L2_5B_Lima_Neitz/search.html Stuart Russel, Peter Norvig. 1995. • Minimax Trees. http://www.generation5.org/content/2001/minimax.asp James Matthews. 2001. • Minimax Explained. http://ai-depot.com/LogicGames/MiniMax.html Paulo Pinto. • Deep Fritz Draws: Are Humans Getting Smarter, or Are Computers Getting Stupider? http://www.kurzweilai.net/articles/art0527.html?printable=1 Ray Kurzweil 2002.