Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.

Slides:



Advertisements
Similar presentations
Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
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.
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.
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
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 Chapter 6.
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,
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
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.
Artificial Intelligence in Game Design
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.
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 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.
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
Adversarial Search and Game Playing Examples. Game Tree MAX’s play  MIN’s play  Terminal state (win for MAX)  Here, symmetries have been used to reduce.
Alpha-Beta Search. 2 Two-player games The object of a search is to find a path from the starting position to a goal position In a puzzle-type problem,
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
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.
CHAPTER 6 : 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 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
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
For Wednesday Read Weiss, chapter 12, section 2 Homework: –Weiss, chapter 10, exercise 36 Program 5 due.
For Friday Finish reading chapter 7 Homework: –Chapter 6, exercises 1 (all) and 3 (a-c only)
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.
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.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
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.
Game Playing: Adversarial Search chapter 5. Game Playing: Adversarial Search  Introduction  So far, in problem solving, single agent search  The machine.
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.
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.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
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
Last time: search strategies
Iterative Deepening A*
PENGANTAR INTELIJENSIA BUATAN (64A614)
CS 460 Spring 2011 Lecture 4.
Artificial Intelligence
Game playing.
Artificial Intelligence
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Adversarial Search CMPT 420 / CMPG 720.
Unit II Game Playing.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni

Planning ahead in a world that includes a hostile agent Games as search problems Idealization and simplification: –Two players –Alternate moves MAX player MIN player –Available information: Perfect: chess, chequers, tic-tac-toe… (no chance, same knowledge for the two players) Imperfect: poker, Stratego, bridge…

Game representation In the general case of a game with two players: –General state representation –Initial-state definition –Winning-state representation as: Structure Properties Utility function –Definition of a set of operators

Search with an opponent

Trivial approximation: generating the tree for all moves Terminal moves are tagged with a utility value, for example: “+1” or “-1” depending on if the winner is MAX or MIN. The goal is to find a path to a winning state. Even if a depth-first search would minimize memory space, in complex games this kind of search cannot be carried out. Even a simple game like tic-tac-toe is too complex to draw the entire game tree.

Search with an opponent

Heuristic approximation: defining an evaluation function which indicates how close a state is from a winning (or losing) move This function includes domain information. It does not represent a cost or a distance in steps. Conventionally: –A winning move is represented by the value“+∞”. –A losing move is represented by the value “-∞”. –The algorithm searches with limited depth. Each new decision implies repeating part of the search.

Minimax Minimax-value(n): utility for MAX of being in state n, assuming both players are playing optimally = –Utility(n),if n is a terminal state –max s ∈ Successors(n) Minimax-value(s),if n is a MAX state –min s ∈ Successors(n) Minimax-value(s), if n is a MIN state

Example: tic-tac-toe e (evaluation function → integer) = number of available rows, columns, diagonals for MAX - number of available rows, columns, diagonals for MIN MAX plays with “X” and desires maximizing e. MIN plays with “0” and desires minimizing e. Symmetries are taken into account. A depth limit is used (2, in the example).

Example: tic-tac-toe

14 The minimax algorithm The minimax algorithm computes the minimax decision from the current state. It uses a simple recursive computation of the minimax values of each successor state: –directly implementing the defining equations. The recursion proceeds all the way down to the leaves of the tree. Then the minimax values are backed up through the tree as the recursion unwinds. 14

15 The minimax algorithm 15

16 The minimax algorithm 16

17 The minimax algorithm

18 The minimax algorithm The algorithm first recurses down to the tree bottom-left nodes –and uses the Utility function on them to discover that their values are 3, 12 and 8. 18

19 The minimax algorithm Then it takes the minimum of these values, 3, and returns it as the backed-up value of node B. Similar process for the other nodes. 19 B A

20 The minimax algorithm The minimax algorithm performs a complete depth-first exploration of the game tree. In minimax, at each point in the process, only the nodes along a path of the tree are considered and kept in memory. 20

21 The minimax algorithm If the maximum depth of the tree is m, and there are b legal moves at each point, then the time complexity is O(b m ). The space complexity is: –O(bm) for an algorithm that generates all successors at once –O(m) if it generates successors one at a time. 21

22 The minimax algorithm: problems For real games the time cost of minimax is totally impractical, but this algorithm serves as the basis: –for the mathematical analysis of games and –for more practical algorithms Problem with minimax search: –The number of game states it has to examine is exponential in the number of moves. Unfortunately, the exponent can’t be eliminated, but it can be cut in half. 22

23 Alpha-beta pruning It is possible to compute the correct minimax decision without looking at every node in the game tree. Alpha-beta pruning allows to eliminate large parts of the tree from consideration, without influencing the final decision. 23

The leaves below B have the values 3, 12 and 8. The value of B is exactly 3. It can be inferred that the value at the root is at least 3, because MAX has a choice worth B Alpha-beta pruning 24

C, which is a MIN node, has a value of at most 2. But B is worth 3, so MAX would never choose C. Therefore, there is no point in looking at the other successors of C. 25 Alpha-beta pruning 25 BC

D, which is a MIN node, is worth at most 14. This is still higher than MAX’s best alternative (i.e., 3), so D’s other successors are explored. 26 Alpha-beta pruning 26 BCD

27 The second successor of D is worth 5, so the exploration continues. Alpha-beta pruning 27 BCD

28 The third successor is worth 2, so now D is worth exactly 2. MAX’s decision at the root is to move to B, giving a value of 3 Alpha-beta pruning 28 BCD

29 Alpha-beta pruning Alpha-beta pruning gets its name from two parameters. –They describe bounds on the values that appear anywhere along the path under consideration: α = the value of the best (i.e., highest value) choice found so far along the path for MAX β = the value of the best (i.e., lowest value) choice found so far along the path for MIN 29

30 Alpha-beta pruning Alpha-beta search updates the values of α and β as it goes along. It prunes the remaining branches at a node (i.e., terminates the recursive call) –as soon as the value of the current node is known to be worse than the current α or β value for MAX or MIN, respectively. 30

31 The alpha-beta search algorithm

32 The alpha-beta search algorithm

MAX ViVi {α, β} If V i > α, modify α If Vi ≥ β, β pruning Return α {α, β} If V i < β, modify β If Vi ≤ α, α pruning Return β MIN ViVi α and β bounds are transmitted from parent to child in the order of node visit. The effectiveness of pruning highly depends on the order in which successors are examined. Alpha-beta pruning

The I subtree can be pruned, because I is a min node and the value of v(K) = 0 is < α = 3 A CB ED 3 {-∞, +∞} A CB ED {-∞, 3} A CB D 3 HF {3, +∞} G JI LK 0 {alpha = -∞, beta = +∞} {-∞, 3} {-∞, +∞} {3, +∞}

The G subtree can be pruned, because G is a max node and the value of v(M) = 7 is > β = 5 AC B D 3 HF {3, +∞} GJ 5 5 A C BD 3 HF GJ {3, 5} 5 5 NM 7 A C BD 3 HF 4 J

36 Final comments about alpha- beta pruning Pruning does not affect final results. Entire subtrees can be pruned, not just leaves. Good move ordering improves effectiveness of pruning. With perfect ordering, time complexity is O(b m/2 ). –Effective branching factor of sqrt(b) –Consequence: alpha-beta pruning can look twice as deep as minimax in the same amount of time. 36