4.0 Game playing.ppt - Game playing Games Why Minimax...

This preview shows page 1 out of 31 pages.

Unformatted text preview: Game playing Games. Why? Minimax search Alpha-beta pruning Garry Kasparov and Deep Blue, 1997 Why are people interested in games? Some games: Ball games Card games Board games Computer games ... 2 Why study board games ? One of the oldest sub-fields of AI Abstract and pure form of competition that seems to require intelligence Easy to represent the states and actions Very little world knowledge required ! Game playing is a special case of a search problem, with some new requirements. 3 Game playing Up till now we have assumed the situation is not going to change whilst we search. Game playing is not like this. The opponent introduces uncertainty. The opponent also wants to win Game Playing has been studied for a long time Babbage (tic-tac-toe) Turing (chess) 4 Why study board games ? “A chess (or draughts) playing computer would be proof of a machine doing something thought to require intelligence” Game playing research has contributed ideas on how to make the best use of time to reach good decisions, when reaching optimal decisions is impossible. These ideas are applicable in tackling real-world search problems. Our limit here: 2-person games, with no chance 5 Why new techniques for games? “Contingency” problem: We don’t know the opponents move ! The size of the search space: Chess : ~15 moves possible per state, 80 ply Go : ~200 moves per state, 300 ply 1580 nodes in tree 200300 nodes in tree Game playing algorithms: Search tree only up to some depth bound Use an evaluation function at the depth bound Propagate the evaluation upwards in the tree 6 Types of games Deterministic Chance Perfect information Imperfect information Chess, Backgammon, draughts, go, monopoly othello, tic-tactoe Bridge, poker, scrabble 7 Game Playing - Chess Size of search space (10120 - average of 40 moves) Shannon - March 9th 1949 - New York 1957 - Newell and Simon predicted that a computer would be chess champion within ten years Simon : “I was a little far-sighted with chess, but there was no way to do it with machines that were as slow as the ones way back then” 8 Game Playing - Chess 1958 - First computer to play chess was an IBM 704 about one millionth capacity of deep blue. 1967 : Mac Hack competed successfully in human tournaments 1983 : “Belle” obtained expert status from the United States Chess Federation Mid 80’s : Scientists at Carnegie Mellon University started work on what was to become Deep Blue. Project moved to IBM in 1989 9 Game Playing - Chess May 11th 1997, Gary Kasparov lost a six match game to Deep blue 3.5 to 2.5 Two wins for deep blue, one win for Kasparov and three draws Deep Blue was capable of evaluating 200 million positions per second 10 Game Playing - Minimax Game Playing: An opponent tries to thwart your every move 1944 - John von Neumann outlined a search method (Minimax) that maximised your position whilst minimising your opponents In order to implement we need a method of measuring how good a position is. Often called a utility function (or payoff function) e.g. outcome of a game; win 1, loss -1, draw 0 Initially this will be a value that describes our position exactly 11 Game Playing - Minimax Restrictions: 2 players: MAX (computer) and MIN (opponent) deterministic, perfect information Select a depth-bound (say: 2) and evaluation function MAX MIN MAX - Construct the tree up till Select the depth-bound this move 3 - Compute the evaluation function for the leaves 2 2 3 1 5 3 1 4 4 3 - Propagate the evaluation function upwards: - taking minima in MIN - taking maxima in MAX 12 Game Playing - Minimax example 1 MAX Select this move 1 MIN MAX 4 4 B D -5 A 1 -5 = terminal position -3 E 2 1 C F -7 = agent -3 2 G -3 -8 = opponent 13 Alpha-Beta Pruning Generally applied optimization on Mini-max. Instead of: first creating the entire tree (up to depth-level) then doing all propagation Interleave the generation of the tree and the propagation of values. Point: some of the obtained values in the tree will provide information that other (non-generated) parts are redundant and do not need to be generated. 14 Alpha-Beta idea: Principles: generate the tree depth-first, left-to-right propagate final values of nodes as initial estimates for their parent node. MAX MIN MAX 2 2 =2 - The MIN-value (1) is already smaller than the MAX-value of the parent (2) 1 - The MIN-value can only decrease further, - The MAX-value is only allowed to increase, - No point in computing further below this node 2 5 1 15 Terminology: - The (temporary) values at MAX-nodes are ALPHAvalues - The (temporary) values at MIN-nodes are BETA-values MAX MIN MAX 2 2 2 =2 5 Alpha-value 1 Beta-value 1 16 The Alpha-Beta principles (1): - If an ALPHA-value is larger or equal than the Betavalue of a descendant node: stop generation of the children of the descendant MAX 2 Alpha-value MIN MAX 2 2 =2 5 1 Beta-value 1 17 The Alpha-Beta principles (2): - If an Beta-value is smaller or equal than the Alphavalue of a descendant node: stop generation of the children of the descendant MAX 2 =2 1 Beta-value MIN 2 MAX 2 5 3 Alpha-value 18 Alpha-Beta Pruning example A MAX <=6 B C MIN 6 D >=8 E MAX H I J 6 5 8 = agent K = opponent 19 Alpha-Beta Pruning example >=6 A MAX 6 B <=2 C MIN 6 D >=8 E 2 F G MAX H I J 6 5 8 = agent K L M 2 1 = opponent 20 Alpha-Beta Pruning example >=6 A MAX 6 B 2 C MIN 6 D >=8 E 2 F G MAX H I J 6 5 8 = agent K L M 2 1 = opponent 21 Alpha-Beta Pruning example 6 A MAX 6 B 2 C beta cutoff MIN 6 D >=8 E alpha cutoff 2 F G MAX H I J 6 5 8 = agent K L M 2 1 = opponent 22 Mini-Max with at work: 4 16 86 =85 9 8 = 5 30 2 10 1 18 4 12 3 20 = 4 14 = 5 22 8 7 3 9 1 6 2 4 1 1 3 4 7 MAX 5 23 = 4 15 82 5 31 = 5 39 9 11 13 3 38 1 33 2 35 3 25 9 27 6 29 = 3 37 1 3 5 3 9 2 6 5 2 17 19 21 24 26 MIN 28 MAX 1 2 3 9 7 2 8 6 4 32 34 36 11 static evaluations 23 “DEEP” cut-offs - For game trees with at least 4 Min/Max layers: the Alpha - Beta rules apply also to deeper levels. 4 4 4 4 4 2 2 24 case: - If at every layer: the best node is the left-most one MAX MIN MAX Only THICK is explored 25 Example of a perfectly ordered tree MAX 21 21 21 24 12 27 12 15 3 18 3 6 MIN 9 MAX 21 20 19 24 23 22 27 26 2512 11 10 15 14 13 18 17 163 2 1 6 5 4 9 8 7 26 Best case gain pictured: # Static evaluations b = 10 No pruning 100000 Alpha-Beta Best case 10000 1000 100 10 1 2 3 4 5 6 7 Depth - Note: algorithmic scale. - Conclusion: still exponential growth !! - Worst case?? For some trees alpha-beta does nothing, For some trees: impossible to reorder to avoid cut-offs 27 The horizon effect. Queen lost Pawn lost horizon = depth bound of mini-max Queen lost Because of the depth-bound we prefer to delay disasters, although we don’t prevent them !! solution: heuristic 28 Heuristic Continuation In situations that are identified as strategically crucial e.g: king in danger, imminent piece loss, pawn to become as queens, ... extend the search beyond the depth-bound ! depth-bound 29 Time bounds: How to play within reasonable time bounds? Even with fixed depth-bound, times can vary strongly! Solution: Iterative Deepening !!! 30 Summary alpha-beta algorithm does the same calculation as minimax, and is more efficient since it prunes irrelevant branches. usually, the complete game tree is not expanded, search is cut off at some point and an evaluation function calculated to estimate the utility of a state. So far, for a possibly good and efficient search: select good search method/technique provide info/heuristic if possible apply prune irrelevant branches 31 ...
View Full Document

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture