Game Playing. Philipp Koehn. 29 September 2015

Similar documents
Game playing. Chapter 6. Chapter 6 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

CS 380: ARTIFICIAL INTELLIGENCE

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

Game playing. Outline

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

ADVERSARIAL SEARCH. Chapter 5

Game Playing: Adversarial Search. Chapter 5

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

Game playing. Chapter 5. Chapter 5 1

Lecture 5: Game Playing (Adversarial Search)

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

Game playing. Chapter 5, Sections 1 6

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

Adversarial search (game playing)

Today. Nondeterministic games: backgammon. Algorithm for nondeterministic games. Nondeterministic games in general. See Russell and Norvig, chapter 6

Artificial Intelligence. Topic 5. Game playing

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

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

CS 188: Artificial Intelligence Spring Game Playing in Practice

Programming Project 1: Pacman (Due )

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

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

CS 188: Artificial Intelligence

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

Adversarial Search Lecture 7

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

COMP219: Artificial Intelligence. Lecture 13: Game Playing

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

Adversarial Search and Game Playing

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

CS 188: Artificial Intelligence Spring Announcements

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

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

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

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. Chapter 5. Mausam (Based on slides of Stuart Russell, Andrew Parks, Henry Kautz, Linda Shapiro) 1

Artificial Intelligence

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

CS 188: Artificial Intelligence Spring 2007

Game-Playing & Adversarial Search

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

CS 5522: Artificial Intelligence II

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

Adversarial Search. CMPSCI 383 September 29, 2011

Artificial Intelligence

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

Artificial Intelligence

CS 331: Artificial Intelligence Adversarial Search II. Outline

Games and Adversarial Search

CSE 473: Artificial Intelligence. Outline

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

Artificial Intelligence Adversarial Search

CS 188: Artificial Intelligence. Overview

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 1: game playing

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

CS 188: Artificial Intelligence

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

CSE 573: Artificial Intelligence Autumn 2010

Game Playing State of the Art

Artificial Intelligence

School of EECS Washington State University. Artificial Intelligence

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

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

Adversarial Search Aka Games

Ar#ficial)Intelligence!!

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

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

Artificial Intelligence

CS 771 Artificial Intelligence. Adversarial Search

Adversarial Search 1

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

CSE 573: Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence

Intuition Mini-Max 2

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence

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

CSE 473: Artificial Intelligence Autumn 2011

Pengju

Artificial Intelligence. Minimax and alpha-beta pruning

Solving Problems by Searching: Adversarial Search

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

Contents. Foundations of Artificial Intelligence. Problems. Why Board Games?

Adversarial Search (Game Playing)

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

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

Game Playing AI Class 8 Ch , 5.4.1, 5.5

Game-playing AIs: Games and Adversarial Search I AIMA

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

CSE 473: Ar+ficial Intelligence

Adversarial Search: Game Playing. Reading: Chapter

More Adversarial Search

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

Game-playing: DeepBlue and AlphaGo

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

Transcription:

Game Playing Philipp Koehn 29 September 2015

Outline 1 Games Perfect play minimax decisions α β pruning Resource limits and approximate evaluation Games of chance Games of imperfect information

2 games

Games vs. Search Problems 3 Unpredictable opponent solution is a strategy specifying a move for every possible opponent reply Time limits unlikely to find goal, must approximate Plan of attack: computer considers possible lines of play (Babbage, 1846) algorithm for perfect play (Zermelo, 1912; Von Neumann, 1944) finite horizon, approximate evaluation (Zuse, 1945; Wiener, 1948; Shannon, 1950) first Chess program (Turing, 1951) machine learning to improve evaluation accuracy (Samuel, 1952 57) pruning to allow deeper search (McCarthy, 1956)

Types of Games 4 deterministic chance perfect information Chess Checkers Go Othello Backgammon Monopoly imperfect information battleships Blind Tic Tac Toe Bridge Poker Scrabble

Game Tree (2-player, Deterministic, Turns) 5

Simple Game Tree 6 2 player game Each player has one move You move first Goal: optimize your payoff (utility) Start Your move Opponent move Your payoff

7 minimax

Minimax 8 Perfect play for deterministic, perfect-information games Idea: choose move to position with highest minimax value = best achievable payoff against best play E.g., 2-player game, one move each:

Minimax Algorithm 9 function MINIMAX-DECISION(state) returns an action inputs: state, current state in game return the a in ACTIONS(state) maximizing MIN-VALUE(RESULT(a, state)) function MAX-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v for a, s in SUCCESSORS(state) do v MAX(v, MIN-VALUE(s)) return v function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v for a, s in SUCCESSORS(state) do v MIN(v, MAX-VALUE(s)) return v

Properties of Minimax 10 Complete? Optimal? Yes, if tree is finite Yes, against an optimal opponent. Otherwise?? Time complexity? O(b m ) Space complexity? O(bm) (depth-first exploration) For Chess, b 35, m 100 for reasonable games exact solution completely infeasible But do we need to explore every path?

α β Pruning Example 11

α β Pruning Example 12

α β Pruning Example 13

α β Pruning Example 14

α β Pruning Example 15

α β Pruning Example 16

α β Pruning Example 17

Why is it Called α β? 18 α 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

The α β Algorithm 19 function ALPHA-BETA-DECISION(state) returns an action return the a in ACTIONS(state) maximizing MIN-VALUE(RESULT(a, state)) function MAX-VALUE(state, α, β) returns a utility value inputs: state, current state in game α, the value of the best alternative for MAX along the path to state β, the value of the best alternative for MIN along the path to state if TERMINAL-TEST(state) then return UTILITY(state) v for a, s in SUCCESSORS(state) do v MAX(v, MIN-VALUE(s, α, β)) if v β then return v α MAX(α, v) return v function MIN-VALUE(state, α, β) returns a utility value same as MAX-VALUE but with roles of α, β reversed

Properties of α β 20 Safe: Pruning does not affect final result Good move ordering improves effectiveness of pruning With perfect ordering, time complexity = O(b m/2 ) 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!

Solved Games 21 A game is solved if optimal strategy can be computed Tic Tac Toe can be trivially solved Biggest solved game: Checkers proof by Schaeffer in 2007 both players can force at least a draw Most games (Chess, Go, etc.) too complex to be solved

22 resource limits

Resource Limits 23 Standard approach: Use CUTOFF-TEST instead of TERMINAL-TEST e.g., depth limit (perhaps add quiescence search) Use EVAL instead of UTILITY i.e., evaluation function that estimates desirability of position Suppose we have 100 seconds, explore 10 4 nodes/second 10 6 nodes per move 35 8/2 α β reaches depth 8 pretty good Chess program

Evaluation Functions 24 For Chess, typically linear weighted sum of features Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) +... + w n f n (s) e.g., f 1 (s) = (number of white queens) (number of black queens)

Evaluation Function for Chess 25 Long experience of playing Chess Evaluation of positions included in Chess strategy books bishop is worth 3 pawns knight is worth 3 pawns rook is worth 5 pawns good pawn position is worth 0.5 pawns king safety is worth 0.5 pawns etc. Pawn count weight for features

Learning Evaluation Functions 26 Designing good evaluation functions requires a lot of expertise Machine learning approach collect a large database of games play note for each game who won try to predict game outcome from features of position learned weights May also learn evaluation functions from self-play

Some Concerns 27 Quiescence position evaluation not reliable if board is unstable e.g., Chess: queen will be lost in next move deeper search of game-changing moves required Horizon Effect adverse move can be delayed, but not avoided search may prefer to delay, even if costly

Forward Pruning 28 Idea: avoid computation on clearly bad moves Cut off searches with bad positions before they reach max-depth Risky: initially inferior positions may lead to better positions Beam search: explore fixed number of promising moves deeper

Lookup instead of Search 29 Library of opening moves even expert Chess players use standard opening moves these can be memorized and followed until divergence End game if only few pieces left, optimal final moves may be computed Chess end game with 6 pieces left solved in 2006 can be used instead of evaluation function

Digression: Exact Values do not Matter 30 Behaviour is preserved under any monotonic transformation of EVAL Only the order matters: payoff in deterministic games acts as an ordinal utility function

Deterministic Games in Practice 31 Checkers: 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. Weakly solved in 2007 by Schaeffer (guaranteed draw). Chess: Deep Blue defeated human world champion Gary Kasparov in a sixgame match in 1997. Deep Blue searches 200 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply. Othello: human champions refuse to compete against computers, who are too good. Go: human champions refuse to compete against computers, who are too bad. In go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves.

32 games of chance

Nondeterministic Games: Backgammon 33

Nondeterministic Games in General 34 In nondeterministic games, chance introduced by dice, card-shuffling Simplified example with coin-flipping:

Algorithm for Nondeterministic Games 35 EXPECTIMINIMAX gives perfect play Just like MINIMAX, except we must also handle chance nodes:... if state is a MAX node then return the highest EXPECTIMINIMAX-VALUE of SUCCESSORS(state) if state is a MIN node then return the lowest EXPECTIMINIMAX-VALUE of SUCCESSORS(state) if state is a chance node then return average of EXPECTIMINIMAX-VALUE of SUCCESSORS(state)...

Pruning in Nondeterministic Game Trees 36 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 37 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 38 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 39 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 40 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 41 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 42 A version of α-β pruning is possible:

Pruning in Nondeterministic Game Trees 43 Terminate, since right path will be worth on average.

Pruning with Bounds 44 More pruning occurs if we can bound the leaf values (0,1,2)

Pruning with Bounds 45 More pruning occurs if we can bound the leaf values (0,1,2)

Pruning with Bounds 46 More pruning occurs if we can bound the leaf values (0,1,2)

Pruning with Bounds 47 More pruning occurs if we can bound the leaf values (0,1,2)

Pruning with Bounds 48 More pruning occurs if we can bound the leaf values (0,1,2)

Pruning with Bounds 49 More pruning occurs if we can bound the leaf values (0,1,2)

Nondeterministic Games in Practice 50 Dice rolls increase b: 21 possible rolls with 2 dice Backgammon 20 legal moves (can be 6,000 with 1-1 roll) depth 4 = 20 (21 20) 3 1.2 10 9 As depth increases, probability of reaching a given node shrinks value of lookahead is diminished α β pruning is much less effective TDGAMMON uses depth-2 search + very good EVAL world-champion level

Digression: Exact Values Do Matter 51 Behaviour is preserved only by positive linear transformation of EVAL Hence EVAL should be proportional to the expected payoff

52 imperfect information

Games of Imperfect Information 53 E.g., card games, where opponent s initial cards are unknown Typically we can calculate a probability for each possible deal Seems just like having one big dice roll at the beginning of the game Idea: compute the minimax value of each action in each deal, then choose the action with highest expected value over all deals Special case: if an action is optimal for all deals, it s optimal.

Commonsense Counter-Example 54 Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll find a mound of jewels; take the right fork and you ll be run over by a bus. Road A leads to a small heap of gold pieces Road B leads to a fork: take the left fork and you ll be run over by a bus; take the right fork and you ll find a mound of jewels. Road A leads to a small heap of gold pieces Road B leads to a fork: guess correctly and you ll find a mound of jewels; guess incorrectly and you ll be run over by a bus.

Proper Analysis 55 Intuition that the value of an action is the average of its values in all actual states is WRONG With partial observability, value of an action depends on the information state or belief state the agent is in Can generate and search a tree of information states Leads to rational behaviors such as acting to obtain information signalling to one s partner acting randomly to minimize information disclosure

Computer Poker 56 Hard game imperfect information including bluffing and trapping stochastic outcomes cards drawn at random partially observable may never see other players hand when they fold non-cooperative multi-player possibility for coalitions Few moves (fold, call, raise), but large number of stochastic states Relative balance of deception plays very important also: when to bluff There is no single best move Need to model other players (style, collusion, patterns) Hard to evaluate (not just win/loss, different types of opponents)

Summary 57 Games are fun to work on They illustrate several important points about AI perfection is unattainable 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 Games are to AI as grand prix racing is to automobile design