PENGANTAR INTELIJENSIA BUATAN (64A614)

Slides:



Advertisements
Similar presentations
Game Playing CS 63 Chapter 6
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.
Games & Adversarial Search
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
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.
Adversarial Search CSE 473 University of Washington.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
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.
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.
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”
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Introduction to Artificial Intelligence CS 438 Spring 2008 Today –AIMA, Ch. 6 –Adversarial Search Thursday –AIMA, Ch. 6 –More Adversarial Search The “Luke.
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 6 Section 1 – 4. Search in an Adversarial Environment Iterative deepening and A* useful for single-agent search problems What.
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.
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.
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
Game Playing Why do AI researchers study game playing?
Adversarial Search and Game-Playing
Game Playing Why do AI researchers study game playing?
Games and Adversarial Search
Last time: search strategies
Games and adversarial search (Chapter 5)
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Pengantar Kecerdasan Buatan
Game Playing.
David Kauchak CS52 – Spring 2016
Adversarial Search Chapter 5.
Game Playing in AI by: Gaurav Phapale 05 IT 6010
Games & Adversarial Search
Artificial Intelligence
Games & Adversarial Search
Adversarial Search.
Artificial Intelligence
CMSC 471 Fall 2011 Class #8-9 Tue 9/27/11 – Thu 9/29/11 Game Playing
Game playing.
Games & Adversarial Search
Games & Adversarial Search
Game Playing: Adversarial Search
Artificial Intelligence
CMSC 671 Fall 2010 Tue 9/21/10 Game Playing
Minimax strategies, alpha beta pruning
Game Playing Fifth Lecture 2019/4/11.
Mini-Max search Alpha-Beta pruning General concerns on games
Game Playing: Adversarial Search
Artificial Intelligence
Game Playing Chapter 5.
Games & Adversarial Search
Adversarial Search CMPT 420 / CMPG 720.
Adversarial Search CS 171/271 (Chapter 6)
Minimax strategies, alpha beta pruning
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Unit II Game Playing.
Presentation transcript:

PENGANTAR INTELIJENSIA BUATAN (64A614) Kuliah 5 : Game Playing Fakultas Teknik Jurusan Informatika Universitas Surabaya

Outline Game Playing Game Trees Minimax Alpha-Beta Pruning

Games Some games: Ball games Card games Board games Computer games ...

Human Game Playing

Garry Kasparov and Deep Blue, 1997 Computer Game Playing Garry Kasparov and Deep Blue, 1997

Game-Playing Agent sensors actuators agent environment ? Environment

Type of games

Typical Case 2-person game Players alternate moves Zero-sum: one player’s loss is the other’s gain Perfect information: both players have access to complete information about the state of the game. No information is hidden from either player.

Typical Case No chance (e.g., using dice) involved Examples: Tic-Tac-Toe, Checkers, Chess, Go, Nim, Othello Not : Bridge, Solitaire, Backgammon, ...

Two-player games A game formulated as a search problem: Initial state: board position and turn Successor function(Action) : definition of legal moves Terminal state: conditions for when game is over Utility function: a numeric value that describes the outcome of the game. E.g., -1, 0, 1 for loss, draw, win. (payoff function)

The Minimax Algorithm Basic idea : Choose move with highest minimax value = Best achievable payoff against best play. Algorithm : Generate game tree completely. Determine utility of each terminal state. Propagate the utility values upward in the tree by applying MIN and MAX operators on the nodes in the current level. At the root node use minimax decision to select the move with the max (of the min) utility value. Steps 2 and 3 in the algorithm assume that the opponent will play perfectly.

Tic-Tac-Toe

Generate Game Tree

Generate Game Tree x x x x

Generate Game Tree x x o x o x o

Generate Game Tree x 1 ply 1 move x o x o x o

A subtree win lose draw x o x o x o x o x x o x o x o x o x o x o o o

What is a good move? win lose draw x o x o x o x o x x o x o x o x o x

Minimax Minimize opponent’s chance Maximize your chance 3 8 12 4 6 14 5 Minimize opponent’s chance Maximize your chance

Minimax Minimize opponent’s chance Maximize your chance 3 2 8 12 4 6 14 5 MIN Minimize opponent’s chance Maximize your chance

Minimax Minimize opponent’s chance Maximize your chance 3 2 8 12 4 6 14 5 MAX MIN Minimize opponent’s chance Maximize your chance

Minimax Minimize opponent’s chance Maximize your chance 3 2 8 12 4 6 14 5 MAX MIN Minimize opponent’s chance Maximize your chance

Minimax = Maximum of the minimum 1st ply 2nd ply

MAX A B C MIN D E F G MAX 1 1 -3 4 1 2 -3 4 -5 1 -7 2 -3 -8 Select this move B C MIN 1 -3 D E F G MAX 4 1 2 -3 4 -5 1 -7 2 -3 -8 = terminal position = agent = opponent

MiniMax search on Tic-Tac-Toe Evaluation function Eval(n) for A infinity if n is a win state for A (Max) -- infinity if n is a win state for B (Min) (# of 3-moves for A) -- (# of 3-moves for B) a 3-move is an open row, column, diagonal

MiniMax search on Tic-Tac-Toe A is X Eval(s) = 6 - 4

Tic-Tac-Toe MiniMax search, d=2

Tic-Tac-Toe MiniMax search, d=4

Tic-Tac-Toe MiniMax search, d=6

Partial Game Tree for Tic-Tac-Toe f(n) = +1 if the position is a win for X. f(n) = -1 if the position is a win for O. f(n) = 0 if the position is a draw.

Properties of minimax Complete? Yes (if tree is finite) Optimal? Yes (against an optimal opponent) Time complexity? O(bm) Space complexity? O(bm) (depth-first exploration) For chess, b ≈ 35, m ≈100 for "reasonable" games  exact solution completely infeasible

Minimax Exercise 5 -3 3 3 -3 2 -2 3 5 2 5 -5 1 5 1 -3 -5 5 -3 3 2

Alpha-Beta Prunning A disadvantage of MinMax search is that it has to expand every node in the subtree to depth m. Can we make a correct MinMax decision without looking at every node? We want to prune the tree: stop exploring subtrees for which their value will not influence the final MinMax root decision Observation: all nodes whose values are greater (smaller) that the current minimum (maximum) need not be explored !

Do We Have To Do All That Work ? MAX MIN 3 12 8

Do We Have To Do All That Work ? 3 MAX 3 MIN 3 12 8

Do We Have To Do All That Work ? 3 MAX 3 2 MIN 3 12 8 2 Since 2 is smaller than 3, then there is no need for further search

Do We Have To Do All That Work ? 3 MAX 3 X 2 MIN 3 12 8 14 5 2

Alpha-Beta Pruning Generally applied optimization on Mini-max. Instead of: first creating the entire tree (up to depth-level) then doing all propagation Interleave the generation of the tree and the propagation of values. Point: some of the obtained values in the tree will provide information that other (non-generated) parts are redundant and do not need to be generated.

Alpha-Beta Pruning MIN MAX 2 2 1 2 =2 1 5

- The (temporary) values at MAX-nodes are ALPHA-values - The (temporary) values at MIN-nodes are BETA-values Alpha-value MIN MAX 2 2 5 =2 2 1 1 Beta-value

Alpha-Beta pruning Example

Alpha-Beta pruning Example

Alpha-Beta pruning Example

Alpha-Beta pruning Example

Alpha-Beta pruning Example

Properties of Alpha-Beta pruning Pruning does not affect final result. Good move ordering improves effectiveness of pruning. With "perfect ordering," time complexity = O(bm/2)  doubles depth of search

Alpha-Beta pruning Example  6 MAX MIN 6

Alpha-Beta pruning Example  6 MAX MIN 6  2 6 12 8 2

Alpha-Beta pruning Example  6 MAX MIN 6  2  5 6 12 8 2 5

Alpha-Beta pruning Example  6 MAX Selected move MIN 6  2  5 6 12 8 2 5

A B C MAX D E F G MIN H I J K L M MAX 6 6 2 beta cutoff 6 >=8 alpha cutoff 2 H I J K L M MAX 6 5 8 2 1 = agent = opponent

Alpha-Beta pruning Example 8 7 3 9 1 6 2 4 5  4 16  5 31 39 = 5 MAX 6  8  5 23 15 = 4 30 = 5  3 38 MIN 33  1 2  8 10  2 18  1 25  3 35  2 12  4 20  3 5 = 8 8  9 27  9 29  6 37 = 3 14 = 4 22 = 5 MAX 1 3 4 7 9 11 13 17 19 21 24 26 28 32 34 36 11 static evaluations saved !!

Example of a perfectly ordered tree MAX MIN 21 21 12 3 21 24 27 12 15 18 3 6 9 21 20 19 24 23 22 27 26 25 12 11 10 15 14 13 18 17 16 3 2 1 6 5 4 9 8 7

Exercise Minimax Alpha Beta Pruning A B C D E F G H I J K L M N O P Q V W Y X 2 3 8 5 7 6 1 4 10 Max Min