200 likes | 423 Views
Artificial Intelligence. Game / Adversarial Search. Outline. Minimax Search Alpha-Beta Pruning. Garry Kasparov and Deep Blue, 1997. Games vs. search problems. "Unpredictable" opponent specifying a move for every possible opponent reply
E N D
Artificial Intelligence Game / Adversarial Search
Outline • Minimax Search • Alpha-Beta Pruning Garry Kasparov and Deep Blue, 1997
Games vs. search problems • "Unpredictable" opponent specifying a move for every possible opponent reply • Time limits unlikely to find goal, must approximate
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
Select this move MAX 3 MIN 3 2 1 MAX 2 5 3 1 4 4 3 Game Playing - Minimax • Restrictions: • 2 players: MAX (computer) and MIN (opponent) • deterministic, perfect information • Select a depth-bound (say: 2) and evaluation function - Construct the tree up till the depth-bound - Compute the evaluation function for the leaves - Propagate the evaluation function upwards: - taking minima in MIN - taking maxima in MAX
Select this move B C 1 -3 D E F G 4 1 2 -3 4 -5 -5 1 -7 2 -3 -8 Game Playing - Minimax example MAX 1 A MIN MAX = terminal position = agent = opponent
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.
MAX 2 1 2 =2 MIN MAX 2 5 1 Alpha-Beta idea: • Principles: • generate the tree depth-first, left-to-right • propagate final values of nodes as initial estimates for their parent node. - The MIN-value (1) is already smaller than the MAX-value of the parent (2) - The MIN-value can only decrease further, - The MAX-value is only allowed to increase, - No point in computing further below this node
- The (temporary) values at MAX-nodes are ALPHA-values MAX 2 Alpha-value 1 2 =2 MIN Beta-value MAX 2 5 1 Terminology: - The (temporary) values at MIN-nodes are BETA-values
MAX 2 Alpha-value 1 2 =2 MIN Beta-value MAX 2 5 1 The Alpha-Beta principles (1): - If an ALPHA-value is larger or equal than the Beta-value of a descendant node: stop generation of the children of the descendant
MAX 2 Alpha-value 2 =2 MIN Beta-value 1 MAX 2 5 3 The Alpha-Beta principles (2): - If an Beta-value is smaller or equal than the Alpha-value of a descendant node: stop generation of the children of the descendant
Alpha-Beta Pruning example B K J I H C D E MAX A MIN <=6 MAX 6 >=8 6 5 8 = agent = opponent
B M L K J I H C D E F G Alpha-Beta Pruning example A >=6 MAX MIN 6 <=2 MAX 6 >=8 2 6 5 8 2 1 = agent = opponent
B M L K J I H C D E F G Alpha-Beta Pruning example A >=6 MAX MIN 6 2 MAX 6 >=8 2 6 5 8 2 1 = agent = opponent
B M L K J I H C D E F G Alpha-Beta Pruning example A MAX 6 MIN 6 2 beta cutoff MAX 6 >=8 alpha cutoff 2 6 5 8 2 1 = agent = opponent
4 5 = 5 16 31 39 8 5 23 6 = 4 = 5 15 30 3 38 1 2 1 8 33 10 18 2 3 2 25 4 3 35 = 8 12 20 5 9 9 6 = 3 8 27 29 = 4 = 5 37 14 22 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2 8 6 4 Mini-Max with at work: MAX MIN MAX 1 3 4 7 9 11 13 17 19 21 24 26 28 32 34 36 11 static evaluations saved !!