1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides: www.cs.berkeley.edu/~wilensky/cs188/lectures/index.html.

Slides:



Advertisements
Similar presentations
Adversarial Search Chapter 6 Sections 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
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
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.
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
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.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
Adversarial Search Chapter 6.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
EIE426-AICV 1 Game Playing Filename: eie426-game-playing-0809.ppt.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
State Space 4 Chapter 4 Adversarial Games. Two Flavors Games of Perfect Information ◦Each player knows everything that can be known ◦Chess, Othello Games.
This time: Outline Game playing The minimax algorithm
Lecture 02 – Part C Game Playing: Adversarial Search
1 Heuristic Search 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games.
Game Playing CSC361 AI CSC361: Game Playing.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.6: Adversarial Search Fall 2008 Marco Valtorta.
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 Heuristic Search 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games.
1 DCP 1172 Introduction to Artificial Intelligence Lecture notes for Chap. 6 [AIMA] Chang-Sheng Chen.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
1 Heuristic Search 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games.
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
Games & Adversarial Search Chapter 6 Section 1 – 4.
HEURISTIC SEARCH. Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005 Portion of the state space for tic-tac-toe.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Notes adapted from lecture notes for CMSC 421 by B.J. Dorr
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. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
Game Playing.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
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.
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 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.
Game Playing: Adversarial Search chapter 5. Game Playing: Adversarial Search  Introduction  So far, in problem solving, single agent search  The machine.
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search Chapter 5 Sections 1 – 4. AI & Expert Systems© Dr. Khalid Kaabneh, AAU Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
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.
Artificial Intelligence AIMA §5: Adversarial Search
Game Playing Why do AI researchers study game playing?
PENGANTAR INTELIJENSIA BUATAN (64A614)
CS 460 Spring 2011 Lecture 4.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search.
Game playing.
Games & Adversarial Search
Games & Adversarial Search
Game Playing Fifth Lecture 2019/4/11.
Adversarial Search CMPT 420 / CMPG 720.
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Presentation transcript:

1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides: Tim Huang’s slides for the game of Go.

2 Game playing Games have always been an important application area for heuristic algorithms. The games that we will look at in this course will be two-person board games such as Tic-tac-toe, Chess, or Go.

3 Types of Games DeterministicChance Perfect information Chess, Checkers Go, Othello Backgammon Monopoly Imperfect Information Battleships Blind tictactoe Bridge, Poker, Scrabble, Nuclear War

4 Tic-tac-toe state space reduced by symmetry (2-player, deterministic, turns)

5 A variant of the game nim A number of tokens are placed on a table between the two opponents A move consists of dividing a pile of tokens into two nonempty piles of different sizes For example, 6 tokens can be divided into piles of 5 and 1 or 4 and 2, but not 3 and 3 The first player who can no longer make a move loses the game For a reasonable number of tokens, the state space can be exhaustively searched

6 State space for a variant of nim

7 Exhaustive minimax for the game of nim

8 Two people games One of the earliest AI applications Several programs that compete with the best human players:  Checkers: beat the human world champion  Chess: beat the human world champion  Backgammon: at the level of the top handful of humans  Go: no competitive programs (? In 2008)  Othello: good programs  Hex: good programs

9 Search techniques for 2-person games The search tree is slightly different: It is a two-ply tree where levels alternate between players Canonically, the first level is “us” or the player whom we want to win. Each final position is assigned a payoff:  win (say, 1)  lose (say, -1)  draw (say, 0) We would like to maximize the payoff for the first player, hence the names MAX & MINIMAX

10 The search algorithm The root of the tree is the current board position, it is MAX’s turn to play MAX generates the tree as much as it can, and picks the best move assuming that Min will also choose the moves for herself. This is the Minimax algorithm which was invented by Von Neumann and Morgenstern in 1944, as part of game theory. The same problem with other search trees: the tree grows very quickly, exhaustive search is usually impossible.

11 Minimax Perfect play for deterministic, perfect information games Idea: choose to move to the position with the highest mimimax value Best achievable payoff against best play

12 Minimax applied to a hypothetical state space (Luger Fig. 4.15)

13 Minimax algorithm Function Minimax-Decision(state) returns an action inputs: state, current state in game return the a in Actions(state) maximizing MIN-VALUE(RESULT(a,state))

14 Max-value algorithm Function MAX-VALUE(state) returns a utility value inputs: state, current state in game if TERMINAL-TEST(state) then return UTILITY(state) v← -∞ for each in SUCCESSORS(state) do v ← MAX(v, MIN-VALUE(s)) return v

15 Min-value algorithm Function MIN-VALUE(state) returns a utility value inputs: state, current state in game if TERMINAL-TEST(state) then return UTILITY(state) v← ∞ for each in SUCCESSORS(state) do v ← MIN(v, MAX-VALUE(s)) return v

16 Properties of minimax Complete: Yes, if the tree is finite (chess has specific rules for this) Optimal: Yes, against an optimal opponent Otherwise? Time complexity: O(b m ) Space complexity: O(bm) (depth-first exploration) For chess, b ≈ 35, m ≈ 100 for “reasonable” games exact solution is completely infeasible But do we need to explore every path?

17 Using the Minimax algorithm MAX generates the full search tree (up to the leaves or terminal nodes or final game positions) and chooses the best one: win or tie To choose the best move, values are propogated upward from the leaves:  MAX chooses the maximum  MIN chooses the minimum This assumes that the full tree is not prohibitively big It also assumes that the final positions are easily identifiable We can make these assumptions for now, so let’s look at an example

18 Two-ply minimax applied to X’s move near the end of the game (Nilsson, 1971)

19 Using cut-off points Notice that the tree was not generated to full depth in the previous example When time or space is tight, we can’t search exhaustively so we need to implement a cut-off point and simply not expand the tree below the nodes who are at the cut-off level. But now the leaf nodes are not final positions but we still need to evaluate them: use heuristics We can use a variant of the “most wins” heuristic

20 Heuristic measuring conflict

21 Calculation of the heuristic E(n) = M(n) – O(n) where  M(n) is the total of My (MAX) possible winning lines  O(n) is the total of Opponent’s (MIN) possible winning lines  E(n) is the total evaluation for state n Take another look at the previous example Also look at the next two examples which use a cut-off level (a.k.a. search horizon) of 2 levels

22 Two-ply minimax applied to the opening move of tic-tac-toe (Nilsson, 1971)

23 Two-ply minimax and one of two possible second MAX moves (Nilsson, 1971)

24 Pruning the search tree The technique is called alpha-beta pruning Basic idea: if a portion of the tree is obviously good (bad) don’t explore further to see how terrific (awful) it is Remember that the values are propagated upward. Highest value is selected at MAX’s level, lowest value is selected at MIN’s level Call the values at MAX levels α values, and the values at MIN levels β values

25 The rules Search can be stopped below any MIN node having a beta value less than or equal to the alpha value of any of its MAX ancestors Search can be stopped below any MAX node having an alpha value greater than or equal to the beta value of any of its MIN node ancestors

26 Example with MAX MAX MIN 3 45 β=3β=3β≤2β≤2 2 As soon as the node with value 2 is generated, we know that the beta value will be less than 3, we don’t need to generate these nodes (and the subtree below them) α ≥ 3α ≥ 3 (Some of) these still need to be looked at

27 Example with MIN MIN MAX 3 45 α=5α=5α≥6α≥6 6 As soon as the node with value 6 is generated, we know that the alpha value will be larger than 6, we don’t need to generate these nodes (and the subtree below them) β ≤ 5β ≤ 5 (Some of) these still need to be looked at

28 Alpha-beta pruning applied to the state space of Fig. 4.15

29 Properties of α-β Pruning does not affect final result Good move ordering improves effectiveness of pruning With “perfect ordering,” doubles solvable depth time complexity = O(b m/2 ) A simple example of the value of reasoning about which computations are relevant (a form of metareasoning) Unfortunately, is still impossible!

30 Number of nodes generated as a function of branching factor B, and solution length L (Nilsson, 1980)

31 Informal plot of cost of searching and cost of computing heuristic evaluation against heuristic informedness (Nilsson, 1980)

32 Summary Games are fun to work on! (and dangerous) They illustrate several important points about AI perfection is unattainable (must approximate) good idea to think about what to think about expanding the ideas to uncertain situations (games) with imperfect information, optimal decisions depend on information state, not real state