Adversary Search. Ref: Chapter 5

Similar documents
ARTIFICIAL INTELLIGENCE (CS 370D)

mywbut.com Two agent games : alpha beta pruning

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

CS885 Reinforcement Learning Lecture 13c: June 13, Adversarial Search [RusNor] Sec

CS 1571 Introduction to AI Lecture 12. Adversarial search. CS 1571 Intro to AI. Announcements

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

Games (adversarial search problems)

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

Adversarial Search 1

CS 331: Artificial Intelligence Adversarial Search II. Outline

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

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

game tree complete all possible moves

2 person perfect information

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

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

CPS331 Lecture: Search in Games last revised 2/16/10

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

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

Adversarial Search Aka Games

More Adversarial Search

Artificial Intelligence

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

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

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

Game Playing Beyond Minimax. Game Playing Summary So Far. Game Playing Improving Efficiency. Game Playing Minimax using DFS.

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

Artificial Intelligence. Minimax and alpha-beta pruning

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

Game-Playing & Adversarial Search

CS 771 Artificial Intelligence. Adversarial Search

Adversarial Search (Game Playing)

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

Game-playing AIs: Games and Adversarial Search I AIMA

CSC 380 Final Presentation. Connect 4 David Alligood, Scott Swiger, Jo Van Voorhis

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

Prepared by Vaishnavi Moorthy Asst Prof- Dept of Cse

Adversarial Search: Game Playing. Reading: Chapter

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

CS188 Spring 2010 Section 3: Game Trees

Game Playing State-of-the-Art

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

Artificial Intelligence Adversarial Search

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

COMP9414: Artificial Intelligence Adversarial Search

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

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

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

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

CMPUT 396 Tic-Tac-Toe Game

Artificial Intelligence

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

Game Playing AI Class 8 Ch , 5.4.1, 5.5

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

Artificial Intelligence 1: game playing

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:

Ar#ficial)Intelligence!!

Foundations of AI. 5. Board Games. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard and Luc De Raedt SA-1

Computer Game Programming Board Games

CS188 Spring 2010 Section 3: Game Trees

Game Playing AI. Dr. Baldassano Yu s Elite Education

Adversarial Search and Game Playing

CS 4700: Foundations of Artificial Intelligence

CS 4700: Artificial Intelligence

Announcements. Homework 1 solutions posted. Test in 2 weeks (27 th ) -Covers up to and including HW2 (informed search)

CS 188: Artificial Intelligence

Adversarial search (game playing)

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

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

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

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

More on games (Ch )

Foundations of Artificial Intelligence

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

Game Playing. Chapter 8

CS61B Lecture #22. Today: Backtracking searches, game trees (DSIJ, Section 6.5) Last modified: Mon Oct 17 20:55: CS61B: Lecture #22 1

Game Playing. Philipp Koehn. 29 September 2015

Adversarial Search. CMPSCI 383 September 29, 2011

Artificial Intelligence. Topic 5. Game playing

CS 188: Artificial Intelligence

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

ADVERSARIAL SEARCH. Chapter 5

Adversarial Search Lecture 7

Data Structures and Algorithms

CSE 332: Data Structures and Parallelism Games, Minimax, and Alpha-Beta Pruning. Playing Games. X s Turn. O s Turn. X s Turn.

Instability of Scoring Heuristic In games with value exchange, the heuristics are very bumpy Make smoothing assumptions search for "quiesence"

Artificial Intelligence

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Path Planning as Search

Foundations of AI. 6. Board Games. Search Strategies for Games, Games with Chance, State of the Art

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

V. Adamchik Data Structures. Game Trees. Lecture 1. Apr. 05, Plan: 1. Introduction. 2. Game of NIM. 3. Minimax

Adverserial Search Chapter 5 minmax algorithm alpha-beta pruning TDDC17. Problems. Why Board Games?

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

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

More on games (Ch )

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

Transcription:

Adversary Search Ref: Chapter 5 1

Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans is possible. Many games can be modeled very easily, although game playing turns out to be very hard. 2

2 Player Games Requires reasoning under uncertainty. Two general approaches: Assume nothing more than the rules of the game are important - reduces to a search problem. Try to encode strategies using some type of pattern-directed system (perhaps one that can learn). 3

Search and Games Each node in the search tree corresponds to a possible state of the game. Making a move corresponds to moving from the current state (node) to a child state (node). Figuring out which child is best is the hard part. The branching factor is the number of possible moves (children). 4

Search Tree Size For most interesting games it is impossible to look at the entire search tree. Chess: branching factor is about 35 typical match includes about 100 moves. Search tree for a complete game: 35 100 5

Heuristic Search Must evaluate each choice with less than complete information. For games we often evaluate the game tree rooted at each choice. There is a tradeoff between the number of choices analyzed and the accuracy of each analysis. 6

Game Trees 7

Plausible Move Generator Sometimes it is possible to develop a move generator that will (with high probability) generate only those moves worth consideration. This reduces the branching factor, which means we can spend more time analyzing each of the plausible moves. 8

Recursive State Evaluation We want to rank the plausible moves (assign a value to each resulting state). For each plausible move, we want to know what kind of game states could follow the move (Wins? Loses?). We can evaluate each plausible move by taking the value of the best of the moves that could follow it. 9

Assume the adversary is good. To evaluate an adversary s move, we should assume they pick a move that is good for them. To evaluate how good their moves are, we should assume we will do the best we can after their move (and so on ) 10

Static Evaluation Function At some point we must stop evaluating states recursively. At each leaf node we apply a static evaluation function to come up with an estimate of how good the node is from our perspective. We assume this function is not good enough to directly evaluate each choice, so we instead use it deeper in the tree. 11

Example evaluation functions Tic-Tac-Toe: number of rows, columns or diagonals with 2 of our pieces. Checkers: number of pieces we have - the number of pieces the opponent has. Chess: weighted sum of pieces: king=1000, queen=10, bishop=5, knight=5,... 12

Minimax Depth-first search with limited depth. Use a static evaluation function for all leaf states. Assume the opponent will make the best move possible. 13

Minimax Search Tree A Our Move Maximizing Ply B Opponent s Move Minimizing Ply C D E F G H I J K 9-6 0 0-2 -4-3 14

Minimax Algorithm Minimax(curstate, depth, player): If (depth==max) Return static(curstate,player) generate successor states s[1..n] If (player==me) Return max of Minimax(s[i],depth+1,OPPONENT) Else Return min of Minimax(s[i],depth+1,ME) 15

The Game of MinMax -3 2-1 -2 3 4 1-4 Start in the center square. Player MAX picks any number in the current row. Player MIN picks any number in the resulting column. The game ends when a player cannot move. MAX wins if the sum of numbers picked is > 0. 16

-3 2-1 -2 3 4 1-4 -3 2-1 -2 3 4 1-4 -3 2-1 -2 3 4 1-4 -3 2-1 3 4 1-4 -3 2-1 3 4 1-4 -3 2-1 -2 4 1-4 -3 2-1 -2 4 1-4 17

-3 2-1 3 4 1-4 MAX s Turn Max -3 Min Max Min Max 2 1 4-4 -1 3-1 3-4 1 4 2 18

Pruning We can use a branch-and-bound technique to reduce the number of states that must be examined to determine the value of a tree. We keep track of a lower bound on the value of a maximizing node, and don t bother evaluating any trees that cannot improve this bound. 19

Pruning in MinMax Max -3 Min Max Min Max 2 1 4-4 -1 3-1 3-4 1 4 2 20

Pruning Minimizing Nodes Keep track of an upper bound on the value of a minimizing node. Don t bother with any subtrees that cannot improve (lower) the bound. 21

Minimax with Alpha-Beta Cutoffs Alpha is the lower bound on maximizing nodes. Beta is the upper bound on minimizing nodes. Both alpha and beta get passed down the tree during the Minimax search. 22

Usage of Alpha & Beta At minimizing nodes, we stop evaluating children if we get a child whose value is less than the current lower bound (alpha). At maximizing nodes, we stop evaluating children as soon as we get a child whose value is greater than the current upper bound (beta). 23

Alpha & Beta At the root of the search tree, alpha is set to - and beta is set to +. Maximizing nodes update alpha from the values of children. Minimizing nodes update beta from the value of children. If alpha > beta, stop evaluating children. 24

Movement of Alpha and Beta Each node passes the current value of alpha and beta to each child node evaluated. Children nodes update their copy of alpha and beta, but do not pass alpha or beta back up the tree. Minimizing nodes return beta as the value of the node. Maximizing nodes return alpha as the value of the node. 25

A B C D E F G H 3 5 4 I J M N 5 7 8 K L 0 7 26

The Effectiveness of Alpha-Beta The effectiveness depends on the order in which children are visited. In the best case, the effective branching factor will be reduced from b to sqrt(b). In an average case (random values of leaves) the branching factor is reduced to b/logb. 27

The Horizon Effect Using a fixed depth search can lead to the following: A bad event is inevitable. The event is postponed by selecting only those moves in which the event is not visible (it is over the horizon). Extending the depth only moves the horizon, it doesn t eliminate the problem. 28

Quiescence Using a fixed depth search can lead to other problems: it s not fair to evaluate a board in the middle of an exchange of Chess pieces. What if we choose an odd number for the search depth on the game of MinMax? The evaluation function should only be applied to states that are quiescent (relatively stable). 29

Pattern-Directed Play Encode a bunch of patterns and some information that indicates what move should be selected if the game state ever matches the pattern. Book play: often used in Chess programs for the beginning and ending of games. 30

Iterative Deepening Many games have time constraints. It is hard to estimate how long the search to a fixed depth will take (due to pruning). Ideally we would like to provide the best answer we can, knowing that time could run out at any point in the search. One solution is to evaluate the choices with increasing depths. 31

Iterative Deepening There is lots of repetition! The repeated computation is small compared to the new computation. Example: branching factor 10 depth 3: 1,000 leaf nodes depth 4: 10,000 leaf nodes depth 5: 100,000 leaf nodes 32

A* Iterative Deepening Iterative deepening can also be used with A*. 1. Set THRESHOLD to be f(start_state). 2. Depth-first search, don t explore any nodes whose f value is greater than THRESHOLD. 3. If no solution is found, increase THRESHOLD and go back to step 2. 33