Download presentation
Presentation is loading. Please wait.
Published byMarianna Patrick Modified over 9 years ago
1
Game-playing AIs Part 2 CIS 391 Fall 2007
2
CSE 391 - Intro to AI 2 Games: Outline of Unit Part II The Minimax Rule Alpha-Beta Pruning Game-playing AI successes
3
CSE 391 - Intro to AI 3 `Don’t play hope chess’: The Minimax Rule Idea: make the move for player MAX which has the most benefit assuming that MIN makes the best move for MIN in response This is computed by a recursive process The backed-up value of each node in the tree is determined by the values of its children For a MAX node, the backed-up value is the maximum of the values of its children (i.e. the best for MAX) For a MIN node, the backed-up value is the minimum of the values of its children (i.e. the best for MIN)
4
CSE 391 - Intro to AI 4 The Minimax Procedure 1.Start with the current position as a MAX node. 2.Expand the game tree a fixed number of ply (half-moves). 3.Apply the evaluation function to the leaf positions. 4.Calculate back-up up values bottom-up. 5.Pick the move which was chosen to give the MAX value at the root.
5
CSE 391 - Intro to AI 5 2-ply Minimax Example 271 8 MAX MIN 271 8 2 1 271 8 21 2 This is the move selected by minimax Evaluation function value 271 8 212
6
CSE 391 - Intro to AI 6 What if MIN does not play optimally? Definition of optimal play for MAX assumes MIN plays optimally: maximizes worst-case outcome for MAX. But if MIN does not play optimally, MAX will do even better. [Theorem-not hard to prove]
7
CSE 391 - Intro to AI 7 Minimax Algorithm function MINIMAX-DECISION(state) returns an action inputs: state, current state in game v MAX-VALUE(state) return the action in SUCCESSORS(state) with value v function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v ∞ for a,s in SUCCESSORS(state) do v MIN(v, MAX-VALUE(s) ) return v function MAX-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v -∞ for a,s in SUCCESSORS(state) do v MAX(v, MIN-VALUE(s) ) return v
8
CSE 391 - Intro to AI 8 Comments on Minimax Search Depth-first search with fixed number of ply as the limit. O(b m ) time complexity – Ooops! O(bm) space complexity Performance will depend on the quality of the evaluation function (expert knowledge) depth of search (computing power and search algorithm) Differences from normal state space search Looking for one move only No cost on arcs MAX can’t be sure how MIN will respond to his moves Minimax rule forms the basis for other game tree search algorithms.
9
Alpha-Beta Pruning Slides of example from screenshots by Mikael Bodén, Halmstad University, Sweden found at http://www.emunix.emich.edu/~evett/AI/AlphaBeta_movie/sld001.htm
10
CSE 391 - Intro to AI 10 Alpha-Beta Pruning A way to improve the performance of the Minimax Procedure Basic idea: “If you have an idea which is surely bad, don’t take the time to see how truly awful it is” ~ Pat Winston 271 =2 >=2 <=1 ? We don’t need to compute the value at this node. No matter what it is it can’t effect the value of the root node.
11
CSE 391 - Intro to AI 11 The algorithm maintains two values, alpha and beta, which represent the minimum score that the maximizing player is assured of and the maximum score that the minimizing player is assured of respectively. Initially alpha is negative infinity and beta is positive infinity. As the recursion progresses the "window" becomes smaller. When beta becomes less than alpha, it means that the current position cannot be the result of best play by both players and hence need not be explored further.
12
CSE 391 - Intro to AI 12 An alpha value is an initial or temporary value associated with a MAX node. Because MAX nodes are given the maximum value among their children, an alpha value can never decrease; it can only go up. A beta value is an initial or temporary value associated with a MIN node. Because MIN nodes are given the minimum value among their children, a beta value can never increase; it can only go down.
13
CSE 391 - Intro to AI 13 http://www.maths.nottingham.ac.uk/personal/anw /G13GAM/alphabet.html http://www.maths.nottingham.ac.uk/personal/anw /G13GAM/alphabet.html
14
CSE 391 - Intro to AI 14 Alpha-Beta Pruning Traverse the search tree in depth-first order For each MAX node n, α(n)=maximum child value found so far Starts with – Increases if a child returns a value greater than the current α(n) Lower-bound on the final value For each MIN node n, β(n)=minimum child value found so far Starts with + Decreases if a child returns a value less than the current β(n) Upper-bound on the final value MAX cutoff rule: At a MAX node n, cut off search if α(n)>=β(n) MIN cutoff rule: At a MIN node n, cut off search if β(n)<=α(n) Carry α and β values down in search
15
CSE 391 - Intro to AI 15
16
CSE 391 - Intro to AI 16
17
CSE 391 - Intro to AI 17
18
CSE 391 - Intro to AI 18
19
CSE 391 - Intro to AI 19
20
CSE 391 - Intro to AI 20
21
CSE 391 - Intro to AI 21
22
CSE 391 - Intro to AI 22
23
CSE 391 - Intro to AI 23
24
CSE 391 - Intro to AI 24
25
CSE 391 - Intro to AI 25
26
CSE 391 - Intro to AI 26
27
CSE 391 - Intro to AI 27
28
CSE 391 - Intro to AI 28
29
CSE 391 - Intro to AI 29
30
CSE 391 - Intro to AI 30
31
CSE 391 - Intro to AI 31
32
CSE 391 - Intro to AI 32
33
CSE 391 - Intro to AI 33 Alpha-Beta Algorithm I function ALPHA-BETA-SEARCH(state) returns an action inputs: state, current state in game v MAX-VALUE(state, - ∞, + ∞ ) return the action in SUCCESSORS(state) with value v function MAX-VALUE(state, , ) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v - ∞ for a,s in SUCCESSORS(state) do v MAX(v,MIN-VALUE(s, , )) if v ≥ then return v MAX( ,v) return v
34
CSE 391 - Intro to AI 34 Alpha-Beta Algorithm II function MIN-VALUE(state, , ) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v + ∞ for a,s in SUCCESSORS(state) do v MIN(v,MAX-VALUE(s, , )) if v ≤ then return v MIN( ,v) return v
35
CSE 391 - Intro to AI 35 Effectiveness of Alpha-Beta Pruning Guaranteed to compute same root value as Minimax Worst case: no pruning, same as Minimax (O(b d )) Best case: when each player’s best move is the first option examined, you examine only O(b d/2 ) nodes, allowing you to search twice as deep! For Deep Blue, alpha-beta pruning reduced the average branching factor from 35-40 to 6.
36
CSE 391 - Intro to AI 36 Chinook and Deep Blue Chinook the World Man-Made Checkers Champion, developed at the University of Alberta. Competed in human tournaments, earning the right to play for the human world championship, and defeated the best players in the world. Play Chinook at http://www.cs.ualberta.ca/~chinookhttp://www.cs.ualberta.ca/~chinook Deep Blue Defeated world champion Gary Kasparov 3.5-2.5 in 1997 after losing 4-2 in 1996. Uses a parallel array of 256 special chess-specific processors Evaluates 200 billion moves every 3 minutes; 12-ply search depth Expert knowledge from an international grandmaster. 8000 factor evaluation function tuned from hundreds of thousands of grandmaster games Tends to play for tiny positional advantages.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.