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

Similar documents
game tree complete all possible moves

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

mywbut.com Two agent games : alpha beta pruning

Adversary Search. Ref: Chapter 5

ARTIFICIAL INTELLIGENCE (CS 370D)

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

2 person perfect information

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

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

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

Adversarial Search 1

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

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

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

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

Game Playing AI Class 8 Ch , 5.4.1, 5.5

Games (adversarial search problems)

Adversarial Search (Game Playing)

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

Game-playing AIs: Games and Adversarial Search I AIMA

Artificial Intelligence. Minimax and alpha-beta pruning

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

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

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

CMPUT 396 Tic-Tac-Toe Game

Adversarial Search Aka Games

16.410/413 Principles of Autonomy and Decision Making

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

Artificial Intelligence

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

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

Programming Project 1: Pacman (Due )

Game Playing AI. Dr. Baldassano Yu s Elite Education

Game Tree Search 1/6/17

COMP9414: Artificial Intelligence Adversarial Search

Game-Playing & Adversarial Search

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

Rules of the game. chess checkers tic-tac-toe...

CSC384: Introduction to Artificial Intelligence. Game Tree Search

Game Playing Part 1 Minimax Search

More on games (Ch )

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

Adversarial Search: Game Playing. Reading: Chapter

Artificial Intelligence Adversarial Search

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

CS 771 Artificial Intelligence. Adversarial Search

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

Game Tree Search. Generalizing Search Problems. Two-person Zero-Sum Games. Generalizing Search Problems. CSC384: Intro to Artificial Intelligence

Game-Playing & Adversarial Search Alpha-Beta Pruning, etc.

Computer Game Programming Board Games

INF September 25, The deadline is postponed to Tuesday, October 3

Artificial Intelligence 1: game playing

More on games (Ch )

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

Rules of the game. chess checkers tic-tac-toe...

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

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

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

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

CS 4700: Artificial Intelligence

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

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

CS188 Spring 2010 Section 3: Game Trees

Artificial Intelligence Lecture 3

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

More Adversarial Search

Lecture 33: How can computation Win games against you? Chess: Mechanical Turk

Game Playing State-of-the-Art

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

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

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

CS 5522: Artificial Intelligence II

CS188 Spring 2010 Section 3: Game Trees

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

Midterm Examination. CSCI 561: Artificial Intelligence

Game Playing. Garry Kasparov and Deep Blue. 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.

Artificial Intelligence

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

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

CS 188: Artificial Intelligence Spring 2007

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

CS 4700: Foundations of Artificial Intelligence

Adversarial Search and Game Playing

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

CS 331: Artificial Intelligence Adversarial Search II. Outline

Game-playing: DeepBlue and AlphaGo

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

Ar#ficial)Intelligence!!

Artificial Intelligence. Topic 5. Game playing

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / September 23, 2013

CS 188: Artificial Intelligence Spring Announcements

Foundations of Artificial Intelligence

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

Artificial Intelligence

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

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

Foundations of Artificial Intelligence

Artificial Intelligence Search III

CS188 Spring 2014 Section 3: Games

Transcription:

Playing Games Henry Z. Lo June 23, 2014 1 Games We consider writing AI to play games with the following properties: Two players. Determinism: no chance is involved; game state based purely on decisions made by players. No hidden information: at any given time, both players have the same amount of knowledge. Finite states: a limited number of possible game states. By game state, we mean state of the board, which contains all the necessary information about the current game (along with whose turn it is). Games which satisfy these properties include checkers, chess, tic-tac-toe, and nim. 1.1 Game Trees Games satisfying these criteria can be represented completely using a game tree. The tree is built as such: The root represents the current game state. Every other node represents a possible future game state. Each node has as its children all game states which can be reached in one move. Thus, leaves of the tree signify ways in which the game can end. Paths from root to leaf represent how the game can evolve. As an example, consider the partial game tree for tic-tac-toe in Figure 1. It is important to know what player is making the current move. In the games mentioned here, each level corresponds to a different player. However, note that the game tree can accommodate players taking multiple turns in a row, as long as we know who is in control of the board at what node. 1

Figure 1: Incomplete game tree for tic-tac-toe, in which x goes first. 2

2 Game AI Given the entire game tree, it is possible to find the optimal sequence of moves, or paths, which solve the game. How can we score the paths? Consider if we were at the state s, which connects to several leaves. We can score winning move as a +1, a losing move as a -1, and a draw as a 0. What is the score of s? It may not be so important if we were already at s, but it is relevant if getting to s is an option. 2.1 Minimax The score depends on the player. We can assume that both us and our opponents will always take the best move available to them. If the move from s is ours, then we are in a pretty good position (we can get to 1). If the move from s is our opponents, then we will lose (opponent can get to -1). The minimax algorithm uses this notion to recursively label nodes in a tree based on its children. Labeling goes from leaf to root. Once we get to the root, we can see which paths will definitely lead us to a win. The minimax algorithm takes this path. See Figure 2. function minimax(node, depth, maximizingplayer) if depth = 0 or node is a terminal node return the heuristic value of node if maximizingplayer bestvalue := - for each child of node val := minimax(child, depth - 1, FALSE) bestvalue := max(bestvalue, val) return bestvalue else bestvalue := + for each child of node val := minimax(child, depth - 1, TRUE) bestvalue := min(bestvalue, val) return bestvalue (* Initial call for maximizing player *) minimax(origin, depth, TRUE) 3 Performance In practice, game trees can get very wide and deep, and evaluating them can take very long. There are some methods to counteract this. One method is to use heuristics to give a rough estimation of the value of a node. This heuristic will be used instead of recursive computation at some 3

Figure 2: State scores +1 if it leads to a win for X, and -1 if it leads to a win for O. 4

depth, so that we don t have to traverse down a very deep tree. An example of a heuristic is the ratio of pieces in a checkers game. Another method is to use memoization. In games with overlapping subproblems (of which there are many), it may be useful to cache values of pre-computed trees. However, this may require a lot of memory to be used, especially in complex games. 4 Alpha-Beta pruning It stops completely evaluating a move when at least one possibility has been found that proves the move to be worse than a previously examined move. Such moves need not be evaluated further. When applied to a standard minimax tree, it returns the same move as minimax would, but prunes away branches that cannot possibly influence the final decision function alphabeta(node, depth,,, maximizingplayer) 02 if depth = 0 or node is a terminal node 03 return the heuristic value of node 04 if maximizingplayer 05 for each child of node 06 := max(, alphabeta(child, depth - 1,,, FALSE)) 07 if 08 break (* cut-off *) 09 return 10 else 11 for each child of node 12 := min(, alphabeta(child, depth - 1,,, TRUE)) 13 if 14 break (* cut-off *) 15 return 5