Presentation is loading. Please wait.

Presentation is loading. Please wait.

Alpha-beta Search. Two-player games zThe object of a search is to find a path from the starting position to a goal position zIn a puzzle-type problem,

Similar presentations


Presentation on theme: "Alpha-beta Search. Two-player games zThe object of a search is to find a path from the starting position to a goal position zIn a puzzle-type problem,"— Presentation transcript:

1 Alpha-beta Search

2 Two-player games zThe object of a search is to find a path from the starting position to a goal position zIn a puzzle-type problem, you (the searcher) get to choose every move zIn a two-player competitive game, you alternate choosing moves with the other player zThe other player doesn't want to reach your goal zYour search technique must be very different

3 Payoffs zEach game outcome has a payoff, which we can represent as a number zBy convention, we prefer positive numbers  In some games, the outcome is either a simple win ( +1 ) or a simple lose ( -1 )  In some games, you might also tie, or draw ( 0 ) zIn other games, outcomes may be other numbers (say, the amount of money you win at Poker)

4 Zero-sum games  Most common games are zero-sum: What I win ( $12 ), plus what you win ( -$12 ), equals zero zThere do exist non-zero-sum games zFor simplicity, we consider only zero-sum games zFrom our point of view, positive numbers are good, negative numbers are bad zFrom our opponents point of view, positive numbers are bad, negative numbers are good

5 A trivial "game" zWouldn't you like to win 50? zDo you think you will? zWhere should you move?

6 Minimaxing zYour opponent will choose smaller numbers  If you move left, your opponent will choose 3  If you move right, your opponent will choose -8  Your choice is 3 or -8 zPlay will be as shown

7 Heuristics zIn a large game, you don't really know the payoffs zA heuristic function computes, for a given node, your best guess as to what the payoff will be zThe heuristic function uses whatever knowledge you can build into the program zWe make two key assumptions: yYour opponent uses the same heuristic function yThe more moves ahead you look, the better your heuristic function will work

8 PBVs zA PBV is a preliminary backed-up value yExplore down to a given level using depth-first search yAs you reach each lowest-level node, evaluate it using your heuristic function yBack up values to the next higher node, according to the following rules: xIf your move, bring up the largest value, possibly replacing a smaller value xIf opponent's move, bring up smallest value, possible replacing a larger value

9 Using PBVs  Explore left-bottom 8 ; bring it up  Explore 5 ; smaller, so ignore it  Bring 8 up another level  Explore 2 ; bring it up  Explore 9 ; better, so bring up, replacing 2  Don't replace 8

10 Bringing up values zIf it's your move, and the next child of this node has a larger value than this node, replace this value zIf it's your opponent's move, and the next child of this node has a smaller value than this node, replace this value zAt your move, never reduce a value zAt your opponent's move, never increase a value

11 Alpha cutoffs  The value at your move is 8 (so far)  If you move right, the value there is 1 (so far) zYour opponent will never increase the value at this node zYou can ignore the black nodes

12 Beta cutoffs zAn alpha cutoff occurs where yIt is your opponent's turn to move yThe node has a lower PBV than some other node you could choose yYour opponent will never increase the PBV of this node zA beta cutoff occurs where yIt is your turn to move yThe node has a higher PBV than some other node the opponent could choose yYou will never decrease the PBV of this node

13 Using beta cutoffs zBeta cutoffs are harder to understand, because you have to see things from your opponent's point of view zYour opponent's alpha cutoff is your beta cutoff zWe assume your opponent is rational, and is using a heuristic function similar to yours zEven if this assumption is incorrect, it's still the best we can do

14 The importance of cutoffs zIf you can search to the end of the game, you know exactly how to play zThe further ahead you can search, the better zIf you can prune (ignore) large parts of the tree, you can search deeper on the other parts zSince the number of nodes at each level grows exponentially, the higher you can prune, the better zYou can save exponential time

15 Heuristic alpha-beta searching zThe higher in the search tree you can find a cutoff, the better (because of exponential growth) zTo maximize the number of cutoffs you can make: yApply the heuristic function at each node you come to, not just at the lowest level yExplore the "best" moves first y"Best" means best for the player whose move it is at that node

16 Best game playing strategies zFor any game much more complicated than tic- tac-toe, you have a time limit zSearching takes time; you need to use heuristics to minimize the number of nodes you search zBut complex heuristics take time, reducing the number of nodes you can search zSeek a balance between simple (but fast) heuristics, and slow (but good) heuristics

17 The End


Download ppt "Alpha-beta Search. Two-player games zThe object of a search is to find a path from the starting position to a goal position zIn a puzzle-type problem,"

Similar presentations


Ads by Google