Game-playing AIs: Games and Adversarial Search I AIMA

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

ARTIFICIAL INTELLIGENCE (CS 370D)

Games and Adversarial Search II

Adversarial Search Aka Games

Adversarial Search (Game Playing)

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

Game Playing AI Class 8 Ch , 5.4.1, 5.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

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

Artificial Intelligence. Minimax and alpha-beta pruning

Game-Playing & Adversarial Search

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

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

CS 771 Artificial Intelligence. Adversarial Search

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

Adversary Search. Ref: Chapter 5

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

Adversarial Search 1

CS 5522: Artificial Intelligence II

Game Playing State-of-the-Art

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

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

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

Game Playing. Philipp Koehn. 29 September 2015

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

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

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

Artificial Intelligence

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

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

Games (adversarial search problems)

Artificial Intelligence

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

Programming Project 1: Pacman (Due )

game tree complete all possible moves

Artificial Intelligence Adversarial Search

Artificial Intelligence 1: game playing

Adversarial Search: Game Playing. Reading: Chapter

Adversarial Search Lecture 7

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

Adversarial Search and Game Playing

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

Game playing. Outline

Ar#ficial)Intelligence!!

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

Adversarial Search. CMPSCI 383 September 29, 2011

CS 188: Artificial Intelligence

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

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

ADVERSARIAL SEARCH. Chapter 5

CS 4700: Foundations of Artificial Intelligence

CS 188: Artificial Intelligence Spring Announcements

CS 188: Artificial Intelligence Spring 2007

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

Artificial Intelligence

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

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

CS 188: Artificial Intelligence

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

Game playing. Chapter 6. Chapter 6 1

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

CS 331: Artificial Intelligence Adversarial Search II. Outline

Games and Adversarial Search

Game Playing Part 1 Minimax Search

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

Game Playing: Adversarial Search. Chapter 5

mywbut.com Two agent games : alpha beta pruning

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

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

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

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

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Path Planning as Search

Adversarial search (game playing)

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

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

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

Game playing. Chapter 6. Chapter 6 1

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

More Adversarial Search

Game playing. Chapter 5. Chapter 5 1

Artificial Intelligence. Topic 5. Game playing

CS 380: ARTIFICIAL INTELLIGENCE

CSE 473: Artificial Intelligence. Outline

Foundations of Artificial Intelligence

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

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

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

CS188 Spring 2010 Section 3: Game Trees

2 person perfect information

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

Game playing. Chapter 5, Sections 1 6

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

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

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

CS 730/730W/830: Intro AI

Foundations of Artificial Intelligence

Lecture 5: Game Playing (Adversarial Search)

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

Transcription:

Game-playing AIs: Games and Adversarial Search I AIMA 5.1-5.2

Games: Outline of Unit Part I: Games as Search Motivation Game-playing AI successes Game Trees Evaluation Functions Part II: Adversarial Search The Minimax Rule Alpha-Beta Pruning CIS 421/521 - Intro to AI 2

May 11, 1997 CIS 421/521 - Intro to AI 4

Ratings of human & computer chess champions https://srconstantin.wordpress.com/2017/01/28/performance-trends-in-ai/ CIS 421/521 - Intro to AI 5

(from: The Guardian) CIS 521 - Intro to AI - Fall 2016 6

https://srconstantin.wordpress.com /2017/01/28/performance-trendsin-ai/ CIS 521 - Intro to AI - Fall 2017 7

The Simplest Game Environment Multiagent Static: No change while an agent is deliberating Discrete: A finite set of percepts and actions Fully observable : An agent's sensors give it the complete state of the environment. Strategic: The next state is determined by the current state and the action executed by the agent and the actions of one other agent. CIS 421/521 - Intro to AI 9

Key properties of our sample games 1. Two players alternate moves 2. Zero-sum: one player s loss is another s gain 3. Clear set of legal moves 4. Well-defined outcomes (e.g. win, lose, draw) Examples: Chess, Checkers, Go, Mancala, Tic-Tac-Toe, Othello, Nim, CIS 421/521 - Intro to AI 10

More complicated games Most card games (e.g. Hearts, Bridge, etc.) and Scrabble Stochastic, not deterministic Not fully observable: lacking in perfect information Real-time strategy games (lack alternating moves). e.g. Warcraft Cooperative games CIS 421/521 - Intro to AI 11

A cooperative multi-agent environment: Pragbot Two players, Commander and Junior, must coordinate to: Tasks: Defuse bombs that can kill Commander Defeat badguys before they flip Junior and/or escape Rescue hostages CIS 421/521 - Intro to AI 12

Formalizing the Game setup 1. Two players: MAX and MIN; MAX moves first. 2. MAX and MIN take turns until the game is over. 3. Winner gets award, loser gets penalty. Games as search: Initial state: e.g. board configuration of chess Successor function: list of (move,state) pairs specifying legal moves. Terminal test: Is the game finished? Utility function: Gives numerical value of terminal states. e.g. win (+ ), lose (- ) and draw (0) MAX uses search tree to determine next move. CIS 421/521 - Intro to AI 13

How to Play a Game by Searching General Scheme 1. Consider all legal successors to the current state ( board position ) 2. Evaluate each successor board position 3. Pick the move which leads to the best board position. 4. After your opponent moves, repeat. Design issues 1. Representing the board 2. Representing legal next boards 3. Evaluating positions 4. Looking ahead CIS 421/521 - Intro to AI 14

Hexapawn: A very simple Game Hexapawn is played on a 3x3 chessboard Only standard pawn moves: 1. A pawn moves forward one square onto an empty square 2. A pawn captures an opponent pawn by moving diagonally forward one square, if that square contains an opposing pawn. The opposing pawn is removed from the board. CIS 421/521 - Intro to AI 15

Hexapawn: A very simple Game Hexapawn is played on a 3x3 chessboard Player P 1 wins the game against P 2 when: One of P 1 s pawns reaches the far side of the board. P 2 cannot move because no legal move is possible. P 2 has no pawns left. (Invented by Martin Gardner in 1962, with learning program using match boxes. Reprinted in The Unexpected Hanging..) CIS 421/521 - Intro to AI 16

Hexapawn: Three Possible First Moves White moves CIS 421/521 - Intro to AI 17

Game Trees Represent the game problem space by a tree: Nodes represent board positions ; edges represent legal moves. Root node is the first position in which a decision must be made. CIS 421/521 - Intro to AI 18

Hexapawn: Simplified Game Tree for 2 Moves White to move Black to move.. White to move CIS 421/521 - Intro to AI 19

MAX & MIN Nodes : An egocentric view Two players: MAX, MAX s opponent MIN All play is computed from MAX s vantage point. When MAX moves, MAX attempts to MAXimize MAX s outcome. When MAX s opponent moves, they attempt to MINimize MAX s outcome. WE TYPICALLY ASSUME MAX MOVES FIRST: Label the root (level 0) MAX Alternate MAX/MIN labels at each successive tree level (ply). Even levels represent turns for MAX Odd levels represent turns for MIN MAX (von Sydow) plays chess. CIS 421/521 - Intro to AI 20

Game Trees Represent the game problem space by a tree: Nodes represent board positions ; edges represent legal moves. Root node is the first position in which a decision must be made. Evaluation function f assigns real-number scores to `board positions without reference to path Terminal nodes represent ways the game could end, labeled with the desirability of that ending (e.g. win/lose/draw or a numerical score) CIS 421/521 - Intro to AI 21

Evaluation functions: f(n) Evaluates how good a board position is Based on static features of that board alone Zero-sum assumption lets us use one function to describe goodness for both players. f(n)>0 if MAX is winning in position n f(n)=0 if position n is tied f(n)<0 if MIN is winning in position n Build using expert knowledge, Tic-tac-toe: f(n)=(# of 3 lengths open for MAX)- (# open for MIN) (AIMA 5.4.1) CIS 421/521 - Intro to AI 22

A Partial Game Tree for Tic-Tac-Toe f(n)=8-8=0 f(n)=8-5=3 f(n)=2 f(n)=3 f(n)=2 f(n)=4 f(n)=2 f(n)=3 f(n)=2 f(n)=3 f(n)=6-5=1 f(n)=0 f(n)=1 f(n)=6-3=3 f(n)=6-4=2-0 + f(n)=6-2=4 f(n)=# of potential three-lines for X # of potential three-line for Y if n is not terminal f(n)=0 if n is a terminal tie f(n)=+ if n is a terminal win f(n)=- if n is a terminal loss CIS 421/521 - Intro to AI 23

Chess Evaluation Functions Alan Turing s f(n)=(sum of A s piece values)-(sum of B s piece values) Pawn 1.0 Knight 3.0 Bishop 3.25 Rook 5.0 Queen 9.0 More complex: weighted sum of positional features: w i feature (n) Deep Blue has > 8000 features i Pieces values for a simple Turing-style evaluation function often taught to novice chess players Positive: rooks on open files, knights in closed positions, control of the center, developed pieces Negative: doubled pawns, wrong-colored bishops in closed positions, isolated pawns,pinned pieces Examples of more complex features CIS 421/521 - Intro to AI 24

Some Chess Positions and their Evaluations White to move f(n)=(9+3)-(5+5+3.25) =-1.25 Nxg5?? f(n)=(9+3)-(5+5) =2 So, considering our opponent s possible responses would be wise. Uh-oh: Rxg4+ f(n)=(3)-(5+5) =-7 And black may force checkmate CIS 421/521 - Intro to AI 25

The Minimax Rule (AIMA 5.2)

The Minimax Rule: `Don t play hope chess Idea: Make the best move for MAX assuming that MIN always replies with the best move for MIN Easily computed by a recursive process The backed-up value of each node in the tree is determined by the values of its children: For a MAX node, the backed-up value is the maximum of the values of its children (i.e. the best for MAX) For a MIN node, the backed-up value is the minimum of the values of its children (i.e. the best for MIN) CIS 421/521 - Intro to AI 27

The Minimax Procedure Until game is over: 1. Start with the current position as a MAX node. 2. Expand the game tree a fixed number of ply. 3. Apply the evaluation function to the leaf positions. 4. Calculate back-up values bottom-up. 5. Pick the move assigned to MAX at the root 6. Wait for MIN to respond CIS 421/521 - Intro to AI 28

2-ply Example: Backing up values MAX MIN 2 2 7 1 8 2 1 2 7 1 8 2 1 2 7 1 8 Evaluation function value 2 This is the move selected by minimax 2 1 2 7 1 8 CIS 421/521 - Intro to AI 29

What if MIN does not play optimally? Definition of optimal play for MAX assumes MIN plays optimally: Maximizes worst-case outcome for MAX. (Classic game theoretic strategy) But if MIN does not play optimally, MAX will do even better. [Theorem-not hard to prove] CIS 421/521 - Intro to AI 30

Comments on Minimax Search Depth-first search with fixed number of ply m as the limit. O(b m ) time complexity As usual! O(bm) space complexity Performance will depend on the quality of the static evaluation function (expert knowledge) depth of search (computing power and search algorithm) Differences from normal state space search Looking to make one move only, despite deeper search No cost on arcs costs from backed-up static evaluation MAX can t be sure how MIN will respond to his moves Minimax forms the basis for other game tree search algorithms. CIS 421/521 - Intro to AI 31

IF TIME ALLOWS. CIS 421/521 - Intro to AI 32

Alpha-Beta Pruning (AIMA 5.3) Many slides adapted from Richard Lathrop, USC/ISI, CS 271

Alpha-Beta Pruning A way to improve the performance of the Minimax Procedure Basic idea: If you have an idea which is surely bad, don t take the time to see how truly awful it is ~ Pat Winston =2 >=2 <=1 We don t need to compute the value at this node. 2 7 1? No matter what it is it can t effect the value of the root node. CIS 421/521 - Intro to AI 34

Alpha-Beta Pruning II During Minimax, keep track of two additional values: α: MAX s current lower bound on MAX s outcome β: MIN s current upper bound on MIN s outcome MAX will never allow a move that could lead to a worse score (for MAX) than α MIN will never allow a move that could lead to a better score (for MAX) than β Therefore, stop evaluating a branch whenever: When evaluating a MAX node: a value v β is backed-up MIN will never select that MAX node When evaluating a MIN node: a value v α is found MAX will never select that MIN node CIS 421/521 - Intro to AI 35

Alpha-Beta Pruning IIIa Based on observation that for all viable paths utility value f(n) will be α <= f(n) <= β Initially, α = -infinity, β=infinity As the search tree is traversed, the possible utility value window shrinks as α increases, β decreases CIS 421/521 - Intro to AI 36

Alpha-Beta Pruning IIIb Whenever the current ranges of alpha and beta no longer overlap, it is clear that the current node is a dead end CIS 421/521 - Intro to AI 37

Tic-Tac-Toe Example with Alpha-Beta Pruning Backup Values 1 CIS 421/521 - Intro to AI 38