Download presentation

Presentation is loading. Please wait.

Published bySofia Sullivan Modified over 3 years ago

1
1 Chapter 6, Sec Adversarial Search

2
2 Outline Optimal decisions α-β pruning Imperfect, real-time decisions

3
3 Games vs. search problems Competitive multiagent environment in which the agents goals are in conflict: adversarial search problem - games. Games in AI: deterministic, turn-taking, 2-player, zero-sum games of perfect information – i.e. deterministic, fully observable environments in which there two agents whose actions must alternate and in which the utility values at the end of the game are always equal and opposite. "Unpredictable" opponent solution is a strategy specifying a move for every possible opponent reply. Time limits unlikely to find goal, must approximate. –how to make the best possible use of time? –The optimal move and an algorithm for finding it –the techniques for choosing a good move within the time limits – allows us to ignore portions of the search tree that make no difference –Pruning allows us to ignore portions of the search tree that make no difference to the final choice – allow us to approximate the true utility –Heuristic evaluation functions allow us to approximate the true utility of a state without doing a complete search.

4
4 Types of games deterministicchance Perfect information Chess, checkers, go, othello backgammon, monopoly Imperfect information Bridge, poker, scrabble, nuclear war

5
5 Optimal decisions in game A game can be formally defined as a kind of search problem with the following components: –: includes the board position and identifies the player to move –Initial state: includes the board position and identifies the player to move –: returns a list of (move, state) pairs, each indicating a legal move and resulting state. –Successor function: returns a list of (move, state) pairs, each indicating a legal move and resulting state. –: determines when the game is over – terminal states. –Terminal test: determines when the game is over – terminal states. – ( an objective function or payoff function): –Utility function ( an objective function or payoff function): gives a numeric value for the terminal states. -- +x, -x, 0 A game tree for tic-tac-toe: –Play alternates b/t MAXs placing an X and MINs placing an O until we reach leaf nodes of terminal states. –The # on each leaf node: the utility value of the terminal state from the point of view of MAX.

6
6 Continued... Optimal decisions Cf) In a normal search problem, the optimal solution would be a sequence of moves leading to a goal state in the minimum path cost. In a game, a player must find a contingent strategy for every possible response by opponent An optimal strategy leads to outcomes at last as good as any other strategy when one is playing an infallible opponent. In a game tree of tic-tac-toe, the optimal strategy can be determined by examining the minimax value of each node, which is the utility (for MAX) of being in the corresponding state, assuming that both players play optimally from there to the end. if n is a terminal state if n is a MAX node if n is a MIN node Given a choice, MAX prefer to move to a state of maximum value, whereas MIN prefers a state of minimum value.

7
7 Game tree (2-player, deterministic, turns) The top node: the initial state Alternative moves by MIN(O) and MAX(X), until we eventually reach terminal states, which can be assigned utilities according to the rules of the game.

8
8 Minimax algorithm Compute the minimax decision from the current state. Perfect play for deterministic games, perfect-information game. Idea: choose move to position with highest minimax value = best achievable payoff against best play E.g., 2-ply game:

9
9 Minimax algorithm -- the minimax decision from the current state

10
10 Properties of minimax Complete? Yes (if tree is finite) Optimal? Yes (against an optimal opponent) Time complexity? O(b m ) Space complexity? O(bm) (depth-first exploration) The # of game states it has to examine is exponential in the # of moves. For chess, b 35, m 100 for "reasonable" games exact solution completely infeasible

11
11 α-β pruning Compute the correct minimax decision w/o looking at every node in the game tree => reduce the # of states examined. Prunes away branches of the game tree that cant possibly influence the final decision. General principle: Consider a node n somewhere in the tree, s.t. Player has a choice of moving to that node. If Player has a better choice m either at the parent node of n or at any choice point further up, then n will never be reached in actual play.

12
12 α-β pruning example

13
13 Continued… α-β pruning example

14
14 Continued… α-β pruning example

15
15 Continued… α-β pruning example

16
16 Continued… α-β pruning example

17
17 Properties of α-β Properties of α-β pruning Pruning does not affect final result Good move ordering improves effectiveness of pruning -- highly dependent on the order of successors examined. It might be worthwhile to try to examine first the successor that are likely to be best. With "perfect ordering – the best-first of successors examination, time complexity = O(b m/2 ) Effective branching factor: b doubles depth of search w/i the same amount of time. Can easily reach depth 8 and play good chess. With random examination, the total # of nodes examined will be O(b 3m/4 ) A simple example of the value of reasoning about which computations are relevant (a form of metareasoning)

18
18 Why is it called α-β? α is the value of the best (i.e., highest-value) choice found so far at any choice point along the path for MAX is the value of the best (i.e. lowest-value) choice found so far at any choice point along the path for MIN. is the value of the best (i.e. lowest-value) choice found so far at any choice point along the path for MIN. If V is worse than α, MAX will avoid it prune that branch Define β similarly for MIN

19
19 The α-β algorithm

20
20 Resource limits Suppose we have 100 seconds, explore 10 4 nodes/sec 10 6 nodes per move Alpha-beta pruning still has to search all the way to terminal states for at least a portion of the search space. Standard approach: –cutoff test: Cut off the search earlier and decide when to apply evaluation function, turning nonterminal nodes into terminal leaves. e.g., depth limit (perhaps add quiescence search) –evaluation function = estimated desirability(utility) of position

21
21 Evaluation functions Returns an estimate of the expected utility of the game from a position. Requirements –The eval-fn should order the terminal states in the same way as the true utility function; otherwise, an agent using it might select suboptimal moves even if it can see ahead all the way to the end of the game. –The computation must not take too long. –For nonterminal states, the eval-fn should be strongly correlated with the actual chances of winning. => Make a guess a/b the final outcome. Categories of states defined by features which are calculated by eval-fn and the states in each category have the same values for all the features as a single value which reflects the proportion of states with each outcome – the weighted average or expected value. The expected value determined for each category, resulting in an eval-fn that works for any state. – too much to estimate all the probabilities of winning for too may categories Compute separate numerical contributions from each feature and then combine them to find the total value. -- a weighted linear function Eval(s)=w 1 f 1 (s)+w 2 f 2 (s)+ …. +w n f n (s)

22
22 Evaluation functions For chess, typically linear weighted sum of features Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) + … + w n f n (s) e.g., w 1 = 9 with f 1 (s) = (number of white queens) – (number of black queens), etc. Deciding the features and weights are from human chess-playing experience. The weights of the Eval-fn can be estimated by the machine learning techniques.

23
23 Cutting off search Modify -SEARCH so that itll call the Eval-fn when to cutt off the search. MinimaxCutoff is identical to MinimaxValue except 1.Terminal? is replaced by Cutoff? 2.Utility is replaced by Eval. E.g.) Apply a depth-limit. => the amount of time used wont exceed what the rules of the game allow. wont exceed what the rules of the game allow. Does it work in practice? b m = 10 6, b=35 m=4

24
24 Deterministic games in practice Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used a precomputed endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 444 billion positions. Chess: Deep Blue defeated human world champion Garry Kasparov in a six- game match in Deep Blue searches 200 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply. Othello: human champions refuse to compete against computers, who are too good. Go: human champions refuse to compete against computers, who are too bad. In go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves.

25
25 Summary Games are fun to work on! They illustrate several important points about AI –perfection is unattainable must approximate –good idea to think about what to think about

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google