Artificial Intelligence Lecture 3

Similar documents
ARTIFICIAL INTELLIGENCE (CS 370D)

Artificial Intelligence. Minimax and alpha-beta pruning

2 person perfect information

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

CS 771 Artificial Intelligence. Adversarial Search

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

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

Adversarial Search 1

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

mywbut.com Two agent games : alpha beta pruning

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 tree complete all possible moves

Adversarial Search (Game Playing)

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

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

Game-Playing & Adversarial Search

Games (adversarial search problems)

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

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

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

Adversary Search. Ref: Chapter 5

Problem 1. (15 points) Consider the so-called Cryptarithmetic problem shown below.

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

Programming Project 1: Pacman (Due )

Artificial Intelligence Search III

Adversarial Search: Game Playing. Reading: Chapter

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

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

CMPUT 396 Tic-Tac-Toe Game

Artificial Intelligence 1: game playing

CS 4700: Artificial Intelligence

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

Introduction to Artificial Intelligence CS 151 Programming Assignment 2 Mancala!! Due (in dropbox) Tuesday, September 23, 9:34am

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

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

Artificial Intelligence Adversarial Search

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

For slightly more detailed instructions on how to play, visit:

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

CS 4700: Foundations of Artificial Intelligence

Game Playing AI Class 8 Ch , 5.4.1, 5.5

CS 5522: Artificial Intelligence II

Heuristics, and what to do if you don t know what to do. Carl Hultquist

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

CSE 573: Artificial Intelligence Autumn 2010

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

COMP5211 Lecture 3: Agents that Search

CS 331: Artificial Intelligence Adversarial Search II. Outline

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

Midterm Examination. CSCI 561: Artificial Intelligence

CS 188: Artificial Intelligence Spring Announcements

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

Game Playing AI. Dr. Baldassano Yu s Elite Education

Game Playing State-of-the-Art

Adversarial Search Aka Games

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

Artificial Intelligence. Topic 5. Game playing

Homework Assignment #1

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

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

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

Games and Adversarial Search II

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

CS 188: Artificial Intelligence

Informed search algorithms. Chapter 3 (Based on Slides by Stuart Russell, Richard Korf, Subbarao Kambhampati, and UW-AI faculty)

Computer Game Programming Board Games

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

Foundations of Artificial Intelligence

Game-playing AIs: Games and Adversarial Search I AIMA

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

Artificial Intelligence

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

CS 188: Artificial Intelligence

CS 188: Artificial Intelligence. Overview

Unit 12: Artificial Intelligence CS 101, Fall 2018

UMBC 671 Midterm Exam 19 October 2009

CS 188: Artificial Intelligence Spring 2007

Adversarial Search and Game Playing

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

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

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

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

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

AIMA 3.5. Smarter Search. David Cline

COMP219: Artificial Intelligence. Lecture 13: Game Playing

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

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

Path Planning as Search

Adversarial Search Lecture 7

Documentation and Discussion

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

Intuition Mini-Max 2

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

COMP9414: Artificial Intelligence Adversarial Search

UNIVERSITY of PENNSYLVANIA CIS 391/521: Fundamentals of AI Midterm 1, Spring 2010

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

CSC384: Introduction to Artificial Intelligence. Game Tree Search

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

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

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

Transcription:

Artificial Intelligence Lecture 3

The problem Depth first Not optimal Uses O(n) space Optimal Uses O(B n ) space Can we combine the advantages of both approaches? 2

Iterative deepening (IDA) Let M be a maximum depth. Run depth first, but only until the given depth. Repeat for increasing values of M. M=1, M=2... 3

Iterative deepening def idasearch( start, goal ): M = 0 ; l=[] while 1: if l == []: M = M+1 ; l = [[start]] path = l.pop() if path[ 1] == goal: return path if len(path) > M: continue choices = nextstates( path[ 1] ) for c in choices: if c not in path: l = [path+[c]] + l return [] 4

Iterative deepening : water jugs problem >>> idasearch( (0,0), (2,0) ) [(0, 0), (0, 3), (3, 0), (3, 3), (4, 2), (0, 2), (2, 0)] >>> idasearch( (0,0), (0,1) ) [(0, 0), (4, 0), (1, 3), (1, 0), (0, 1)] How many nodes where visited? >>> idasearch ( (0,0), (0,2) ) 73 nodes visited [(0, 0), (0, 3), (3, 0), (3, 3), (4, 2), (0, 2)] >>> dfsearch ( (0,0), (0,2) ) 25 nodes visited [(0, 0), (0, 3), (3, 0), (3, 3), (4, 2), (0, 2)] 5

Analysing iterative deepening Completeness Yes, will return the best (shortest) solution Space complexity O(n) Time complexity Each iteration of M takes: O(B M ) time Total time: O(B 1 )+O(B 2 )+...+O(B N ) = O(B N ) That's the same complexity as both df and breadth first! In practice, if we skip the big O notation IDA takes B times longer Use breadth first if we have enough memory, otherwise IDA Using too much memory causes swapping which is slow! 6

Heuristic search Basic idea Use some domain knowledge to create a heuristic that tells how close to the goal a solution is. Example: In navigation, count the distance to the destination Heuristic does not have to be perfect, only give a rough guide to how good/bad a solution is When searching, expand first the nodes that have a good heuristic value 7

Use a cost function: f(n) = g(n) + h(n) g(n): cost from root node to this node h(n): admissible heuristic cost from this node to goal Admissible heuristic: must never overestimate the distance to the goal For each node, keep track of cost f(n) Expand the node n that have the lowest cost Compute cost of children. Insert sorted into list of nodes Sort explicitly (inefficient) or, Iterate over list and insert at right place 8

The efficiency of A* depends on the heuristic Provides a good way of combining domain knowledge with general search. Provides optimal solutions iff heuristic is admissible Time complexity In worst case: O(B n ) Space complexity In worst case: O(B n ) 9

Games Search for games have the small problem, that we do not know what our opponents will do. Eg. chess, tic tac toe,... Search algorithms Min max Alpha beta pruning 10

Example: Tic Tac Toe 11

Solution to Tic Tac Toe Represent current state as an integer Create table with best move for each state 19683 possible game states How do we write that table? Generalize the problem? 12

Another solution to tic tac toe Create ad hoc algorithm Blank=2, X=3, O=5 Make2: return center if it is empty, otherwise a non empty non corner. Posswin: return the square that constitues a winning move. (if product is 18 then X can win, if product is 50 then 0 can win). 13

Another solution to tic tac toe Easier to understand and change Total strategy have to be figured out Not generalizable 14

A general and systematic solution Try every combination of moves, assume that your opponent is a genius. Don't make moves allowing him to win. 15

Example search space Rectangle = our move, circle = opponents move We win if get a positive score What should we do? 16

Min Max Keep track of whose turn it is in each state Each players move called one ply. Compute the score for each state If someone has won, give +/ infinity as score If our move, the max of any children If his move, the min of any children Expensive to perform full search of whole game tree. Stop at a certain depth Give a meaningfull score for that position (heuristic!) eg. In chess: value of all pieces taken plus extra points for strategic positions such as centre 17

Observations Not all games suitable to represent by these rules Random outcomes Large branching factors (eg. Go) Pruning the search tree 18

Min max for Reversi Use given representation of states Function generating legal moves about 4 10 choices each turn Search 3 4 ply's Heuristic at leaf nodes eg. AI score Human score eg. Extra points for corners 19

Alpha beta pruning Reduces the size of the search tree Can we compute the final score without expanding node D? 20

Alpha beta pruning continued Alpha: Best choise for a MAX node so far. Beta: Best choise for a MIN node so far. Unbound MAX nodes have alpha = infinity Unbound MIN nodes have beta = +infinity Alpha pruning: Cut of under MIN nodes having beta value < alpha value of any of it's MAX node ancestors. Beta pruning: Cut of under MAX nodes having alpha value > beta value of any of it's MIN node ancestors. 21

Alpha beta pruning in reversi AI vs. AI: 4 ply search 11m46s for example game Alpha beta prunning 6m 36s for same game 22