COMP219: Artificial Intelligence. Lecture 13: Game Playing

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

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

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

Game playing. Chapter 6. Chapter 6 1

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

Game playing. Chapter 5. Chapter 5 1

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. Philipp Koehn. 29 September 2015

Adversarial Search. CMPSCI 383 September 29, 2011

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

CS 380: ARTIFICIAL INTELLIGENCE

Game playing. Outline

Programming Project 1: Pacman (Due )

Game Playing: Adversarial Search. Chapter 5

Lecture 5: Game Playing (Adversarial Search)

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

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

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

Adversarial search (game playing)

Artificial Intelligence. Topic 5. Game playing

Artificial Intelligence Search III

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

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

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

Adversarial Search Lecture 7

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

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

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

CS 188: Artificial Intelligence Spring Announcements

CSE 473: Artificial Intelligence. Outline

Game Playing State-of-the-Art

CS 5522: Artificial Intelligence II

CS 188: Artificial Intelligence Spring 2007

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

Artificial Intelligence Adversarial Search

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

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

CS 188: Artificial Intelligence

Artificial Intelligence

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

CS 188: Artificial Intelligence Spring Game Playing in Practice

Game playing. Chapter 5, Sections 1 6

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

ADVERSARIAL SEARCH. Chapter 5

CS 188: Artificial Intelligence

ARTIFICIAL INTELLIGENCE (CS 370D)

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

CS 188: Artificial Intelligence. Overview

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

Artificial Intelligence

Game Playing AI Class 8 Ch , 5.4.1, 5.5

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

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

Intuition Mini-Max 2

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

Adversarial Search (Game Playing)

CSE 573: Artificial Intelligence Autumn 2010

Game Playing State of the Art

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

Artificial Intelligence. Minimax and alpha-beta pruning

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

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

CS 771 Artificial Intelligence. Adversarial Search

CS 4700: Foundations of Artificial Intelligence

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

Game-Playing & Adversarial Search

CSE 573: Artificial Intelligence

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

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

CS 331: Artificial Intelligence Adversarial Search II. Outline

Games (adversarial search problems)

Artificial Intelligence

Adversarial Search Aka Games

Adversarial Search and Game Playing

Pengju

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

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

Adversarial Search 1

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

Artificial Intelligence

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

Games and Adversarial Search

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

Game-playing: DeepBlue and AlphaGo

Ar#ficial)Intelligence!!

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

Artificial Intelligence. 4. Game Playing. Prof. Bojana Dalbelo Bašić Assoc. Prof. Jan Šnajder

Foundations of Artificial Intelligence

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

Foundations of Artificial Intelligence

Adversarial Search: Game Playing. Reading: Chapter

Adversary Search. Ref: Chapter 5

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

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

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

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

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

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

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

Transcription:

CMP219: Artificial Intelligence Lecture 13: Game Playing 1

verview Last time Search with partial/no observations Belief states Incremental belief state search Determinism vs non-determinism Today We will look at how search can be applied to playing games Types of games Perfect play minimax decisions alpha beta pruning Playing with limited recourses 2

Games and Search In search we make all the moves. In games we play against an unpredictable opponent Solution is a strategy specifying a move for every possible opponent reply Assume that the opponent is intelligent: always makes the best move Some method is needed for selecting good moves that stand a good chance of achieving a winning position, whatever the opponent does! There are time limits, so we are unlikely to find goal, and must approximate using heuristics 3

Types of Game In some games we have perfect information the position is known completely In others we have imperfect information: e.g. we cannot see the opponent s cards Some games are deterministic no random element thers have elements of chance (dice, cards) 4

Types of Games 5

We will consider: Games that are: Deterministic Two-player Zero-sum the utility values at the end are equal and opposite example: one wins (+1) the other loses ( 1) Perfect information E.g. thello, Blitz Chess 6

Problem Formulation Initial state Initial board position, player to move Transition model List of (move, state) pairs, one per legal move Terminal test Determines when the game is over Utility function Numeric value for terminal states e.g. Chess +1, -1, 0 e.g. Backgammon +192 to -192 7

Noughts and Crosses 8

Noughts and Crosses 9

Noughts and Crosses +1 +1 10

Noughts and Crosses +1 +1 11

Noughts and Crosses +1-1 +1 12

Noughts and Crosses +1-1 +1 13

Noughts and Crosses +1-1 +1 +1 14

Game Tree Each level labelled with player to move Each level represents a ply Half a turn Represents what happens with competing agents 15

Introducing MIN and MA MIN and MA are two players: MA wants to win (maximise utility) MIN wants MA to lose (minimise utility for MA) MIN is the pponent Both players will play to the best of their ability MA wants a strategy for maximising utility assuming MIN will do best to minimise MA s utility Consider minimax value of each node 16

Example Game Tree Minimax value of a node is the value of the best terminal node, assuming Best play by opponent 17

Minimax Value Utility for MA of being in that state assuming both players play optimally to the end of the game Formally: 18

Minimax Algorithm Calculate minimaxvalue of each node recursively Depth-first exploration of tree Game tree as minimax tree Max Node: Min Node 19

Minimax Tree 20

Minimax Tree 3 12 8 21

Minimax Tree Min takes the lowest value from its children 3 3 12 8 22

Minimax Tree Min takes the lowest value from its children 3 3 12 8 2 4 6 23

Minimax Tree Min takes the lowest value from its children 3 2 3 12 8 2 4 6 24

Minimax Tree Min takes the lowest value from its children 3 2 3 12 8 2 4 6 14 5 2 25

Minimax Tree Min takes the lowest value from its children 3 2 2 3 12 8 2 4 6 14 5 2 26

Minimax Tree 3 Min takes the lowest value from its children Max takes the highest value from its children 3 2 2 3 12 8 2 4 6 14 5 2 27

Exercise Perform the minimax search algorithm on the following tree to get the minimax value of the root: 28

Exercise 6 4 7 6 8 11 1 2 29

Exercise 6 6 2 6 7 11 2 6 4 7 6 8 11 1 2 30

Properties of Minimax Complete, if tree is finite ptimal, against an optimal opponent. therwise?? No. e.g. expected utility against random player Time complexity: b m Space complexity: bm (depth-first exploration) For chess, b 35, m 100 for reasonable games Infeasible so typically set a limit on look ahead. Can still use minimax, but the terminal node is deeper on every move, so there can be surprises. No longer optimal But do we need to explore every path? 31

Pruning Basic idea: If you know half-way through a calculation that it will succeed or fail, then there is no point in doing the rest of it For example, in Java it is clear that when evaluating statements like if ((A > 4) (B < 0)) If A is 5 we do not have to check on B! 32

Alpha-Beta Pruning 33

Alpha-Beta Pruning 3 12 8 34

Alpha-Beta Pruning 3 3 12 8 35

Alpha-Beta Pruning 3 3 3 12 8 36

Alpha-Beta Pruning 3 3 3 12 8 2 37

Alpha-Beta Pruning 3 3 2 3 12 8 2 38

Alpha-Beta Pruning 3 3 2 3 12 8 2 14 39

Alpha-Beta Pruning 3 3 2 14 3 12 8 2 14 40

Alpha-Beta Pruning 3 3 2 14 3 12 8 2 14 5 41

Alpha-Beta Pruning 3 3 2 5 3 12 8 2 14 5 42

Alpha-Beta Pruning 3 3 2 5 3 12 8 2 14 5 2 43

Alpha-Beta Pruning 3 3 2 2 3 12 8 2 14 5 2 44

Alpha-Beta Pruning 3 3 2 2 3 12 8 2 14 5 2 45

Why is it called alpha-beta? 46

The Alpha-Beta Algorithm alpha (α) is value of best (highest value) choice for MA beta (β) is value of best (lowest value) choice for MIN If at a MIN node and value α, stop looking, because MA node will ignore this choice If at a MA node and value β beta, stop looking because MIN node will ignore this choice 47

Properties of Alpha-Beta Pruning does not affect final result Good move ordering improves effectiveness of pruning With perfect ordering time complexity b m/2 and so doubles solvable depth A simple example of the value of reasoning about which computations are relevant (a form of metareasoning) Unfortunately, 35 50 is still impossible, so chess not completely soluble 48

Cutoffs and Heuristics Cut off search according to some cutoff test Simplest is a depth limit Problem: payoffs are defined only at terminal states Solution: Evaluate the pre-terminal leaf states using heuristic evaluation function rather than using the actual payoff function 49

Cutoff Value To handle the cutoff, in minimax or alpha-beta search we can make an alteration by making use of a cutoff value MinimaxCutof is identical to MinimaxValue except 1. Terminal test is replaced by Cutof test, which indicates when to apply the evaluation function 2. Utility is replaced by Evaluation function, which estimates the position s utility 50

Example: Chess (I) Assume MA is white Assume each piece has the following material value: pawn = 1 knight = 3 bishop = 3 rook = 5 queen = 9 let w = sum of the value of white pieces let b = sum of the value of black pieces 51

Example: Chess (II) The previous evaluation function naively gave the same weight to a piece regardless of its position on the board... Let i be the number of squares the i-th piece attacks Evaluation(n) = piece 1 value * 1 + piece 2 value * 2 +... 52

Example: Chess (III) Heuristics based on database search Statistics of wins in the position under consideration Database defining perfect play for all positions involving or fewer pieces on the board (endgames) penings are extensively analysed, so can play the first few moves from the book 53

Deterministic Games in Practice Draughts: Chinook ended 40-year-reign of human world champion Marion Tinsley in 1994. Used 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 Chess: Deep Blue defeated human world champion Gary Kasparov in a six-game match in 1997. Deep Blue searches 200 million positions per second, used very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply 54

Deterministic Games in Practice thello: human champions refuse to compete against computers, who are too good Go: a challenging game for AI (b > 300) so progress much slower with computers. AlphaGo was a recent breakthrough See more at: University of Alberta GAMES Group 55

Summary Games have been an AI topic since the beginning. They illustrate several important features of AI: perfection is unattainable so must approximate good idea to think about what to think about uncertainty constrains the assignment of values to states optimal decisions depend on information state, not real state Next lecture: We have now finished with the topic of search so we will move on to knowledge representation 56