School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW AI for games: min-max search COMP 112 2014 #

Slides:



Advertisements
Similar presentations
Artificial Intelligence 5. Game Playing
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.
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.
EGR 141 Computer Problem Solving in Engineering and Computer Science
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Tic Tac Toe Game Design Using OOP
University College Cork (Ireland) Department of Civil and Environmental Engineering Course: Engineering Artificial Intelligence Dr. Radu Marinescu Lecture.
CS 4700: Foundations of Artificial Intelligence Bart Selman Reinforcement Learning R&N – Chapter 21 Note: in the next two parts of RL, some of the figure/section.
Heidi Newton Peter Andreae Artificial Intelligence.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Hoe schaakt een computer? Arnold Meijster. Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games.
Artificial Intelligence in Game Design Heuristics and Other Ideas in Board Games.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Place captured red pieces here Place captured yellow pieces here To use as Kings Rules New Game Exit Left mouse click on piece – drag to desired location.
Artificial Intelligence in Game Design
CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,
This time: Outline Game playing The minimax algorithm
Game Playing CSC361 AI CSC361: Game Playing.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
Online Chess Project 3 Due date: April 17 th. Introduction Third in series of three projects This project focuses on adding online support –2 players.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Adversarial Search: Game Playing Reading: Chess paper.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
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.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Review COMP 102 #
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
9.1. B OARD G AMES AND A IMING AI Common board game AI approaches and Aiming AI.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game Playing. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
Adversarial Search CS30 David Kauchak Spring 2015 Some material borrowed from : Sara Owsley Sood and others.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Artificial Intelligence in Game Design Lecture 22: Heuristics and Other Ideas in Board Games.
AD FOR GAMES Lecture 4. M INIMAX AND A LPHA -B ETA R EDUCTION Borrows from Spring 2006 CS 440 Lecture Slides.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Adversarial Search CS311 David Kauchak Spring 2013 Some material borrowed from : Sara Owsley Sood and others.
Mark Dunlop, Computer and Information Sciences, Strathclyde University 1 Algorithms & Complexity 5 Games Mark D Dunlop.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington2012 More Collections: Queues,
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington 2D arrays COMP 102 # T1.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
1 Adversarial Search CS 171/271 (Chapter 6) Some text and images in these slides were drawn from Russel & Norvig’s published material.
W 2 L 1 sh 1 C lessons LessonSubjectBook Week 1 lesson 1Objects, names Week 1 lesson 2Statements, layout Week 2 lesson 1Functions, decomposition Week 2.
HPC Checkers By Andy Block Ryan Egan. Table of Contents Overview of Checkers ▫Overview of Checkers ▫Rules of the Game AI Theory The Program ▫Board ▫Sample.
Draughts. Introduction Draughts is played on the same chequered board as chess and has been played in Europe since the end of the 1100s. It is similar.
Senior Project Poster Day 2007, CIS Dept. University of Pennsylvania Reversi Meng Tran Faculty Advisor: Dr. Barry Silverman Strategies: l Corners t Corners.
Cilk Pousse James Process CS534. Overview Introduction to Pousse Searching Evaluation Function Move Ordering Conclusion.
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington 2D arrays COMP 102 # T1.
CSE 143 Lecture 18 More Recursive Backtracking slides created by Marty Stepp
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington More Recursion COMP 102 #30.
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW IRC, parsing, protocols COMP # 25.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Adversarial Search and Game-Playing
PENGANTAR INTELIJENSIA BUATAN (64A614)
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Optimizing Minmax Alpha-Beta Pruning Real Time Decisions
Adversarial Search.
David Kauchak CS52 – Spring 2016
CSE (c) S. Tanimoto, 2007 Search 2: AlphaBeta Pruning
Data Structures and Algorithms
CS51A David Kauchak Spring 2019
CS51A David Kauchak Spring 2019
Unit II Game Playing.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW AI for games: min-max search COMP # 26

COMP112 26: 2 Menu AI and Games: min-max search for 2-person turn-taking games Admin

COMP112 26: 3 AI: Games Where is AI used in Games?

COMP112 26: 4 Min-Max search 2-person, turn-taking games (eg, board games) It’s O’s turn / white’s turn What should they do? ♖ ♔♘ ♗ ♙♜ ♝ ♚ ♜

COMP112 26: 5 Approaches: Look-up table of good moves for each position. Heuristics (“rules-of-thumb”) to evaluate each move. Look-ahead search: for each possible move for each possible response for each possible move for each possible ….. work out if win or loss propagate it back….

COMP112 26: 6 O’s choice X’s Choice It’s O’s turn: what should O do? Work backwards to determine status of earlier positions X will try to make O lose

COMP112 26: 7 O’s choices O’s choice X’s Choice It’s O’s turn: what should O do? Work backwards to determine status of earlier positions O will try to win

COMP112 26: 8 O’s choice X’s Choices It’s O’s turn: what should O do? Work backwards to determine status of earlier positions X will try to make O lose

COMP112 26: 9 O’s choice It’s O’s turn: what should O do? Work backwards to determine status of earlier positions O will try to win

COMP112 26: 10 Min-max search To choose move: for each possible move, evaluate new board state from other player’s perspective perform move with lowest value board (worst for them, best for me) To evaluate a board from players’ perspective If the game is over, return 1 for win, -1 for lose, 0 for draw for each possible move of the player, construct board state after move value = -ve of (evaluate new state from other player’s perspective) keep track of maximum value (ie, best for this player) return value

COMP112 26: 11 AI for O and X. public void doAITurn(){ String bestOutcome = "X"; //start pessimistic - the real player will win int bestRow = -1; for (int row=0; row<3; row++){for (int col=0; col<3; col++){ if (board[row][col] == null ){ // it's an empty cell if (bestRow == -1){ bestRow = row; bestCol = col; } //we can at least play here String[ ][ ] hypotheticalBoard = this.newBoard(this.board, row, col, "O"); String value = evaluate(hypotheticalBoard, "X"); if (value.equals("O")){ // Winning move: play here this.board[row][col] = "O"; return; } else if (value.equals("draw")){ // might be best option bestOutcome = "draw"; bestRow = row; bestCol = col; } }} } if (bestRow != -1) { this.board[bestRow][bestCol] = "O"; } // play at best option. }

COMP112 26: 12 AI for O and X public String evaluate(String[][] brd, String player){ // player plays next String outcome = this.boardOutcome(brd); if ( outcome != null )){ return outcome; } //the game is over String other = this.other(player); // the other player from this perspective outcome = other; // minimum outcome if player can't do better for (int r=0; r<3; r++){for (int c=0; c<3; c++){ if (!brd[r][c].equals("")){ continue; } String[][] hypotheticalBoard = this.newBoard(brd, r, c, player); // see what the outcome of that play would be String v = evaluate(hypotheticalBoard, other); if (v.equals(player)){ // the player could win return player; // then they definitely would choose this } if (v.equals("draw")){ outcome = "draw"; } // choose this if there is no win }} return outcome; //there was no win for the nextPlayer, }

COMP112 26: 13 What about 3D OandX? Is this approach feasible? What about chess or draughts (checkers)? How big is the search? OandX, 3D 0andX, Draughts, Chess, Go?

COMP112 26: 14 Min-Max search for big games Need to search as deep as possible, Then use heuristics to evaluate board states: eg: piece count, dominance  values between -1 and 1 Propagate the values back minimising the values on the opponent’s turn maximising the values on the player’s turn.

COMP112 26: 15 Min-max search.