159.3021 Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.

Slides:



Advertisements
Similar presentations
Chapter 6, Sec Adversarial Search.
Advertisements

Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
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.
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.
Adversarial Search CSE 473 University of Washington.
Hoe schaakt een computer? Arnold Meijster. Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Lecture 13 Last time: Games, minimax, alpha-beta Today: Finish off games, summary.
This time: Outline Game playing The minimax algorithm
Lecture 02 – Part C Game Playing: Adversarial Search
CS 561, Sessions Administrativia Assignment 1 due tuesday 9/24/2002 BEFORE midnight Midterm exam 10/10/2002.
1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides:
CS 561, Sessions Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first.
Game Playing CSC361 AI CSC361: Game Playing.
Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.
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)
1 DCP 1172 Introduction to Artificial Intelligence Lecture notes for Chap. 6 [AIMA] Chang-Sheng Chen.
CS 460, Sessions Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first.
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”
ICS-270a:Notes 5: 1 Notes 5: Game-Playing ICS 270a Winter 2003.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
PSU CS 370 – Introduction to Artificial Intelligence Game MinMax Alpha-Beta.
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.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
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.
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
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.
For Wednesday Read Weiss, chapter 12, section 2 Homework: –Weiss, chapter 10, exercise 36 Program 5 due.
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.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Game Playing Revision Mini-Max search Alpha-Beta pruning General concerns on games.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Game Playing: Adversarial Search chapter 5. Game Playing: Adversarial Search  Introduction  So far, in problem solving, single agent search  The machine.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search In this lecture, we introduce a new search scenario: game playing 1.two players, 2.zero-sum game, (win-lose, lose-win, draw) 3.perfect.
Chapter 5 Adversarial Search. 5.1 Games Why Study Game Playing? Games allow us to experiment with easier versions of real-world situations Hostile agents.
Artificial Intelligence AIMA §5: Adversarial Search
Adversarial Search and Game-Playing
Last time: search strategies
Iterative Deepening A*
PENGANTAR INTELIJENSIA BUATAN (64A614)
Game Playing.
Games & Adversarial Search
Chapter 6 : Game Search 게임 탐색 (Adversarial Search)
Games & Adversarial Search
Games & Adversarial Search
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Mini-Max search Alpha-Beta pruning General concerns on games
Games & Adversarial Search
Games & Adversarial Search
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing

Types of Games Bridge, Poker, Scrabble Battleships Backgammon, Monopoly Chess, Checkers,Go Deterministic Chance Perfect Information Imperfect Information

Two player game Two players: MAX and MIN MAX moves first and they take turns until the game is over. Properties Initial state: e.g. board configuration of chess Successor function: list of (move,state) pairs specifying legal moves. Terminal test: Is the game finished? Utility function: Gives numerical value of terminal states. E.g. win (+1), loose (-1) and draw (0) MAX uses a search tree to determine next move.

Game tree for noughts and crosses

What is the Optimal Strategy? Assume MIN plays perfectly for each node assign a value given by: the utility function if it is a terminal node the minimum of the successor nodes if it is a min node the maximum of the successor nodes if it is a max node

Minimax Algorithm For each move by the computer 1. Perform depth-first search as far as the terminal state 2. Assign utilities at each terminal state 3. Propagate upwards the minimax choices If the parent is a minimizer (opponent) Propagate up the minimum value of the children If the parent is a maximizer (computer) Propagate up the maximum value of the children 4. Choose the move (the child of the current node) corresponding to the maximum of the minimax values of the children

Minimax Algorithm int MINIMAX(N) { if N is a leaf then return the score of this leaf else Let N 1, N 2,.., N m be the successors of N; if N is a Min node then return min{MINIMAX(N 1 ),.., MINIMAX(N m )} else return max{MINIMAX(N 1 ),.., MINIMAX(N m )} }

Example

A Real Game Start with a stack of coins Each player divides one of the current stacks into two unequal stacks (one having more coins than the other). The game ends when every stack contains one or two coins The first player who cannot play loses.

Game Tree 7 6, 15, 2 4, 3 3, 2, 2 3, 3, 1 Min’s turn 5, 1, 14, 2, 1 Max’s turn 4, 1, 1, 1 3, 2, 1, 1 Max’s turn Min’s turn Max’s turn 3, 1, 1, 1, 1 2, 1, 1, 1, 1, 1 MAX Loses Min’s turn 2, 2, 2, 1 MAX Loses 2, 2, 1, 1, 1 Min Loses

Complexity Time Complexity O(b m ) Space Complexity O(bm) Where b is the branching factor and m is the maximum depth For chess b=35, m=100 approximately, this is not feasible

Evaluation functions Not often practical to search all the way to the terminal states. Use a heuristic evaluation function to estimate which moves lead to better terminal states. A cutoff test must be used to limit the search. Choosing a good evaluation function is very important to the efficiency of this method. The evaluation function must agree with the utility function for terminal states and it must be a good predictor of the terminal values. If the evaluation function is infallible then no search is necessary, just choose the move that gives the best position. The better the evaluation function the less search need to be done.

Cutting off Search Fixed depth OK, if we know how long it will take to evaluate the tree. Iterative deepening Good if there is a time limit, just keep going until time is up and use best so far.

Can we do better? Yes mimimax examines some branches that are already known to be bad. Alpha-Beta pruning keep a track of the best and worst values (alpha and beta) if one of the successors of a min node is worse than the best so far, go no further. If one of the successors of a max node is better than the worst so far, go no further.

Alpha-Beta Algorithm int MAX-VALUE (state, alpha, beta) { if CUTOFF-TEST (state) then return EVAL (state) v=-MAXVAL for each s in SUCCESSORS (state) { v = MAX (v, MIN-VALUE (s,alpha,beta)) if(v>=beta) return v if(v>alpha) alpha=v } return v } int MIN-VALUE (state, alpha, beta) { if CUTOFF-TEST (state) then return EVAL (state) v=MAXVAL for each s in SUCCESSORS (state) { v = MIN (v, MAX-VALUE (s,alpha, beta)) if (v<=alpha) return v if (v<beta) beta=v } return v }

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Alpha-Beta Pruning

Effectiveness of alpha-beta pruning. What are the maximum savings possible? Suppose the tree is ordered as follows: ^ ____________________________o____________________________ / | \ v ________o________ _______o________ ________o________ / | \ / | \ / | \ ^ o o o o o o o o o / | \ / | \ / | \ / | \ / | \ / | \ / | \ / | \ / | \ * * * * * * * * * * * Only those nodes marked (*) need be evaluated. How many static evaluations are needed?. If b is the branching factor (3 above) and d is the depth (3 above) s = 2b d/2 - 1 IF d is even s = b (d+1)/2 + b (d-1)/2 - 1 IF d is odd

Effectiveness of alpha-beta pruning. For our tree d=3, b=3 and so s=11. This is only for the perfectly arranged tree. It gives a lower bound on the number of evaluations of approximately 2 bd/2.The worst case is b d (minimax) In practice, for reasonable games, the complexity is O(b 3d/4 ). Using minimax with alpha beta pruning allows us to look ahead about half as far again as without.