Adversarial Search 1

Similar documents
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

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

Game Playing State of the Art

CS 5522: Artificial Intelligence II

CS 188: Artificial Intelligence Spring Announcements

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

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

Artificial Intelligence

CS 188: Artificial Intelligence

Programming Project 1: Pacman (Due )

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

CS 188: Artificial Intelligence. Overview

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

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

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

CSE 573: Artificial Intelligence

Adversarial Search Lecture 7

Artificial Intelligence

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

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

CSE 573: Artificial Intelligence Autumn 2010

CS 188: Artificial Intelligence Spring 2007

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

CSE 473: Ar+ficial Intelligence

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

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

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

CS 188: Artificial Intelligence

CSE 473: Artificial Intelligence. Outline

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

mywbut.com Two agent games : alpha beta pruning

Lecture 5: Game Playing (Adversarial Search)

Artificial Intelligence

Game-Playing & Adversarial Search

ARTIFICIAL INTELLIGENCE (CS 370D)

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

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

CS 771 Artificial Intelligence. Adversarial Search

Adversary Search. Ref: Chapter 5

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

Adversarial Search and Game Playing

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

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

CS 188: Artificial Intelligence

CSE 473: Artificial Intelligence Autumn 2011

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

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

Games (adversarial search problems)

Artificial Intelligence Adversarial Search

Module 3. Problem Solving using Search- (Two agent) Version 2 CSE IIT, Kharagpur

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

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

Game Playing. Philipp Koehn. 29 September 2015

Artificial Intelligence. Minimax and alpha-beta pruning

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

game tree complete all possible moves

Game playing. Chapter 5. Chapter 5 1

CS 4700: Foundations of Artificial Intelligence

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

CS 331: Artificial Intelligence Adversarial Search II. Outline

Game Tree Search. CSC384: Introduction to Artificial Intelligence. Generalizing Search Problem. General Games. What makes something a game?

Game playing. Chapter 6. Chapter 6 1

Game Playing: Adversarial Search. Chapter 5

ADVERSARIAL SEARCH. Chapter 5

Artificial Intelligence 1: game playing

School of EECS Washington State University. Artificial Intelligence

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

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

CS 380: ARTIFICIAL INTELLIGENCE

Adversarial Search. CMPSCI 383 September 29, 2011

Artificial Intelligence. Topic 5. Game playing

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

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

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

Adversarial Search: Game Playing. Reading: Chapter

Game playing. Chapter 6. Chapter 6 1

Game-playing AIs: Games and Adversarial Search I AIMA

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

Algorithms for Data Structures: Search for Games. Phillip Smith 27/11/13

Computer Science and Software Engineering University of Wisconsin - Platteville. 4. Game Play. CS 3030 Lecture Notes Yan Shi UW-Platteville

Foundations of Artificial Intelligence

CS325 Artificial Intelligence Ch. 5, Games!

Adversarial search (game playing)

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

16.410/413 Principles of Autonomy and Decision Making

Game playing. Outline

Games and Adversarial Search

CS 188: Artificial Intelligence Spring Game Playing in Practice

Path Planning as Search

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

CSC384: Introduction to Artificial Intelligence. Game Tree Search

Playing Games. Henry Z. Lo. June 23, We consider writing AI to play games with the following properties:

Game playing. Chapter 5, Sections 1 6

CS 2710 Foundations of AI. Lecture 9. Adversarial search. CS 2710 Foundations of AI. Game search

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

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

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

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

Computer Game Programming Board Games

Transcription:

Adversarial Search 1

Adversarial Search The ghosts trying to make pacman loose Can not come up with a giant program that plans to the end, because of the ghosts and their actions Goal: Eat lots of dots and lots of ghosts (not most hideous ones) and not die How to come up with an action based on reasoning ahead about what both you and your adversary might do 2

Adversarial Search Problems: Games Many different kinds of games! Deterministic or stochastic? Is there any dice? Does any action have multiple random outcomes? One, two, or more players? Multiple agents may cooperate, compete, or act in between. Zero sum? One utility function: you want to make it big and the adversary wants to make it small Perfect information (can you see the state)? Need algorithms for calculating a strategy (policy) which recommends a move in each state 3

Deterministic Games Many possible formalizations, one is: States: S (start at s 0 ) Players: P={1... N} (usually take turns) Actions: A (may depend on player/state) Transition Function (also called the model): S A S Terminal Test: S {t, f} (Terminal) Utility Function: S P R Solution for a player is a policy: S A 4

Deterministic Single-Player? Deterministic, single player, perfect information: Know the rules Know what actions do Know when you win E.g. 8-Puzzle, Rubik s cube it s just a search! 5

Deterministic Single-Player? Like search tree, but there is some end of the game On each leaf (ending node) there is some outcome (+1 win, -1 lose or some real values to specify some states are better than others) In general search costs are incremental we try to minimize cost Games are like general AI we want to maximize utility, all rewards come at the end, no cost on each move In each node select the branch (child) that finally will achieve the win -1 +1-1 6

Deterministic Single-Player? it s just a search! Slight reinterpretation: Each node stores a value: the best outcome it can reach under optimal play This is the maximal value of its children (the maxvalue) Note that we don t have path sums as before (utilities are at leaves) Here, value at the root is +1 since you can force the win +1 After search, +1-1 can pick move that leads to best node 7-1

Adversarial Games Deterministic, zero-sum games: Tic-tac-toe, chess, checkers One player maximizes result The other minimizes result Minimax search: A state-space search tree Players alternate turns Each node has a minimax value: best achievable utility against a rational (optimal) adversary 8

Adversarial Games Deterministic, zero-sum games: Tic-tac-toe, chess, checkers One player maximizes result The other minimizes result Minimax search: A state-space search tree Players alternate turns Each node has a minimax value: best achievable utility against a rational (optimal) adversary 9

Computing Minimax Values Two recursive functions: max-value maxes the values of successors min-value mins the values of successors def value(state): If the state is a terminal state: return the state s utility If the agent is MAX: return max-value(state) If the agent is MIN: return min-value(state) def max-value(state): Initialize max = - For each successor of state: Compute value(successor) Update max accordingly Return max 10

11

Minimax Example? Minmax search performs a complete DFS exploration of game tree?? +?? + 3 3 + 3 3 12

Minimax Example 3 3 2 2 13

Tic-Tac-Toe Game Tree Fewer than 9! Terminal nodes Minmax value at the root is 0 14

Minimax Properties Optimal against a perfect player. Otherwise? If MIN does not play optimally, MAX can do even better (other strategies exist) Time complexity? O(b m ) Exponential Time Totally impractical Space complexity? O(bm) For chess, b 35, m 100 Exact solution is completely infeasible But, do we need to explore the whole tree? 15

Two real time approaches when Resource Limits we cannot search to leaves (terminals): Truncate subtrees Depth-limited Search Iterative Deepening Pruning parts of tree proved not be useful Alpha-Beta pruning 16

Depth-limited Search Depending how long you have time, search to the right depth Depth-limited search search a limited depth of tree Replace terminal utilities with a heuristic evaluation function Eval for non-terminal positions Guarantee of optimal play is gone More plies makes a BIG difference Example: Suppose we have 100 seconds time for each move, and can explore 10K nodes/sec So can check 1M nodes per move This reaches about depth 8, a decent chess program 17

Iterative Deepening If not sure about time, search depth by depth Iterative deepening, use DFS to do BFS Do a DFS which only searches for paths of length 1. (DFS gives up on any path of more than 1) If still have time, do a DFS which only searches paths of length 2 or less. If still have time, do a DFS which only searches paths of length 3 or less..and so on. Note: wrongness of Eval functions matters less and less the deeper the search goes! 18

Evaluation Functions Function which scores non-terminal states (estimated achievable utility) Ideal function: returns the exact utility of the state In practice: typically weighted linear sum of features of states: Eval ( 2 s) = w1 f1( s) + w2 f ( s) + K+ wn fn( s) e.g. f 1 (s) = (numwhitequeens numblackqueens), etc. 19

Minimax Example 20

Pruning in Minimax Search - 3 3 3 3 2 3 3 3 14 5 2 21

Alpha-Beta Pruning General configuration We re computing the MIN-VALUE at n We re looping over n s children n s value estimate is dropping a is the best value that MAX can get at any choice point along the current path If n s value estimate becomes worse than a, MAX will avoid it, so can stop considering n s other children Define b similarly for MIN 22

Alpha-Beta Pruning Example 23

Alpha-Beta Pruning Example Starting a/b a= b=+ Raise a a= b=+ a=3 b=+ a=3 b=+ a=3 b=+ Lower b a= b=+ a= b=3 a= b=3 a= b=3 a=3 b=+ a=3 b=2 a=3 b=+ a=3 b=14 a=3 b=5 a=3 b=1 Raise a a= b=3 a=8 b=3 a is MAX s best choice (highest) found so far along the path b is MIN s best choice (lowest) found so far along the path

Example trace v = max (v, MinV(child, α, β)) if v β the return v else α = max(α, v) MaxV=3 MaxV=12 MaxV=8 u = min (u, MaxV(child, α, β)) if u α the return u else β = min(β, u)

MaxV=2 Example trace

Example trace MaxV=14 MaxV=5 MaxV=2

28

Alpha-Beta Pseudocode 29

Alpha-Beta Pruning Properties This pruning has no effect on final result at the root Values of intermediate nodes might be wrong! Important: children of the root may have the wrong value Good child ordering improves effectiveness of pruning With perfect ordering : Time complexity drops to O(b m/2 ) Doubles solvable depth! Full search of, e.g. chess, is still hopeless This is a simple example of metareasoning (computing about what to compute) 30