Game Playing: Adversarial Search chapter 5. Game Playing: Adversarial Search  Introduction  So far, in problem solving, single agent search  The machine.

Slides:



Advertisements
Similar presentations
Chapter 6, Sec Adversarial Search.
Advertisements

Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
For Friday Finish chapter 5 Program 1, Milestone 1 due.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
For Monday Read chapter 7, sections 1-4 Homework: –Chapter 4, exercise 1 –Chapter 5, exercise 9.
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
CMSC 671 Fall 2001 Class #8 – Thursday, September 27.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
1 Game Playing. 2 Outline Perfect Play Resource Limits Alpha-Beta pruning Games of Chance.
Adversarial Search: Game Playing Reading: Chapter next time.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
CMSC 463 Chapter 5: Game Playing Prof. Adam Anthony.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
This time: Outline Game playing The minimax algorithm
Lecture 02 – Part C Game Playing: Adversarial Search
1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides:
Game Playing CSC361 AI CSC361: Game Playing.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
CSC 412: AI Adversarial Search
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Notes adapted from lecture notes for CMSC 421 by B.J. Dorr
Adversarial Search Chapter 5 Adapted from Tom Lenaerts’ lecture notes.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game Playing: Adversarial Search Dr. Yousef Al-Ohali Computer Science Depart. CCIS – King Saud University Saudi Arabia
Game Playing.
AD FOR GAMES Lecture 4. M INIMAX AND A LPHA -B ETA R EDUCTION Borrows from Spring 2006 CS 440 Lecture Slides.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
1 Computer Group Engineering Department University of Science and Culture S. H. Davarpanah
Chapter 6 Adversarial Search. Adversarial Search Problem Initial State Initial State Successor Function Successor Function Terminal Test Terminal Test.
Adversarial Search CS311 David Kauchak Spring 2013 Some material borrowed from : Sara Owsley Sood and others.
Games Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell, Andrew Moore,
Notes on Game Playing by Yun Peng of theYun Peng University of Maryland Baltimore County.
For Wednesday Read Weiss, chapter 12, section 2 Homework: –Weiss, chapter 10, exercise 36 Program 5 due.
Introduction to Artificial Intelligence CS 438 Spring 2008 Today –AIMA, Ch. 6 –Adversarial Search Thursday –AIMA, Ch. 6 –More Adversarial Search The “Luke.
Minimax with Alpha Beta Pruning The minimax algorithm is a way of finding an optimal move in a two player game. Alpha-beta pruning is a way of finding.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
For Wednesday Read chapter 7, sections 1-4 Homework: –Chapter 6, exercise 1.
Quiz 4 : Minimax Minimax is a paranoid algorithm. True
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri CS 440 / ECE 448 Introduction to Artificial Intelligence.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Game-playing AIs Part 2 CIS 391 Fall CSE Intro to AI 2 Games: Outline of Unit Part II  The Minimax Rule  Alpha-Beta Pruning  Game-playing.
CMSC 421: Intro to Artificial Intelligence October 6, 2003 Lecture 7: Games Professor: Bonnie J. Dorr TA: Nate Waisbrot.
Adversarial Search 2 (Game Playing)
Adversarial Search and Game Playing Russell and Norvig: Chapter 6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
Adversarial Search and Game Playing. Topics Game playing Game trees Minimax Alpha-beta pruning Examples.
Chapter 5: Adversarial Search & Game Playing
Adversarial Search CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and Java.
PENGANTAR INTELIJENSIA BUATAN (64A614)
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Game Playing: Adversarial Search
Game Playing: Adversarial Search
Game Playing: Adversarial Search
Game Playing Chapter 5.
Adversarial Search CMPT 420 / CMPG 720.
Games & Adversarial Search
Presentation transcript:

Game Playing: Adversarial Search chapter 5

Game Playing: Adversarial Search  Introduction  So far, in problem solving, single agent search  The machine is “exploring” the search space by itself.  No opponents or collaborators.  Games require generally multiagent (MA) environments:  Any given agent need to consider the actions of the other agent and to know how do they affect its success?  Distinction should be made between cooperative and competitive MA environments.  Competitive environments: give rise to adversarial search: playing a game with an opponent.

Game Playing: Adversarial Search  I I ntroduction WW hy study games? GG ame playing is fun and is also an interesting meeting point for human and computational intelligence. TT hey are hard. EE asy to represent. AA gents are restricted to small number of actions. II nteresting question: Does winning a game absolutely require human intelligence?

 Introduction  Different kinds of games: Chess, Checkers Go, Othello Backgammon, Monopoly Battleship Bridge, Poker, Scrabble, Deterministic Chance Perfect Information Imperfect Information  Games with perfect information. No randomness is involved.  Games with imperfect information. Random factors are part of the game.

Game Playing: Adversarial Search  Searching in a two player game  Traditional (single agent) search methods only consider how close the agent is to the goal state (e.g. best first search).  In two player games, decisions of both agents have to be taken into account: a decision made by one agent will affect the resulting search space that the other agent would need to explore.  Question : Do we have randomness here since the decision made by the opponent is NOT known in advance?  No. Not if all the moves or choices that the opponent can make are finite and can be known in advance.

Game Playing: Adversarial Search  Searching in a two player game To formalize a two player game as a search problem an agent can be called MAX and the opponent can be called MIN. Problem Formulation:  Initial state: board configurations and the player to move.  Successor function: list of pairs (move, state) specifying legal moves and their resulting states. (moves + initial state = game tree)  A terminal test: decide if the game has finished.  A utility function: produces a numerical value for (only) the terminal states. Example: In chess, outcome = win/loss/draw, with values +1, -1, 0 respectively.  Players need search tree to determine next move.

Partial game tree for Tic-Tac-Toe Each level of search nodes in the tree corresponds to all possible board configurations for a particular player MAX or MIN. Utility values found at the end can be returned back to their parent nodes. Idea: MAX chooses the board with the max utility value, MIN the minimum.

Game Playing: Adversarial Search  Searching in a two player game  The search space in game playing is potentially very huge: Need for optimal strategies.  The goal is to find the sequence of moves that will lead to the winning for MAX.  How to find the best trategy for MAX assuming that MIN is an infaillible opponent.  Given a game tree, the optimal strategy can be determined by the MINIMAX-VALUE for each node. It returns: 1. Utility value of n if n is the terminal state. 2. Maximum of the utility values of all the successor nodes s of n : n is a MAX’s current node. 3. Minimum of the utility values of the successor node s of n : n is a MIN’s current node.

Game Playing: Adversarial Search  Searching in a two player game MINIMAX-VALUE (n) = Utility (n) if n is a terminal state Max s   Min s   Given a choice, MAX will prefer to move to a state of maximum value, whereas MIN prefers a state of minimum value. Notice: 1. Minimax value != Utility value 2. Utility value is the value of a terminal node in the game tree 3. Minimax value indicates the best value that the current player can possibly get.

Game Playing: Adversarial Search  Searching in a two player game  The MINIMAX algorithm  If the terminal states have been reached then compute their utility values: +1, -1, or 0.  Otherwise, if the current search level is a maximising level (MAX’s move) then apply MINIMAX on the children of the current position and report the maximum of the results.  Otherwise, the level is a minimising level, so invoke MINIMAX on the children of the current position and report the minimum of the results.

Game Playing: Adversarial Search  Searching in a two player game  The MINIMAX algorithm MAX node MIN node Max nodeMin node value computed by minimax Utility value

Game Playing: Adversarial Search The MINIMAX algorithm function MINIMAX-DECISION(state) returns an action inputs: state, current state in game v ← MAX-VALUE(state) return the action in SUCCESSORS(state) with value v function MAX-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v ← ∞ for a,s in SUCCESSORS(state) do v ← MAX(v,MIN-VALUE(s)) return v function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v ← ∞ for a,s in SUCCESSORS(state) do v ← MIN(v,MAX-VALUE(s)) return v

Game Playing: Adversarial Search CriterionMinimax Complete?Yes OptimalityYes SpaceO(bm) TimeO(b m ) MINIMAX properties  Note: For chess, b = 35, m = 100 for a “reasonable game.”  Solution is completely infeasible Actually only board positions, not Note: For chess, b = 35, m = 100 for a “reasonable game.”  Solution is completely infeasible Actually only board positions, not

Game Playing: Adversarial Search  Problem of minimax search Number of games states is exponential to the number of moves. Solution: Do not examine every node ==> Alpha-beta pruning Alpha = value of best choice found so far at any choice point along the MAX path. Beta = value of best choice found so far at any choice point along the MIN path.

Game Playing: Adversarial Search Alpha-beta pruning Basic idea: If you have an idea that is surely bad, don't take the time to see how truly awful it is.” -- Pat Winston 271 =2 >=2 <=1 ? We don’t need to compute the value at this node. No matter what it is, it can’t effect the value of the root node. Some branches will never be played by rational players since they include sub-optimal decisions (for either player).

Game Playing: Adversarial Search

General description of α- β pruning algorithm  Traverse the search tree in depth-first order  At each Max node n, alpha(n) = maximum value found so far  Start with - infinity and only increase.  Increases if a child of n returns a value greater than the current alpha.  Serve as a tentative lower bound of the final pay-off.  At each Min node n, beta(n) = minimum value found so far  Start with infinity and only decrease.  Decreases if a child of n returns a value less than the current beta.  Serve as a tentative upper bound of the final pay-off.  beta(n) for MAX node n: smallest beta value of its MIN ancestors.  alpha(n) for MIN node n: greatest alpha value of its MAX ancestors

Game Playing: Adversarial Search Carry alpha and beta values down during search –alpha can be changed only at MAX nodes –beta can be changed only at MIN nodes –Pruning occurs whenever alpha >= beta alpha cutoff: –Given a Max node n, cutoff the search below n (i.e., don't generate any more of n's children) if alpha(n) >= beta(n) (alpha increases and passes beta from below) beta cutoff: –Given a Min node n, cutoff the search below n (i.e., don't generate any more of n's children) if beta(n) <= alpha(n) (beta decreases and passes alpha from above)

Game Playing: Adversarial Search function ALPHA-BETA-SEARCH(state) returns an action inputs: state, current state in game v← MAX-VALUE(state, - ∞, +∞) return the action in SUCCESSORS(state) with value v function MAX-value (n, alpha, beta) return utility value if n is a leaf node then return f(n); for each child n’ of n do alpha :=max{alpha, MIN-value(n’, alpha, beta)}; if alpha >= beta then return beta /* pruning */ end{do} return alpha function MIN-value (n, alpha, beta) return utility value if n is a leaf node then return f(n); for each child n’ of n do beta :=min{beta, MAX-value(n’, alpha, beta)}; if beta <= alpha then return alpha /* pruning */ end{do} return beta

Game Playing: Adversarial Search Slides of example from screenshots by Mikael Bodén, Halmstad University, Sweden found at

Game Playing: Adversarial Search

In another way

Game Playing: Adversarial Search Evaluating Alpha-Beta algorithm  Alpha-Beta is guaranteed to compute the same value for the root node as computed by Minimax.  Worst case: NO pruning, examining O(b d ) leaf nodes, where each node has b children and a d-ply search is performed  Best case: examine only O(b d/2 ) leaf nodes. You can search twice as deep as Minimax! Or the branch factor is b 1/2 rather than b.  Best case is when each player's best move is the leftmost alternative, i.e. at MAX nodes the child with the largest value generated first, and at MIN nodes the child with the smallest value generated first.  In Deep Blue, they found empirically that Alpha-Beta pruning meant that the average branching factor at each node was about 6 instead of about 35-40

Game Playing: Adversarial Search Summary  A game can be defined by the initial state, the operators (legal moves), a terminal test and a utility function (outcome of the game).  In two player game, the minimax algorithm can determine the best move by enumerating the entire game tree.  The alpha-beta pruning algorithm produces the same result but is more efficient because it prunes away irrelevant branches.  Usually, it is not feasible to construct the complete game tree, so the utility value of some states must be determined by an evaluation function.

Trace α- β pruning algorithm given the following game tree.

3