CS51A David Kauchak Spring 2019

Slides:



Advertisements
Similar presentations
Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
Advertisements

Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Adversarial Search Reference: “Artificial Intelligence: A Modern Approach, 3 rd ed” (Russell and Norvig)
Computers playing games. One-player games Puzzle: Place 8 queens on a chess board so that no two queens attack each other (i.e. on the same row, same.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
Adversarial Search CSE 473 University of Washington.
Artificial Intelligence in Game Design Heuristics and Other Ideas in Board Games.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing State-of-the-Art  Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used an endgame database defining.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
CSC 412: AI Adversarial Search
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
More Adversarial Search CS311 David Kauchak Spring 2013 Some material borrowed from : Sara Owsley Sood and others.
Adversarial Search CS30 David Kauchak Spring 2015 Some material borrowed from : Sara Owsley Sood and others.
Game Playing.
Artificial Intelligence in Game Design Lecture 22: Heuristics and Other Ideas in Board Games.
Adversarial Search CS311 David Kauchak Spring 2013 Some material borrowed from : Sara Owsley Sood and others.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search Chapter 5 Sections 1 – 4. AI & Expert Systems© Dr. Khalid Kaabneh, AAU Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
Artificial Intelligence AIMA §5: Adversarial Search
Game playing Types of games Deterministic vs. chance
Game Playing Why do AI researchers study game playing?
Adversarial Search and Game-Playing
Games and adversarial search (Chapter 5)
Adversarial Environments/ Game Playing
EA C461 – Artificial Intelligence Adversarial Search
Instructor: Vincent Conitzer
4. Games and adversarial search
Games and Adversarial Search
PENGANTAR INTELIJENSIA BUATAN (64A614)
Games and adversarial search (Chapter 5)
CS 460 Spring 2011 Lecture 4.
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Pengantar Kecerdasan Buatan
Optimizing Minmax Alpha-Beta Pruning Real Time Decisions
Adversarial Search.
Game Playing.
David Kauchak CS52 – Spring 2016
Adversarial Search Chapter 5.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search.
Game playing.
Games & Adversarial Search
Games & Adversarial Search
NIM - a two person game n objects are in one pile
Instructor: Vincent Conitzer
Game Playing Fifth Lecture 2019/4/11.
Instructor: Vincent Conitzer
Games & Adversarial Search
Adversarial Search CMPT 420 / CMPG 720.
Minimax strategies, alpha beta pruning
CS51A David Kauchak Spring 2019
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

CS51A David Kauchak Spring 2019 Adversarial Search 2 CS51A David Kauchak Spring 2019 Some material borrowed from : Sara Owsley Sood and others

Admin Assignment 10 Pre-registration

Baby Nim What move should I take? MAX MIN MAX MIN MAX Take 1 or 2 at each turn Goal: take the last match MAX What move should I take? MIN MAX

Baby Nim MAX MIN MAX MIN MAX 5 4 3 2 1 W MAX MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX MAX wins MIN MIN W = 1.0 MAX MAX W = -1.0 MIN wins/ MAX loses

Baby Nim ? 1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 MAX MIN MAX MIN MAX 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX MAX wins MIN MIN 1.0 1.0 W = 1.0 1.0 ? MAX MAX W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim ? 1.0 1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 MAX MIN MAX MIN MAX 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX MAX wins ? MIN MIN 1.0 1.0 W = 1.0 1.0 MAX MAX W = -1.0 1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim ? -1.0 1.0 1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 1.0 MAX MIN MAX 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX MAX wins ? MIN MIN -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX W = -1.0 1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match ? MAX MAX MAX wins MIN MIN -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX W = -1.0 1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX -1.0 MAX wins ? MIN MIN -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX W = -1.0 1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN Take 1 or 2 at each turn Goal: take the last match ? MAX MAX -1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX ? MIN MIN Take 1 or 2 at each turn Goal: take the last match MAX MAX -1.0 1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN -1.0 Take 1 or 2 at each turn Goal: take the last match MAX MAX 1.0 -1.0 MAX wins ? MIN MIN -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN -1.0 Take 1 or 2 at each turn Goal: take the last match ? MAX MAX 1.0 -1.0 MAX wins ? MIN MIN -1.0 -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX MIN MIN -1.0 Take 1 or 2 at each turn Goal: take the last match ? MAX MAX 1.0 1.0 -1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim 5 4 3 2 1 W MAX MAX ? MIN MIN -1.0 Take 1 or 2 at each turn Goal: take the last match MAX MAX 1.0 1.0 1.0 -1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim Which move? 5 4 3 2 1 W MAX MAX MIN MIN -1.0 1.0 Take 1 or 2 at each turn Goal: take the last match MAX MAX 1.0 1.0 1.0 -1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Baby Nim could still win, but not optimal!!! 5 4 3 2 1 W MAX MAX MIN MIN -1.0 1.0 Take 1 or 2 at each turn Goal: take the last match MAX MAX 1.0 1.0 1.0 -1.0 MAX wins MIN MIN -1.0 -1.0 -1.0 -1.0 1.0 1.0 W = 1.0 1.0 MAX MAX 1.0 W = -1.0 -1.0 -1.0 -1.0 -1.0 MIN wins/ MAX loses 1.0

Minimax example 2 Which move should be made: A1, A2 or A3? MAX MIN A1 12 8 A11 A12 A13 2 4 6 A21 A22 A23 14 5 2 A31 A32 A33 Which move should be made: A1, A2 or A3?

Minimax example 2 A1 MAX MIN A2 A3 3 2 2 3 12 8 2 4 6 2 5 14 A11 A12

Properties of minimax Minimax is optimal! Are we done? Yes (if tree is finite) Yes (against an optimal opponent) O(bm) O(bm) (depth-first exploration)

Games State Space Sizes On average, there are ~35 possible moves that a chess player can make from any board configuration… 0 Ply 1 Ply 18 Ply!! 2 Ply 17005 Branching Factor Estimates for different two-player games Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 Hydra at home in the United Arab Emirates…

Games State Space Sizes On average, there are ~35 possible moves that a chess player can make from any board configuration… 0 Ply 1 Ply 2 Ply Branching Factor Estimates for different two-player games Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 Boundaries for qualitatively different games…

Games State Space Sizes On average, there are ~35 possible moves that a chess player can make from any board configuration… 0 Ply 1 Ply 2 Ply Branching Factor Estimates for different two-player games Can search entire space Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 “solved” games CHINOOK (2007) computer-dominated Can’t  human-dominated Is this true?

Games State Space Sizes AlphaGo (created by Google), in April 2016 beat one of the best Go players: http://www.nytimes.com/2016/04/05/science/google-alphago-artificial-intelligence.html 0 Ply 1 Ply 2 Ply Branching Factor Estimates for different two-player games Can search entire space Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 “solved” games CHINOOK (2007) computer-dominated Can’t  What do we do?

Alpha-Beta pruning An optimal pruning strategy only prunes paths that are suboptimal (i.e. wouldn’t be chosen by an optimal playing player) returns the same result as minimax, but faster Name the movie 

Alpha-Beta pruning

Games State Space Sizes Pruning helps get a bit deeper For many games, still can’t search the entire tree Now what? 0 Ply 1 Ply 2 Ply Branching Factor Estimates for different two-player games Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 computer-dominated

Games State Space Sizes Pruning helps get a bit deeper For many games, still can’t search the entire tree Go as deep as you can: estimate the score/quality of the state (called an evaluation function) use that instead of the real score 0 Ply 1 Ply 2 Ply Branching Factor Estimates for different two-player games Tic-tac-toe 4 Connect Four 7 Checkers 10 Othello 30 Chess 35 Go 300 computer-dominated

Tic Tac Toe evaluation functions X O Ideas?

Example Tic Tac Toe EVAL Assume MAX is using “X” X O EVAL(state) = if state is win for MAX: +  if state is win for MIN: -  else: (number of rows, columns and diagonals available to MAX) - (number of rows, columns and diagonals available to MIN) = 6 - 4 = 2 X O = 4 - 3 = 1

Chess evaluation functions Ideas?

Chess EVAL = 31 - 36 = -5 Assume each piece has the following values pawn = 1; knight = 3; bishop = 3; rook = 5; queen = 9; EVAL(state) = sum of the value of white pieces – sum of the value of black pieces = 31 - 36 = -5

Chess EVAL Any problems with this? Assume each piece has the following values pawn = 1; knight = 3; bishop = 3; rook = 5; queen = 9; EVAL(state) = sum of the value of white pieces – sum of the value of black pieces Any problems with this?

Chess EVAL Ignores actual positions! Actual heuristic functions are often a weighted combination of features

Chess EVAL A feature can be any numerical information about the board number of pawns number of attacked knights 1 if king has knighted, 0 otherwise A feature can be any numerical information about the board as general as the number of pawns to specific board configurations Deep Blue: 8000 features!

history/end-game tables keep track of the quality of moves from previous games use these instead of search end-game tables do a reverse search of certain game configurations, for example all board configurations with king, rook and king tells you what to do in any configuration meeting this criterion if you ever see one of these during search, you lookup exactly what to do

end-game tables Devastatingly good Allows much deeper branching for example, if the end-game table encodes a 20-move finish and we can search up to 14 can search up to depth 34 Stiller (1996) explored all end-games with 5 pieces one case check-mate required 262 moves! Knoval (2006) explored all end-games with 6 pieces one case check-mate required 517 moves! Traditional rules of chess require a capture or pawn move within 50 or it’s a stalemate

Opening moves At the very beginning, we’re the farthest possible from any goal state People are good with opening moves Tons of books, etc. on opening moves Most chess programs use a database of opening moves rather than search

Nim K piles of coins On your turn you must take one or more coins from one pile Player that takes the last coin wins Example: https://www.goobix.com/games/nim/