Adversarial Games. Two Flavors  Perfect Information –everything that can be known is known –Chess, Othello  Imperfect Information –Player’s have each.

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.
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Game Playing Games require different search procedures. Basically they are based on generate and test philosophy. At one end, generator generates entire.
CS 484 – Artificial Intelligence
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
MINIMAX SEARCH AND ALPHA- BETA PRUNING: PLAYER 1 VS. PLAYER 2.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
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.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Artificial Intelligence in Game Design
State Space 4 Chapter 4 Adversarial Games. Two Flavors Games of Perfect Information ◦Each player knows everything that can be known ◦Chess, Othello Games.
Mahgul Gulzai Moomal Umer Rabail Hafeez
This time: Outline Game playing The minimax algorithm
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.
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)
Game-Playing Read Chapter 6 Adversarial Search. Game Types Two-person games vs multi-person –chess vs monopoly Perfect Information vs Imperfect –checkers.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Monotonicity Admissible Search: “That finds the shortest path to the Goal” Monotonicity: local admissibility is called MONOTONICITY This property ensures.
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.
Games & Adversarial Search Chapter 6 Section 1 – 4.
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 Read Chapter 6 Adversarial Search. State-Space Model Modified States the same Operators depend on whose turn Goal: As before: win or win.
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.
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.
KU NLP Heuristic Search Heuristic Search and Expert Systems (1) q An interesting approach to implementing heuristics is the use of confidence.
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.
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
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.
Adversarial Search and Game-Playing
Announcements Homework 1 Full assignment posted..
Last time: search strategies
Iterative Deepening A*
PENGANTAR INTELIJENSIA BUATAN (64A614)
Pengantar Kecerdasan Buatan
State Space 4 Chapter 4 Adversarial Games.
Game playing.
Alpha-Beta Search.
NIM - a two person game n objects are in one pile
Alpha-Beta Search.
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Alpha-Beta Search.
Alpha-Beta Search.
Mini-Max search Alpha-Beta pruning General concerns on games
Based on slides by: Rob Powers Ian Gent
Artificial Intelligence
Alpha-Beta Search.
Minimax strategies, alpha beta pruning
Unit II Game Playing.
Presentation transcript:

Adversarial Games

Two Flavors  Perfect Information –everything that can be known is known –Chess, Othello  Imperfect Information –Player’s have each have partial knowledge –Poker: dispute is settled by revealing the contents of one’s hand

Two Approaches to Perfect Information Games  Use simple heuristics and search many nodes  Use sophisticated heuristics and search few nodes Cost of calculating the heuristics might outweigh the cost of opening many nodes The closer h is to h*, the better informed it is. But information can be expensive

MiniMax on exhaustively searchable graphs Two Players  min: tries to achieve an outcome of 0  max: tries to achieve an outcome of 1

You are max at node A Expand the entire search space B A H F CD K G O E J N PQ R I LM MAX Max Min Max

Wins  Max: F,J,N,Q,L  Min: D,H,P,R,M Propagating Scores: A first pass  Min’s Turn a Node I –Go to M to win –So assign I a 0  Max’s turn at node O –Go to Q to win –So assign 1 to node O

Conclusion 1. If faced with two labeled choices, you would choose 0 (if min) or 1 (if max) 2. Assume you’re opponent will play the same way

Propagating Scores For each unlabeled node in the tree  If it’s max’s turn, give it the max score of its children  If it’s min’s turn, give it the min score of its children Now label the tree Conclusion: Max must choose C at the first move or lose the game

Nim  7 coins  2 players  Players divide coins into two piles at each move, such that –Piles have an unequal number of coins –No pile is empty  Play ends when a player can no longer move

Start of Game 7 6,1 5,2 4,3 min Complete the game to see that min wins only if max makes a mistake at 6,1 or 5,2 5,1,1 4,2,1

α-β Pruning Problem  For games of any complexity, you can’t search the whole tree Solution  Look ahead a fixed number of plys (levels)  Evaluate according to some heuristic estimate  Develop a criterion for pruning subtrees that don’t require examination

Recast Instead of representing wins, numbers represent the relative goodness of nodes. At any junction  Max chooses highest  Min chooses lowest Higher means better for max Lower means better for min

Example: Max’s Turn j mz g k n t pq r Max Min Alpha beta

Situation Max’s turn at node g  Left subtree of g has been explored  If max chooses j, min will choose m  So the best max can do by going left is 8. Call this α Now Examine K and its left subtree n with a value of 4  If max chooses k, the worst min can do is 4.  Because, T may be < 4. If it is min will choose it. If not, min will choose 4  So the worst min can do, if max goes right is 4. Call this β

Question Should max expand the right subtree of k. No. Because min is guaranteed 4. But if max chose j, min is only guaranteed 8. Val(k) = min(4, val(t)) <= 4 Val(g) = max(8,val(k)) = max(8, min(4,val(t)) = max(8, min(4,val(t)) = 8 = 8

Leads to Max Principle Search can be stopped below any min node where β <= α of its max ancestor

Example: Min’s Turn n de k t pqr min Min alpha Beta

Situation Min’s turn at node k  Left subtree of k has been explored  If min chooses n, max will choose d  So the best min can do by going left is 4. Call this β Now examine T and its left subtree P with a value of 7  If min chooses T, the worst max can do is 7.  Because, Q or R may be > 7. If it is Max will choose it. If not, min will choose 7.  So the worst max can do, if min goes right is 7. Call this α

Question  Should min explore Q and R  No  Max is guaranteed 7 if min chooses T  But if min chooses N, max gets only 4  Val(T) = max(7,val(Q), val(R)) >= 7  Val(k) = min(4,val(T)) = 4

Leads to min principle Search can be stopped below any max node where α >= β of its min ancestor

To Summarize  Max’s turn –β is min’s guaranteed score (the worst min can do) –α is best max can do  Max principle –Search can be stopped below any min node where β <= α of its max ancestor  Min’s turn –α is max’s guaranteed score (the worst max can do) –β is best min can do  Min principle –Search can be stopped below any max node where α >= β of its min ancestor

Efficiency  Suppose a tree has depth, D, and branching factor B D = 2, B = 2: Terminal Nodes = 2 2 In general, Terminal Nodes = B D

Ordering  Ordering of nodes in a tree clearly affects the number than can be pruned using alpha/beta.  Call N D the number of terminal nodes  Can be shown that with alpha/beta best case performance is: N D = 2B D/2 – 1 for even D N D = 2B (D+1)/2 + B (D-1)/2 for odd D

Example Suppose B = 5, D = 6 w/out alpha/beta N D = 5 6 = w/alpha/beta N D = 2* = 249 Approx. 1.6% of worst case

Reduction in Branching Factor

Average Performance On average, the peformance reduces B to B 3/4 Suppose B = 5, B ab = 3.34 Suppose D = 6 Then N D = 5 6 = N DAB = = 1388 ≈ 8.8% of worst case

Combinatorial Explosion  Key Idea: branching factor makes optimal solution intranctable –Sum of Subsets Problem  2 –Traveling Salesperson  (N + 1)/2 –8 puzzle  2.67 –15 puzzle  Approximately 4 Let B = average branching factor Let T = total nodes Let D = depth of search Then T = B + B 2 + B 3 + … + B D = B(B D – 1)/(B – 1) + 1

Sum of Subsets Given a set, S, of positive integers, find all subsets whose sum is m. E.G. S = {7,11,13,24} m = 31 Solutions S-1 = {7,11,13} S-2 = {7,24}

Problem Representation Solution is a sequence of 1s and 0s, indicating that elements of S have been chosen or not. Rep of S-1 (1,1,1,0) Rep of S-2 (1,0,0,1) State space is a tree where left turn indicates a 1 and right turn indicates a 0

Partial Space S-1 Three left turns and a right turn to get to S-1 is the sequence (1,1,1,0) Clearly the branching factor is 2

TSP Can also be represented as a state space search. Suppose 4 cities 4 Choices at level 0 3 Choices at level 1 2 Choices at level 2 1 Choice at level 3 T = 4*3*2*1 = 4 P 4 = 4!/(4-4)! = 4!

Branching Factor B_F = (sum of choices at each level)/#of levels = ( )/4 = 2.5 = ( )/4 = 2.5 Clearly this increases with the size of the tour: (1+2+3+…+n)/n = (n(n+1)/2)/n = (n+1)/2

Relationship between branching factor and nodes in the tree Whenever the branching factor >= 2, we have an exponentially complex problem Let T = number of nodes in a full binary tree T = … + 2 d-1 = 2 d – 1 Easily proved through induction

Replace 2 by branching factor, B T = B 0 +B 1 + B 2 + … + B L = B(B L -1)/(B-1) + 1 = B(B L -1)/(B-1) + 1 Where L is d-1, d being the depth of the tree Proof Basis: T = B(B 0 – 1)/(B-1) + 1 = 1 Inductive hypothesis: T = B 0 +B 1 + B 2 + … + B L = B(B L -1)/(B-1) + 1

Show that this is true at level L+1 That is, Show = B 0 +B 1 + B 2 + … + B L+1 = B(B L+1 -1)/(B-1) + 1 B 0 +B 1 + B 2 + … + B L + B L+1 = B(B L -1)/(B-1) + B L = (B(B L -1) + B L+1 (B-1))/(B-1) + 1 %common D = (B( (B L -1) + B L (B-1))/(B-1) + 1 %factor B out = (B(B L -1 + B L+1 –B L )/(B-1) + 1 %multiply b = B(B L+1 -1)/(B-1) + 1 %subtract Which is what we were trying to prove

Two Concepts 1. B – average number of descendents that emerge from any state in the space 2. Total nodes = B(B L -1)/(B-1) + 1 Where L is the deepest level (or, the depth of the search)

Another Problem: 8 Puzzle ABC A: 4 moves for blank * 1 position = 4 B: 2 moves for blank * 4 positions = 8 C: 3 moves for blank * 4 positions = 12 B = ( ) /( ) = 2.67 Does the branching factor of larger (15, 24) puzzles approach 4 as the puzzles get larger?