Game playing. Chapter 5, Sections 1 6

Similar documents
Game playing. Chapter 5. Chapter 5 1

Game playing. Chapter 6. Chapter 6 1

Games vs. search problems. Adversarial Search. Types of games. Outline

Games vs. search problems. Game playing Chapter 6. Outline. Game tree (2-player, deterministic, turns) Types of games. Minimax

CS 380: ARTIFICIAL INTELLIGENCE ADVERSARIAL SEARCH. Santiago Ontañón

Game playing. Chapter 6. Chapter 6 1

Outline. Game playing. Types of games. Games vs. search problems. Minimax. Game tree (2-player, deterministic, turns) Games

CS 380: ARTIFICIAL INTELLIGENCE

Game Playing: Adversarial Search. Chapter 5

ADVERSARIAL SEARCH. Chapter 5

Game Playing. Philipp Koehn. 29 September 2015

Game playing. Outline

Game Playing. Dr. Richard J. Povinelli. Page 1. rev 1.1, 9/14/2003

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 4: Search 3.

Game playing. Chapter 5, Sections 1{5. AIMA Slides cstuart Russell and Peter Norvig, 1998 Chapter 5, Sections 1{5 1

Lecture 5: Game Playing (Adversarial Search)

Adversarial search (game playing)

Artificial Intelligence. Topic 5. Game playing

Ch.4 AI and Games. Hantao Zhang. The University of Iowa Department of Computer Science. hzhang/c145

Last update: March 9, Game playing. CMSC 421, Chapter 6. CMSC 421, Chapter 6 1

CS 188: Artificial Intelligence

School of EECS Washington State University. Artificial Intelligence

Adversarial Search and Game Playing

Adversarial Search. Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 9 Feb 2012

Programming Project 1: Pacman (Due )

CS 188: Artificial Intelligence Spring Game Playing in Practice

Games CSE 473. Kasparov Vs. Deep Junior August 2, 2003 Match ends in a 3 / 3 tie!

Today. Nondeterministic games: backgammon. Algorithm for nondeterministic games. Nondeterministic games in general. See Russell and Norvig, chapter 6

CSE 473: Artificial Intelligence. Outline

Adversarial Search. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 5

Adversarial Search (a.k.a. Game Playing)

Artificial Intelligence

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

CS 331: Artificial Intelligence Adversarial Search II. Outline

Adversarial Search. CMPSCI 383 September 29, 2011

Outline. Game Playing. Game Problems. Game Problems. Types of games Playing a perfect game. Playing an imperfect game

Game Playing. Why do AI researchers study game playing? 1. It s a good reasoning problem, formal and nontrivial.

Adversarial Search Lecture 7

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

Game-Playing & Adversarial Search

Adversarial Search. Chapter 5. Mausam (Based on slides of Stuart Russell, Andrew Parks, Henry Kautz, Linda Shapiro) 1

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 2 February, 2018

CS 771 Artificial Intelligence. Adversarial Search

Announcements. Homework 1. Project 1. Due tonight at 11:59pm. Due Friday 2/8 at 4:00pm. Electronic HW1 Written HW1

CS 188: Artificial Intelligence Spring 2007

Local Search. Hill Climbing. Hill Climbing Diagram. Simulated Annealing. Simulated Annealing. Introduction to Artificial Intelligence

Adversarial Search and Game- Playing C H A P T E R 6 C M P T : S P R I N G H A S S A N K H O S R A V I

CSE 573: Artificial Intelligence Autumn 2010

Game-playing AIs: Games and Adversarial Search FINAL SET (w/ pruning study examples) AIMA

Adversarial Search. Human-aware Robotics. 2018/01/25 Chapter 5 in R&N 3rd Ø Announcement: Slides for this lecture are here:

Game Playing State-of-the-Art CSE 473: Artificial Intelligence Fall Deterministic Games. Zero-Sum Games 10/13/17. Adversarial Search

CS 188: Artificial Intelligence Spring Announcements

Intuition Mini-Max 2

Artificial Intelligence. Minimax and alpha-beta pruning

Adversarial Search. Rob Platt Northeastern University. Some images and slides are used from: AIMA CS188 UC Berkeley

Artificial Intelligence

COMP219: Artificial Intelligence. Lecture 13: Game Playing

CS440/ECE448 Lecture 9: Minimax Search. Slides by Svetlana Lazebnik 9/2016 Modified by Mark Hasegawa-Johnson 9/2017

CS 5522: Artificial Intelligence II

Artificial Intelligence

Games and Adversarial Search

Announcements. CS 188: Artificial Intelligence Fall Local Search. Hill Climbing. Simulated Annealing. Hill Climbing Diagram

Adversarial Search and Game Playing. Russell and Norvig: Chapter 5

Artificial Intelligence Adversarial Search

CSE 40171: Artificial Intelligence. Adversarial Search: Games and Optimality

Game Playing State-of-the-Art

Adversarial Search. Read AIMA Chapter CIS 421/521 - Intro to AI 1

Game Playing State-of-the-Art. CS 188: Artificial Intelligence. Behavior from Computation. Video of Demo Mystery Pacman. Adversarial Search

CS 188: Artificial Intelligence. Overview

Foundations of Artificial Intelligence

CSE 473: Artificial Intelligence Autumn 2011

Path Planning as Search

Foundations of Artificial Intelligence

Contents. Foundations of Artificial Intelligence. Problems. Why Board Games?

Announcements. CS 188: Artificial Intelligence Spring Game Playing State-of-the-Art. Overview. Game Playing. GamesCrafters

CS 188: Artificial Intelligence

CSE 40171: Artificial Intelligence. Adversarial Search: Game Trees, Alpha-Beta Pruning; Imperfect Decisions

Artificial Intelligence 1: game playing

Adversarial Search. Chapter 5. Mausam (Based on slides of Stuart Russell, Andrew Parks, Henry Kautz, Linda Shapiro, Diane Cook) 1

Adversarial Search (Game Playing)

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016 Tim French

Games vs. search problems

CSE 573: Artificial Intelligence

Adversarial Search 1

CPS 570: Artificial Intelligence Two-player, zero-sum, perfect-information Games

Adversarial Search Aka Games

CS 4700: Foundations of Artificial Intelligence

Game Playing State of the Art

Artificial Intelligence

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter Read , Skim 5.7

COMP9414: Artificial Intelligence Adversarial Search

Unit-III Chap-II Adversarial Search. Created by: Ashish Shah 1

Games and Adversarial Search II

ADVERSARIAL SEARCH. Today. Reading. Goals. AIMA Chapter , 5.7,5.8

CSE 473: Artificial Intelligence Fall Outline. Types of Games. Deterministic Games. Previously: Single-Agent Trees. Previously: Value of a State

Game Playing AI Class 8 Ch , 5.4.1, 5.5

2/5/17 ADVERSARIAL SEARCH. Today. Introduce adversarial games Minimax as an optimal strategy Alpha-beta pruning Real-time decision making

Artificial Intelligence

Lecture 14. Questions? Friday, February 10 CS 430 Artificial Intelligence - Lecture 14 1

Ar#ficial)Intelligence!!

Transcription:

Game playing Chapter 5, Sections 1 6 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 1

Outline Games Perfect play minimax decisions α β pruning Resource limits and approximate evaluation Games of chance (briefly) Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 2

Games as search problems The main difference to the previous slides: now we have more than one agent that have different goals. All possible game sequences are represented in a game tree. The nodes are the states of the game, e.g. the board position in chess. Initial state and terminal nodes. States are connected if there is a legal move/ply. Utility function (payoff function). Terminal nodes have utility values 0, 1 or -1. Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 3

Types of games perfect information imperfect information deterministic chess, checkers, go, othello battleships, blind tictactoe chance backgammon monopoly bridge, poker, scrabble nuclear war Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 4

Strategies for Two-Player Games GiventwoplayerscalledMaxandMin, Maxwantstomaximizetheutility value. Since Min wants to minimize the same value, Max should choose the alternative that maximizes given that MIN minimized. Minimax algorithm Minimax(state) = if Terminal-Test(state) then return Utility(state) if state is a Max node then return max s Minimax(Result(state, s)) if state is a Min node then return min s Minimax(Result(state, s)) Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 5

Game tree (2-player, deterministic, turns) MA () MIN (O) MA () O O O... MIN (O) O O O............... TERMINAL Utility O O O O O O O O O O 1 0 +1... Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 6

Minimax Gives perfect play for deterministic, perfect-information games Idea: choose the move with the highest minimax value = best achievable payoff against best play E.g., 2-ply game: MA 3 A 1 A 2 A 3 MIN 3 2 2 A 11 A 21 A 22 A 23 A 32 A 33 A 12 A 13 A 31 3 12 8 2 4 6 14 5 2 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 7

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)) function Max-Value(state) returns a utility value if Terminal-Test(state) then return Utility(state) v for a, s in Successors(state) do v Max(v, Min-Value(s)) return v function Min-Value(state) returns a utility value if Terminal-Test(state) then return Utility(state) v for a, s in Successors(state) do v Min(v, Max-Value(s)) return v Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 8

Properties of minimax Complete?? Yes, if the game 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 an exact solution is completely infeasible But do we need to explore every path? Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 9

α β pruning Suppose, we reach a node t in the game tree which has leaves t 1,..., t k corresponding to moves of player Min. Let α be the best value of a position on a path from the root node to t. Then, if any of the leaves evaluates to f(t i ) α, we can discard t, because any further evaluation will not improve the value of t. Analogously, define β values for evaluating response moves of Max. Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 10

α β pruning example MA 3 MIN 3 3 12 8 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 11

α β pruning example MA 3 MIN 3 2 3 12 8 2 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 12

α β pruning example MA 3 MIN 3 2 14 3 12 8 2 14 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 13

α β pruning example MA 3 MIN 3 2 14 5 3 12 8 2 14 5 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 14

α β pruning example MA 3 3 MIN 3 2 14 5 2 3 12 8 2 14 5 2 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 15

The α β algorithm function Alpha-Beta-Decision(state) returns an action return the a in Actions(state) maximizing Min-Value(Result(a, state)) function Max-Value(state, α, β) returns a utility value inputs: state, current state in game α, the value of the best alternative for max along the path to state β, the value of the best alternative for min along the path to state if Terminal-Test(state) then return Utility(state) v for a, s in Successors(state) do v Max(v, Min-Value(s,α,β)) if v β then return v α Max(α, v) return v function Min-Value(state, α, β) returns a utility value same as Max-Value but with roles of α,β reversed Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 16

Properties of α β pruning Pruning does not affect the final result A good move ordering improves the effectiveness of pruning With perfect ordering, the time complexity becomes O(b m/2 ) this doubles the solvable depth This is a simple example of the value of reasoning about which computations are relevant (a form of metareasoning) Unfortunately, 35 50 is still impossible! Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 17

Resource limits The standard approach is to cutoff the search at some point: Use Cutoff-Test instead of Terminal-Test use a depth limit perhaps add quiescence search Use Eval instead of Utility i.e., an evaluation function that estimates desirability of position Suppose we have 10 seconds per move, and can explore 10 5 nodes/second 10 6 nodes per move 35 8/2 nodes α β pruning reaches depth 8 pretty good chess program Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 18

Evaluation functions Black to move White slightly better White to move Black winning For chess, the evaluation function is typically linear weighted sum of features Eval(s) = w 1 f 1 (s)+w 2 f 2 (s)+...+w n f n (s) e.g., w 1 = 9 with f 1 (s) = (number of white queens) (number of black queens) Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 19

Deterministic games in practice Chess: Deep Blue (IBM) beats chess world champion Garry Kasparov, 1997. Modern chess programs: Houdini, Critter, Stockfish. Checkers/Othello/Reversi: Human champions refuse to compete computers are too good. Chinook plays checkers perfectly, 2007. It uses an endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 443,748,401,247 positions. Logistello beats the world champion in Othello/Reversi, 1997. Go: Human champions refuse to compete computers are too bad. In Go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves. Modern programs: MoGo, Zen, GNU Go Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 20

Nondeterministic games: backgammon 0 1 2 3 4 5 6 7 8 9 10 11 12 25 24 23 22 21 20 19 18 17 16 15 14 13 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 21

Nondeterministic games in general In nondeterministic games, chance is introduced by dice, card-shuffling, etc. Simplified example with coin-flipping: MA CHANCE 3 1 0.5 0.5 0.5 0.5 MIN 2 4 0 2 2 4 7 4 6 0 5 2 Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 22

Algorithm for nondeterministic games ExpectiMinimax gives perfect play Just like Minimax, except we must also handle chance nodes ExpectiMinimax(state) = if Terminal-Test(state) then return Utility(state) if state is a Max node then return max s ExpectiMinimax(Result(state, s)) if state is a Min node then return min s ExpectiMinimax(Result(state, s)) if state is a chance node then return Σ s P(s) ExpectiMinimax(Result(state, s)) where P(s) is the probability that s occurs Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 23

Nondeterministic games in practice Dice rolls increase the branching factor b: there are 21 possible rolls with 2 dice Backgammon has 20 legal moves (can be up to 4,000 with double rolls) depth 4 20 (21 20) 3 1.2 10 9 nodes As depth increases, the probability of reaching a given node shrinks value of lookahead is diminished α β pruning is much less effective TDGammon uses depth-2 search + very good Eval world-champion level Artificial Intelligence, spring 2013, Peter Ljunglöf; based on AIMA Slides c Stuart Russel and Peter Norvig, 2004 Chapter 5, Sections 1 6 24