Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck.

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.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
For Friday Finish chapter 5 Program 1, Milestone 1 due.
Games & Adversarial Search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
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.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Artificial Intelligence in Game Design
This time: Outline Game playing The minimax algorithm
Games with Chance Other Search Algorithms CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 3 Adapted from slides of Yoonsuck Choe.
Game Playing CSC361 AI CSC361: Game Playing.
Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
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.
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Lecture 5 Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
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.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Game Playing.
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.
1 Computer Group Engineering Department University of Science and Culture S. H. Davarpanah
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Game Playing. Towards Intelligence? Many researchers attacked “intelligent behavior” by looking to strategy games involving deep thought. Many researchers.
Minimax with Alpha Beta Pruning The minimax algorithm is a way of finding an optimal move in a two player game. Alpha-beta pruning is a way of finding.
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.
For Wednesday Read chapter 7, sections 1-4 Homework: –Chapter 6, exercise 1.
Game Playing. Introduction One of the earliest areas in artificial intelligence is game playing. Two-person zero-sum game. Games for which the state space.
Quiz 4 : Minimax Minimax is a paranoid algorithm. True
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
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.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Game-playing AIs Part 2 CIS 391 Fall CSE Intro to AI 2 Games: Outline of Unit Part II  The Minimax Rule  Alpha-Beta Pruning  Game-playing.
Adversarial Search 2 (Game Playing)
Games: Efficiency Andrea Danyluk September 23, 2013.
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search In this lecture, we introduce a new search scenario: game playing 1.two players, 2.zero-sum game, (win-lose, lose-win, draw) 3.perfect.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
1 Chapter 6 Game Playing. 2 Chapter 6 Contents l Game Trees l Assumptions l Static evaluation functions l Searching game trees l Minimax l Bounded lookahead.
Adversarial Search and Game-Playing
Announcements Homework 1 Full assignment posted..
Last time: search strategies
CS Fall 2016 (Shavlik©), Lecture 11, Week 6
Adversarial Search and Game Playing (Where making good decisions requires respecting your opponent) R&N: Chap. 6.
Games with Chance Other Search Algorithms
Games & Adversarial Search
Artificial Intelligence
Games & Adversarial Search
NIM - a two person game n objects are in one pile
Artificial Intelligence
Minimax strategies, alpha beta pruning
Based on slides by: Rob Powers Ian Gent
Games & Adversarial Search
Minimax strategies, alpha beta pruning
CS51A David Kauchak Spring 2019
Games & Adversarial Search
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 2 Adapted from slides of Yoonsuck Choe

Two-Person Perfect Information Deterministic Game Two players take turns making moves Board state fully known, deterministic evaluation of moves One player wins by defeating the other (or else there is a tie) Want a strategy to win, assuming the other person plays as well as possible

Minimax Create a utility function Evaluation of board/game state to determine how strong the position of player 1 is. Player 1 wants to maximize the utility function Player 2 wants to minimize the utility function Minimax tree Generate a new level for each move Levels alternate between “max” (player 1 moves) and “min” (player 2 moves)

Minimax tree Max Min Max Min

Minimax Tree Evaluation Assign utility values to leaves Sometimes called “board evaluation function” If leaf is a “final” state, assign the maximum or minimum possible utility value (depending on who would win) If leaf is not a “final” state, must use some other heuristic, specific to the game, to evaluate how good/bad the state is at that point

Minimax tree Max Min Max Min

Minimax Tree Evaluation At each min node, assign the minimum of all utility values at children Player 2 chooses the best available move At each max node, assign the maximum of all utility values at children Player 1 chooses best available move Push values from leaves to top of tree

Minimax tree Max Min Max Min

Minimax tree Max Min Max Min

Minimax tree Max Min Max Min

Minimax Evaluation Given average branching factor b, and depth m: A complete evaluation takes time b m A complete evaluation takes space bm Usually, we cannot evaluate the complete state, since it’s too big Instead, we limit the depth based on various factors, including time available.

Pruning the Minimax Tree Since we have limited time available, we want to avoid unnecessary computation in the minimax tree. Pruning: ways of determining that certain branches will not be useful

 Cuts If the current max value is greater than the successor’s min value, don’t explore that min subtree any more

 Cut example Max Min

 Cut example Depth first search along path Max Min

 Cut example 21 is minimum so far (second level) Can’t evaluate yet at top level Max Min 21

 Cut example -3 is minimum so far (second level) -3 is maximum so far (top level) Max Min -3

 Cut example 12 is minimum so far (second level) -3 is still maximum (can’t use second node yet) Max Min -3 12

 Cut example -70 is now minimum so far (second level) -3 is still maximum (can’t use second node yet) Max Min

 Cut example Since second level node will never be > -70, it will never be chosen by the previous level We can stop exploring that node Max Min

 Cut example Evaluation at second level is again Max Min

 Cut example Again, can apply  cut since the second level node will never be > -73, and thus will never be chosen by the previous level Max Min

 Cut example As a result, we evaluated the Max node without evaluating several of the possible paths Max Min

 cuts Similar idea to  cuts, but the other way around If the current minimum is less than the successor’s max value, don’t look down that max tree any more

 Cut example Some subtrees at second level already have values > min from previous, so we can stop evaluating them Min Max

 -  Pruning Pruning by these cuts does not affect final result May allow you to go much deeper in tree “Good” ordering of moves can make this pruning much more efficient Evaluating “best” branch first yields better likelihood of pruning later branches Perfect ordering reduces time to b m/2 i.e. doubles the depth you can search to!

 -  Pruning Can store information along an entire path, not just at most recent levels! Keep along the path:  : best MAX value found on this path (initialize to most negative utility value)  : best MIN value found on this path (initialize to most positive utility value)

Pruning at MAX node  is possibly updated by the MAX of successors evaluated so far If the value that would be returned is ever > , then stop work on this branch If all children are evaluated without pruning, return the MAX of their values

Pruning at MIN node  is possibly updated by the MIN of successors evaluated so far If the value that would be returned is ever < , then stop work on this branch If all children are evaluated without pruning, return the MIN of their values

Idea of  -  Pruning We know  on this path is 21 So, when we get max=70, we know this will never be used, so we can stop here

Utility Evaluation Function Very game-specific Take into account knowledge about game “Stupid” utility 1 if player 1 wins -1 if player 0 wins 0 if tie (or unknown) Only works if we can evaluate complete tree But, should form a basis for other evaluations

Utility Evaluation Need to assign a numerical value to the state Could assign a more complex utility value, but then the min/max determination becomes trickier Typically assign numerical values to lots of individual factors a = # player 1’s pieces - # player 2’s pieces b = 1 if player 1 has queen and player 2 does not, -1 if the opposite, or 0 if the same c = 2 if player 1 has 2-rook advantage, 1 if a 1- rook advantage, etc.

Utility Evaluation The individual factors are combined by some function Usually a linear weighted combination is used u =  a +  b +  c Different ways to combine are also possible Notice: quality of utility function is based on: What features are evaluated How those features are scored How the scores are weighted/combined Absolute utility value doesn’t matter – relative value does.

Evaluation functions If you had a perfect utility evaluation function, what would it mean about the minimax tree?

Evaluation functions If you had a perfect utility evaluation function, what would it mean about the minimax tree? You would never have to evaluate more than one level deep! Typically, you can’t create such perfect utility evaluations, though.

Evaluation Functions for Ordering As mentioned earlier, order of branch evaluation can make a big difference in how well you can prune A good evaluation function might help you order your available moves Perform one move only Evaluate board at that level Recursively evaluate branches in order from best first move to worst first move (or vice-versa if at a MIN node)