Adversarial Search Lecture 7

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

Game Playing State-of-the-Art

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

CS 188: Artificial Intelligence

CS 5522: Artificial Intelligence II

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

Artificial Intelligence

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

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

Programming Project 1: Pacman (Due )

CSE 573: Artificial Intelligence

CS 188: Artificial Intelligence. Overview

CS 188: Artificial Intelligence Spring Announcements

Artificial Intelligence

CSE 473: Artificial Intelligence. Outline

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

CS 188: Artificial Intelligence

Game Playing State of the Art

Adversarial Search 1

Game Playing State-of-the-Art. CS 188: Artificial Intelligence. Behavior from Computation. Adversarial Games. Deterministic Games.

CS 188: Artificial Intelligence

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

CSE 473: Ar+ficial Intelligence

Game playing. Chapter 5. Chapter 5 1

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

Game playing. Chapter 6. Chapter 6 1

Game Playing: Adversarial Search. Chapter 5

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

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

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

Artificial Intelligence

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

Game Playing. Philipp Koehn. 29 September 2015

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

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

Lecture 5: Game Playing (Adversarial Search)

CS 380: ARTIFICIAL INTELLIGENCE

CSE 573: Artificial Intelligence Autumn 2010

Project 1. Out of 20 points. Only 30% of final grade 5-6 projects in total. Extra day: 10%

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

CSE 473: Artificial Intelligence Autumn 2011

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

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

CS 188: Artificial Intelligence Spring 2007

Game playing. Outline

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

Artificial Intelligence Adversarial Search

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

ADVERSARIAL SEARCH. Chapter 5

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

Game-Playing & Adversarial Search

Announcements. CS 188: Artificial Intelligence Fall Today. Tree-Structured CSPs. Nearly Tree-Structured CSPs. Tree Decompositions*

Artificial Intelligence. Minimax and alpha-beta pruning

Adversarial search (game playing)

Adversarial Search and Game Playing

Game playing. Chapter 5, Sections 1 6

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

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Adversarial Search. Robert Platt Northeastern University. Some images and slides are used from: 1. CS188 UC Berkeley 2. RN, AIMA

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

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

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

CS 188: Artificial Intelligence Spring Game Playing in Practice

Game-playing: DeepBlue and AlphaGo

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

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

Intuition Mini-Max 2

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

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

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

CS 331: Artificial Intelligence Adversarial Search II. Outline

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

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

School of EECS Washington State University. Artificial Intelligence

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

Artificial Intelligence. Topic 5. Game playing

CS 771 Artificial Intelligence. Adversarial Search

Foundations of Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

Adversarial Search. CMPSCI 383 September 29, 2011

6. Games. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Mechanical Turk. Origins. origins. motivation. minimax search

Games and Adversarial Search

ARTIFICIAL INTELLIGENCE (CS 370D)

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

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

Adversarial Search: Game Playing. Reading: Chapter

Ar#ficial)Intelligence!!

Adversarial Search (Game Playing)

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

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

Adversarial Search Aka Games

Game-Playing & Adversarial Search Alpha-Beta Pruning, etc.

CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #5

Pengju

Game-playing AIs: Games and Adversarial Search I AIMA

Foundations of AI. 6. Adversarial Search. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard & Bernhard Nebel

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

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

Transcription:

Lecture 7 How can we use search to plan ahead when other agents are planning against us? 1

Agenda Games: context, history Searching via Minimax Scaling α β pruning Depth-limiting Evaluation functions Handling uncertainty with Expectiminimax 2

Characterizing Games There are many kinds of games, and several ways to classify them Deterministic vs. stochastic [Im]perfect information One, two, multi-player Utility (how agents value outcomes) Zero-sum Algorithmic goal: calculate a strategy (or policy) that decides a move in each state 3

Utility Zero/Constant-Sum Opposite utilities Adversarial, pure competition General Games Independent utilities Cooperation, indifference, competition, and more are all possible 4

Examples: Perception vs. Chance Deterministic Stochastic Perfect Chess, Checkers, Go, Othello Backgammon, Monopoly Imperfect Battleship Bridge, Poker, Scrabble 5

1950: First computer player 1994: First computer champion (Chinook) ended 40-year-reign of human champion Marion Tinsley using complete 8-piece endgame 1995: defended against Don Lafferty 2007: solved! Checkers 6

Chess 1997: Deep Blue defeats human champion Gary Kasparov in a six-game match Deep Blue examined 200M positions per second, used very sophisticated evaluation and undisclosed methods for extending some lines of search up to 40 ply Current programs are even better, if less historic DeepBlue 7

Go Until recently, AI was not competitive at champion level 2015: beat Fan Hui, European champion (2-dan; 5-0) 2016: beat Lee Sedol, one of the best players in the world (9-dan; 4-1) 2017: beat Ke Jie, #1 in the world (9-dan; 2-0) MCTS + ANNs for policy (what to do) and evaluation (how good is a board state) AlphaGo 8

Libratus beat four topclass human poker players in January, 2017 120,000 hands played Novel methods for endgame solving in imperfect games Poker 15 million core hours of computation (+4 during competition) Libratus 9

Othello: 1997, defeated world champion Bridge: 1998, competitive with human champions Scrabble: 2006, defeated world champion More Progress 10

Game Formalism States: S (start at S % ) Players: P {1, N} (typically take turns) Actions: Action(s), returns legal options Transition function: S A S Terminal test: Terminal(s), returns T/F Utility: S P R Solution for a player is a policy: S A 11

Start with deterministic, twoplayer adversarial games Game Plan :) Issues to come Multiple players Resource limits Stochasticity 12

Single-Agent Game Tree 8 2 0 2 6 4 6 13

Value of a state: The best achievable outcome (utility) from that state Value of a State Non-Terminal States: 8 2 0 2 6 4 6 Terminal States: 14

Adversarial Game Trees -20-8 -18-5 -10 +4-20 +8 15

Minimax Values States Under Agent s Control: States Under Opponent s Control: -8-5 -10 +8 Terminal States: 16

Tic-Tac-Toe Game Tree 17

via Minimax Deterministic, zero-sum Tic-tac-toe, chess One player maximizes The other minimizes Minimax search A search tree Players alternate turns Compute each node s minimax value: the best achievable utility against a rational (optimal) adversary Minimax values: computed recursively 5 max 2 5 8 2 5 6 Terminal values: part of the game min 18

Minimax Implementation def value(state): if the state is a terminal state: return the state s utility if the next agent is MAX: return max-value(state) if the next agent is MIN: return min-value(state) def max-value(state): initialize v = - for each successor of state: v = max(v, value(successor)) return v def min-value(state): initialize v = + for each successor of state: v = min(v, value(successor)) return v 19

Time O(b m ) For chess: b 35, m 100 Space O(bm) Minimax Evaluation Complete Only if finite Minimax-Min Optimal Yes, against optimal opponent Minimax-Avg 20

Add a ply per player Independent utility: use a vector of values, each player MAX own utility Zero-sum: each team sequentially MIN/MAX Multiple Players In Pacman, have multiple MIN layers for each ghost per 1 Pacman move 21

Scaling to Larger Games Tree Pruning Depth-Limiting + Evaluation 22

Minimax Example 3 3 2 2 3 12 8 2 4 6 14 5 2 23

Minimax Pruning [, [3,3] ] ] 3 [, [3,3] 3] ] 3 [, 2] [, [2,2] 14] 5] 2 2 3 12 8 2 14 5 2 24

General Case α is the best value (to MAX) found so far off the current path If V is worse than α, MAX will avoid it prune that branch Define β similarly for MIN 25

Alpha-Beta Pruning def min-value(state, α, β): initialize v = + for each successor of state: v = min(v,value(successor,α,β)) if v α return v β = min(β, v) return v α: MAX s best option on path β: MIN s best option on path def max-value(state, α, β): initialize v = - for each successor of state: v = max(v,value(successor,α,β)) if v β return v α = max(α, v) return v 26

Alpha-Beta Properties Has no effect on minimax value computed for the root! Good child ordering improves effectiveness of pruning With perfect ordering : Time complexity drops to O(b N/P ) Doubles solvable depth! Full search of, e.g. chess, is still hopeless This is a simple example of metareasoning (computing about what to compute) 27

Checkup #1 10 8 4 50 28

Checkup #2 10 6 100 8 1 2 20 4 29

Checkup #3 5 6 7 4 5 3 6 6 9 7 5 9 8 6 30

Resource Limits Problem: in realistic games, cannot search to leaves! Solution: depth-limited search 1. Search only to a limited depth in the tree 2. Replace terminal utilities with an evaluation function for non-terminal positions Guarantee of optimal play is gone More plies makes a BIG difference Use iterative deepening for an anytime algorithm 31

Search Depth Matters Evaluation functions are always imperfect The deeper in the tree the evaluation function is buried, the less the quality of the evaluation function matters An important example of the tradeoff between complexity of features and complexity of computation Depth2 Depth10 32

Evaluation Functions Evaluation functions score non-terminals in depthlimited search Ideal: returns the actual minimax value of the position In practice: typically weighted linear sum of features: e.g. f R (s) = (num white queens num black queens) 33

Why Pacman Starves/Thrashes A danger of replanning agents! He knows his score will go up by eating a dot now He knows his score will go up just as much by eating a dot later There are no point-scoring opportunities after eating a dot (within the horizon, two here) Therefore, waiting seems just as good as eating: he may go east, then back west in the next round of replanning! 34

Pacman/Ghost Evaluation Thrashing Thrashing-Fixed SmartGhosts-1 SmartGhosts-2 35

Nondeterministic Games 36

Worst Case vs. Average Case max min 10 10 9 100 In nondeterministic games, chance is introduced by non-opponent stochasticity (e.g. dice, card-shuffling) 37

Expectiminimax Search Why wouldn t we know what the result of an action will be? Explicit randomness: rolling dice Unpredictable opponents: the ghosts respond randomly Actions can fail: when moving a robot, wheels might slip max chance Values should now reflect average-case (expectimax) outcomes, not worst-case (minimax) outcomes Expectiminimax search: compute the average score under optimal play Max nodes as in minimax search Chance nodes are like min nodes but the outcome is uncertain Calculate their expected utilities 10 10 4 59 100 7 38

Reminder: Probabilities A random variable represents an event whose outcome is unknown A probability distribution is an assignment of weights to outcomes Example: Traffic on freeway Random variable: T = whether there s traffic Outcomes: T in {none, light, heavy} Distribution: P(T=none) = 0.25 P(T=light) = 0.50 P(T=heavy) = 0.25 0.25 0.50 0.25 39

Reminder: Expectations The expected value of a function of a random variable is the average, weighted by the probability distribution over outcomes Example: How long to get to the airport? Time P(T) 20 min 30 min 60 min + + 35 min x x x 0.25 0.50 0.25 T 40

Expectiminimax Implementation def value(state): if the state is a terminal state: return the state s utility if the next agent is MAX: return max-value(state) if the next agent is EXP: return exp-value(state) def max-value(state): initialize v = - for each successor of state: v = max(v, value(successor)) return v def exp-value(state): initialize v = 0 for each successor of state: p = probability(successor) v += p * value(successor) return v 41

Expectiminimax Example def exp-value(state): initialize v = 0 for each successor of state: p = probability(successor) v += p * value(successor) return v 1/2 1/3 1/6 58 24 7-12 v = (1/2) (8) + (1/3) (24) + (1/6) (-12) = 10 42

Where Do Probabilities Come From? In expectiminimax search, we have a probabilistic model of how the opponent (or environment) will behave in any state Model could be a simple uniform distribution (roll a die) Model could be sophisticated and require a great deal of computation We have a chance node for any outcome out of our control: opponent or environment The model might say that adversarial actions are likely! For now, assume each chance node magically comes along with probabilities that specify the distribution over its outcomes 43

Summary A game can be formulated as a search problem, with a solution policy (S A) For deterministic games, the minimax algorithm plays optimally (assuming the game tree is reasonable) To help with resource limitations, standard practice is to employ alpha-beta pruning and depth-limited search (with an evaluation function) To model uncertainty, the expectiminimax algorithm introduces chance nodes that employ a probability distribution over actions to model expected utility 44