contents foundations of artificial intelligence
play

Contents Foundations of Artificial Intelligence Board Games 1 6. - PowerPoint PPT Presentation

Contents Foundations of Artificial Intelligence Board Games 1 6. Board Games Minimax Search 2 Search Strategies for Games, Games with Chance, State of the Art Alpha-Beta Search 3 Wolfram Burgard, Bernhard Nebel, and Martin Riedmiller


  1. Contents Foundations of Artificial Intelligence Board Games 1 6. Board Games Minimax Search 2 Search Strategies for Games, Games with Chance, State of the Art Alpha-Beta Search 3 Wolfram Burgard, Bernhard Nebel, and Martin Riedmiller Games with an Element of Chance 4 Albert-Ludwigs-Universit¨ at Freiburg State of the Art 5 May 31, 2011 (University of Freiburg) Foundations of AI May 31, 2011 2 / 35 Why Board Games? Problems Board games are not only difficult because they are contingency problems, but also because the search trees can become astronomically large. Board games are one of the oldest branches of AI (Shannon and Turing 1950). Examples : Chess : On average 35 possible actions from every position; often, Board games present a very abstract and pure form of competition games have 50 moves per player, resulting in a search depth of 100 : between two opponents and clearly require a form of “intelligence”. → 35 100 ≈ 10 150 nodes in the search tree (with “only” 10 40 legal chess The states of a game are easy to represent. positions). The possible actions of the players are well-defined. Go : On average 200 possible actions with ca. 300 moves → 200 300 ≈ 10 700 nodes. → Realization of the game as a search problem → The world states are fully accessible Good game programs have the properties that they → It is nonetheless a contingency problem, because the characteristics of delete irrelevant branches of the game tree, the opponent are not known in advance. use good evaluation functions for in-between states, and look ahead as many moves as possible. (University of Freiburg) Foundations of AI May 31, 2011 3 / 35 (University of Freiburg) Foundations of AI May 31, 2011 4 / 35

  2. Terminology of Two-Person Board Games Tic-Tac-Toe Example MAX ( X ) Players are max and min , where max begins. X X X MIN ( O ) X X X X X X Initial position (e.g., board arrangement) X O X O X . . . MAX ( X ) O Operators (= legal moves) X O X X O X O . . . MIN ( O ) X X Termination test, determines when the game is over. Terminal state = game over. . . . . . . . . . . . . Strategy. In contrast to regular searches, where a path from beginning . . . X O X X O X X O X O X O O X X TERMINAL to end is simply a solution, max must come up with a strategy to reach O X X O X O O Utility �–1 0 +1 a terminal state regardless of what min does → correct reactions to all Every step of the search tree, also called game tree, is given the player’s name whose of min ’s moves. turn it is ( max - and min -steps). When it is possible, as it is here, to produce the full search tree (game tree), the minimax algorithm delivers an optimal strategy for max . (University of Freiburg) Foundations of AI May 31, 2011 5 / 35 (University of Freiburg) Foundations of AI May 31, 2011 6 / 35 Minimax Minimax Example 1. Generate the complete game tree using depth-first search. 2. Apply the utility function to each terminal state. 3. Beginning with the terminal states, determine the utility of the predecessor nodes as follows: Node is a min -node Value is the minimum of the successor nodes Node is a max -node Value is the maximum of the successor nodes From the initial state (root of the game tree), max chooses the move that leads to the highest value (minimax decision). Note: Minimax assumes that min plays perfectly. Every weakness (i.e., every mistake min makes) can only improve the result for max . (University of Freiburg) Foundations of AI May 31, 2011 7 / 35 (University of Freiburg) Foundations of AI May 31, 2011 8 / 35

  3. Minimax Algorithm Evaluation Function Recursively calculates the best move from the initial state. When the search space is too large, the game tree can be created to a function M INIMAX -D ECISION ( state ) returns an action certain depth only. The art is to correctly evaluate the playing position of return arg max a ∈ A CTIONS ( s ) M IN -V ALUE (R ESULT ( state , a )) the leaves. function M AX -V ALUE ( state ) returns a utility value if T ERMINAL -T EST ( state ) then return U TILITY ( state ) Example of simple evaluation criteria in chess: v ← −∞ for each a in A CTIONS ( state ) do Material value: pawn 1, knight/bishop 3, rook 5, queen 9 v ← M AX ( v , M IN -V ALUE (R ESULT ( s , a ))) return v Other: king safety, good pawn structure function M IN -V ALUE ( state ) returns a utility value Rule of thumb: 3-point advantage = certain victory if T ERMINAL -T EST ( state ) then return U TILITY ( state ) v ← ∞ The choice of evaluation function is decisive! for each a in A CTIONS ( state ) do v ← M IN ( v , M AX -V ALUE (R ESULT ( s , a ))) return v The value assigned to a state of play should reflect the chances of winning, i.e., the chance of winning with a 1-point advantage should be less than with a 3-point advantage. Note: Minimax only works when the game tree is not too deep. Otherwise, the minimax value must be approximated. (University of Freiburg) Foundations of AI May 31, 2011 9 / 35 (University of Freiburg) Foundations of AI May 31, 2011 10 / 35 Evaluation Function - General When Should we Stop Growing the Tree? Motivation: Return an answer within the allocated time. The preferred evaluation functions are weighted, linear functions: Fixed-depth search w 1 f 1 + w 2 f 2 + · · · + w n f n Better: iterative deepening search (stop, when time is over) where the w ’s are the weights, and the f ’s are the features. [e.g., w 1 = 3 , but only stop and evaluate at ’quiescent’ positions that won’t cause f 1 = number of our own knights on the board] large fluctuations in the evaluation function in the following moves. E.g. if one can capture a figure, then the position is not ’quiescent’ because this might change the evaluation dramatically. Solution: Continue The above linear sum makes a strong assumption: the contribution of search at non quiescent positions, favorably by only allowing certain each feature are independend. (not true: e.g. bishops in the endgame are types of moves (e.g. capturing) to reduce search effort, until a quiescent more powerful, when there is more space) position was reached. The weights can be learned. The features, however, are often designed by problem of limited depth search: horizon effect (see next slide) human intuition and understandig (University of Freiburg) Foundations of AI May 31, 2011 11 / 35 (University of Freiburg) Foundations of AI May 31, 2011 12 / 35

  4. Horizon Problem Alpha-Beta Pruning Improvement possible? We do not need to consider all nodes. Black to move Black has a slight material advantage . . . but will eventually lose (pawn becomes a queen) A fixed-depth search cannot detect this because it thinks it can avoid it (on the other side of the horizon - because black is concentrating on the check with the rook, to which white must react). (University of Freiburg) Foundations of AI May 31, 2011 13 / 35 (University of Freiburg) Foundations of AI May 31, 2011 14 / 35 Alpha-Beta Pruning: General Alpha-Beta Pruning Player Minimax algorithm with depth-first search α = the value of the best (i.e., highest-value) choice we have found so far m Opponent at any choice point along the path for max . .. .. β = the value of the best (i.e., lowest-value) choice we have found so far .. at any choice point along the path for min . Player n Opponent If m > n we will never reach node n in the game. (University of Freiburg) Foundations of AI May 31, 2011 15 / 35 (University of Freiburg) Foundations of AI May 31, 2011 16 / 35

  5. When Can we Prune? Alpha-Beta Search Algorithm function A LPHA -B ETA -S EARCH ( state ) returns an action v ← M AX -V ALUE ( state , −∞ , + ∞ ) The following applies: return the action in A CTIONS ( state ) with value v α values of max nodes can never decrease function M AX -V ALUE ( state , α , β ) returns a utility value if T ERMINAL -T EST ( state ) then return U TILITY ( state ) β values of min nodes can never increase v ← −∞ for each a in A CTIONS ( state ) do v ← M AX ( v , M IN -V ALUE (R ESULT ( s , a ), α , β )) if v ≥ β then return v (1) Prune below the min node whose β -bound is less than or equal to the α ← M AX ( α , v ) α -bound of its max -predecessor node. return v function M IN -V ALUE ( state , α , β ) returns a utility value (2) Prune below the max node whose α -bound is greater than or equal to if T ERMINAL -T EST ( state ) then return U TILITY ( state ) the β -bound of its min -predecessor node. v ← + ∞ for each a in A CTIONS ( state ) do v ← M IN ( v , M AX -V ALUE (R ESULT ( s , a ) , α , β )) → Provides the same results as the complete minimax search to the same if v ≤ α then return v depth (because only irrelevant nodes are eliminated). β ← M IN ( β , v ) return v Initial call with Max-Value ( initial - state , −∞ , + ∞ ) (University of Freiburg) Foundations of AI May 31, 2011 17 / 35 (University of Freiburg) Foundations of AI May 31, 2011 18 / 35 Alpha-Beta Pruning Example Alpha-Beta Pruning Example 3 3 MAX MAX 3 3 2 MIN MIN X X 3 12 8 3 12 8 2 (University of Freiburg) Foundations of AI May 31, 2011 19 / 35 (University of Freiburg) Foundations of AI May 31, 2011 20 / 35

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend