ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
This lecture topic: Game-Playing & Adversarial Search
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
1 CSC 550: Introduction to Artificial Intelligence Fall 2008 search in game playing  zero-sum games  game trees, minimax principle  alpha-beta pruning.
University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.
Adversarial Search Chapter 5.
Game-Playing & Adversarial Search
COMP-4640: Intelligent & Interactive Systems Game Playing A game can be formally defined as a search problem with: -An initial state -a set of operators.
Adversarial Search: Game Playing Reading: Chapter next time.
ICS-171:Notes 6: 1 Notes 6: Two-Player Games and Search ICS 171 Winter 2001.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
Artificial Intelligence for Games Game playing Patrick Olivier
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
Two-player games overview Computer programs which play 2-player games – –game-playing as search – –with the complication of an opponent General principles.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Artificial Intelligence in Game Design
This time: Outline Game playing The minimax algorithm
Chapter 6 : Game Search 게임 탐색 (Adversarial Search)
Lecture 02 – Part C Game Playing: Adversarial Search
Game-Playing & Adversarial Search Alpha-Beta Pruning, etc. This lecture topic: Game-Playing & Adversarial Search (Alpha-Beta Pruning, etc.) Read Chapter.
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”
ICS-270a:Notes 5: 1 Notes 5: Game-Playing ICS 270a Winter 2003.
Game Playing State-of-the-Art  Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used an endgame database defining.
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.
CSC 412: AI Adversarial Search
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
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.
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.
Announcements (1) Cancelled: –Homework #2 problem 4.d, and Mid-term problems 9.d & 9.e & 9.h. –Everybody gets them right, regardless of your actual answers.
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.
Game Playing. Introduction One of the earliest areas in artificial intelligence is game playing. Two-person zero-sum game. Games for which the state space.
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.
Game-Playing & Adversarial Search Alpha-Beta Pruning, etc. This lecture topic: Game-Playing & Adversarial Search (Alpha-Beta Pruning, etc.) Read Chapter.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
CMSC 421: Intro to Artificial Intelligence October 6, 2003 Lecture 7: Games Professor: Bonnie J. Dorr TA: Nate Waisbrot.
Adversarial Search 2 (Game Playing)
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
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.
Adversarial Search and Game-Playing
Games and Adversarial Search
Game-Playing & Adversarial Search
PENGANTAR INTELIJENSIA BUATAN (64A614)
Pengantar Kecerdasan Buatan
Games & Adversarial Search
Games & Adversarial Search
Game playing.
Chapter 6 : Game Search 게임 탐색 (Adversarial Search)
Games & Adversarial Search
Games & Adversarial Search
Notes 6: Two-Player Games and Search
Games & Adversarial Search
Games & Adversarial Search
Presentation transcript:

ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008

ICS-271:Notes 6: 2 Overview Computer programs which play 2-player games –game-playing as search –with the complication of an opponent General principles of game-playing and search –evaluation functions –minimax principle –alpha-beta-pruning –heuristic techniques Status of Game-Playing Systems –in chess, checkers, backgammon, Othello, etc, computers routinely defeat leading world players Applications? –think of “nature” as an opponent –economics, war-gaming, medical drug treatment

ICS-271:Notes 6: 3 Solving 2-players Games Two players, perfect information Examples: e.g., chess, checkers, tic-tac-toe Configuration of the board = unique arrangement of “pieces” Statement of Game as a Search Problem: –States = board configurations –Operators = legal moves –Initial State = current configuration –Goal = winning configuration –payoff function = gives numerical value of outcome of the game A working example: Grundy's game –Given a set of coins, a player takes a set and divides it into two unequal sets. The player who plays last, looses. –What is a state? Moves? Goal?

ICS-271:Notes 6: 4 Grundy’s game - special case of nim

ICS-271:Notes 6: 5

ICS-271:Notes 6: 6 Game Trees: Tic-tac-toe

ICS-271:Notes 6: 7 Game Trees

ICS-271:Notes 6: 8 An optimal procedure: The Min-Max method Designed to find the optimal strategy for Max and find best move: –1. Generate the whole game tree to leaves –2. Apply utility (payoff) function to leaves –3. Back-up values from leaves toward the root: a Max node computes the max of its child values a Min node computes the Min of its child values –4. When value reaches the root: choose max value and the corresponding move.

ICS-271:Notes 6: 9 Properties of minimax Complete? –Yes (if tree is finite) Optimal? –Yes (against an optimal opponent) Time complexity? O(b m ) Space complexity? O(bm) (depth-first exploration) For chess, b ≈ 35, m ≈100 for "reasonable" games  exact solution completely infeasible –Chess: b ~ 35 (average branching factor) d ~ 100 (depth of game tree for typical game) b d ~ ~ nodes!! –Tic-Tac-Toe ~5 legal moves, total of 9 moves 5 9 = 1,953,125 9! = 362,880 (Computer goes first) 8! = 40,320 (Computer goes second)

ICS-271:Notes 6: 10 An optimal procedure: The Min-Max method Designed to find the optimal strategy for Max and find best move: –1. Generate the whole game tree to leaves –2. Apply utility (payoff) function to leaves –3. Back-up values from leaves toward the root: a Max node computes the max of its child values a Min node computes the Min of its child values –4. When value reaches the root: choose max value and the corresponding move. However: It is impossible to develop the whole search tree. Instead develop part of the tree and evaluate promise of leaves using a static evaluation function.

ICS-271:Notes 6: 11 Static (Heuristic) Evaluation Functions An Evaluation Function: –Estimates how good the current board configuration is for a player. –Typically, one figures how good it is for the player, and how good it is for the opponent, and subtracts the opponents score from the player. –Othello: Number of white pieces - Number of black pieces –Chess: Value of all white pieces - Value of all black pieces Typical values from -infinity (loss) to +infinity (win) or [-1, +1]. If the board evaluation is X for a player, it’s -X for the opponent Example: –Evaluating chess boards, –Checkers –Tic-tac-toe

ICS-271:Notes 6: 12

ICS-271:Notes 6: 13 Deeper Game Trees

ICS-271:Notes 6: 14

ICS-271:Notes 6: 15 Applying MiniMax to tic-tac-toe The static evaluation function heuristic

ICS-271:Notes 6: 16 Backup Values

ICS-271:Notes 6: 17

ICS-271:Notes 6: 18

ICS-271:Notes 6: 19

ICS-271:Notes 6: 20 Pruning with Alpha/Beta In Min-Max there is a separation between node generation and evaluation. Backup Values

ICS-271:Notes 6: 21 Alpha Beta Procedure Idea: –Do depth first search to generate partial game tree, –Give static evaluation function to leaves, –Compute bound on internal nodes. Alpha, Beta bounds: –Alpha value for max node means that max real value is at least alpha. –Beta for min node means that min can guarantee a value below beta. Computation: –Alpha of a max node is the maximum value of its seen children. –Beta of a min node is the minimum value seen of its child node.

ICS-271:Notes 6: 22 When to Prune Pruning –Below a Min node whose beta value is lower than or equal to the alpha value of its ancestors. –Below a Max node having an alpha value greater than or equal to the beta value of any of its Min nodes ancestors.

ICS-271:Notes 6: 23

ICS-271:Notes 6: 24

ICS-271:Notes 6: 25

ICS-271:Notes 6: 26

ICS-271:Notes 6: 27

ICS-271:Notes 6: 28 Effectiveness of Alpha-Beta Search Worst-Case –Branches are ordered so that no pruning takes place. In this case alpha-beta gives no improvement over exhaustive search Best-Case –Each player’s best move is the left-most alternative (i.e., evaluated first) –In practice, performance is closer to best rather than worst-case In practice often get O(b (d/2) ) rather than O(b d ) –This is the same as having a branching factor of sqrt(b), since (sqrt(b)) d = b (d/2) (i.e., we have effectively gone from b to square root of b) –In chess go from b ~ 35 to b ~ 6 permiting much deeper search in the same amount of time

ICS-271:Notes 6: 29

ICS-271:Notes 6: 30 Iterative (Progressive) Deepening In real games, there is usually a time limit T on making a move How do we take this into account? using alpha-beta we cannot use “partial” results with any confidence unless the full breadth of the tree has been searched – So, we could be conservative and set a conservative depth-limit which guarantees that we will find a move in time < T disadvantage is that we may finish early, could do more search In practice, iterative deepening search (IDS) is used –IDS runs depth-first search with an increasing depth-limit –when the clock runs out we use the solution found at the previous depth limit

ICS-271:Notes 6: 31 Heuristics and Game Tree Search: limited horizon The Horizon Effect –sometimes there’s a major “effect” (such as a piece being captured) which is just “below” the depth to which the tree has been expanded. –the computer cannot see that this major event could happen because it has a “limited horizon”. –there are heuristics to try to follow certain branches more deeply to detect such important events –this helps to avoid catastrophic losses due to “short-sightedness” Heuristics for Tree Exploration –it may be better to explore some branches more deeply in the allotted time –various heuristics exist to identify “promising” branches

ICS-271:Notes 6: 32

ICS-271:Notes 6: 33

ICS-271:Notes 6: 34

ICS-271:Notes 6: 35

ICS-271:Notes 6: 36

ICS-271:Notes 6: 37

ICS-271:Notes 6: 38

ICS-271:Notes 6: 39

ICS-271:Notes 6: 40

ICS-271:Notes 6: 41

ICS-271:Notes 6: 42

ICS-271:Notes 6: 43 Summary Game playing is best modeled as a search problem Game trees represent alternate computer/opponent moves Evaluation functions estimate the quality of a given board configuration for the Max player. Minimax is a procedure which chooses moves by assuming that the opponent will always choose the move which is best for them Alpha-Beta is a procedure which can prune large parts of the search tree and allow search to go deeper For many well-known games, computer algorithms based on heuristic search match or out-perform human world experts. Reading:R&N Chapter 5.