CS 416 Artificial Intelligence Lecture Lecture 99 Adversarial Adversarial Search Search Chapter Chapter 66 Games Shall Shall we we play play aa game game Let s Let s play play tic tac toe tic tac toe Minimax What data do we need to play Initial Initial State State How How does does the the game game start start Successor Successor Function Function A A list list of of legal legal move move state state pairs pairs for for each each state state Terminal Terminal Test Test Determines Determines when when game game is is over over Utility Utility Function Function Provides Provides numeric numeric value value for for all all terminal terminal states states Minimax Strategy Optimal Optimal Stragtegy Stragtegy Leads Leads to to outcomes outcomes at at least least as as good good as as any any other other strategy strategy when when playing playing an an infallible infallible opponent opponent Pick Pick the the option option that that most most max max minimizes minimizes the the damage damage your your opponent opponent can can do do maximize maximize the the worst case worst case outcome outcome because because your your skillful skillful opponent opponent will will certainly certainly find find the the most most damaging damaging move move Minimax Algorithm Algorithm MinimaxValue n MinimaxValue n Utility Utility n n ifif nn is is aa terminal terminal state state max max MinimaxValue s MinimaxValue s ofof allall successors successors ss ifif nn is is aa MAX MAX node node min min MinimaxValue s MinimaxValue s ofof allall successors successors ss ifif nn is is aa MIN MIN node node Minimax Minimax Algorithm We We wish wish to to identify identify minimax minimax decision decision at at the the root root Recursive Recursive evaluation evaluation of of all all nodes nodes in in game game tree tree Time Time complexity complexity O O b bmm Feasibility of minimax How How about about aa nice nice game game of of chess chess Avg Avg branching branching 35 35 and and avg avg moves moves 50 50 for for each each player player 100 time 154 nodes O 35 O 35100 time complexity complexity 10 10154 nodes 40 distinct 10 1040 distinct nodes nodes Minimax Minimax is is impractical impractical ifif directly directly applied applied to to chess chess Pruning minimax tree Are Are there there times times when when you you know know you you need need not not explore explore aa particular particular move move When When the the move move is is poor poor Poor Poor compared compared to to what what Poor Poor compared compared to to what what you you have have explored explored so so far far Alpha beta pruning Alpha beta pruning the the value value of of the the best best highest highest choice choice so so far far in in search search of of MAX MAX the the value value of of the the best best lowest lowest choice choice so so far far in in search search of of MIN MIN Order Order of of considering considering successors successors matters matters look look at at step step ff in in previous previous slide slide IfIf possible possible consider consider best best successors successors first first Realtime decisions What What ifif you you don t don t have have enough enough time time to to explore explore entire entire search search tree tree We We cannot cannot search search all all the the way way down down to to terminal terminal state state for for all all decision decision sequences sequences Use Use aa heuristic heuristic to to approximate approximate guess guess eventual eventual terminal terminal state state Evaluation Function The The heuristic heuristic that that estimates estimates expected expected utility utility Cannot Cannot take take too too long long otherwise otherwise recurse recurse to to get get answer answer ItIt should should preserve preserve the the ordering ordering among among terminal terminal states states otherwise otherwise itit can can cause cause bad bad decision decision making making Define Define features features of of game game state state that that assist assist in in evaluation evaluation what what are are features features of of chess chess Truncating minimax search When When do do you you recurse recurse or or use use evaluation evaluation function function Cutoff Test Cutoff Test state state depth depth returns returns 11 or or 00 When When 11 is is returned returned use use evaluation evaluation function function Cutoff Cutoff beyond beyond aa certain certain depth depth Cutoff Cutoff ifif state state is is stable stable more more predictable predictable Cutoff Cutoff moves moves you you know know are are bad bad forward forward pruning pruning Benefits of truncation Comparing Comparing Chess Chess Using Using minimax minimax 55 ply ply Average Average Human Human 6 8 6 8 ply ply Using Using alpha beta alpha beta 10 10 ply ply Intelligent Intelligent pruning pruning 14 14 ply ply Games with chance How How to to include include chance chance in in game game tree tree Add Add chance chance nodes nodes Expectiminimax Expectiminimax Expectiminimax n n utility n utility n ifif nn is is aa terminal terminal state state max s Successors n EXPECTIMINIMAX s ifif nn is is aa MAX MAX node node min s Successors n EXPECTIMINIMAX s ifif nn is is aa MIN MIN node node P s EXPECTIMINIMAX s s Successors n ifif nn is is aa chance chance node node Pruning Can Can we we prune prune search search in in games games of of chance chance Think Think about about alpha beta alpha beta pruning pruning don t don t explore explore nodes nodes that that you you know know are are worse worse than than what what you you have have we we don t don t know know what what we we have have chance chance node node values values are are average average of of successors successors History of Games Chess Chess Deep Deep Blue Blue IBM IBM 30 30 RS 6000 RS 6000 comps comps with with 480 480 custom custom VLSI VLSI chess chess chips chips Deep Deep Thought Thought design design came came from from Campbell Campbell and and Hsu Hsu at at CMU CMU 126 126 mil mil nodes nodes ss 30 30 bil bil positions positions per per move move routine routine reaching reaching depth depth of of 14 14 iterative iterative deepening deepening alpha beta alpha beta search search Deep Blue evaluation evaluation function function had had 8000 8000 features features 4000 4000 opening opening moves moves in in memory memory 700 000 700 000 grandmaster grandmaster games games from from which which recommendations recommendations extracted extracted
View Full Document