Presentation is loading. Please wait.

Presentation is loading. Please wait.

Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour.

Similar presentations


Presentation on theme: "Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour."— Presentation transcript:

1 Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour

2 Two Players Games One Search Tree for both Players –Even layers – Max Player move –Odd Layers – Min Player move The state evaluated according to heuristic function.

3 MinMax search strategy Generate the whole game tree. (Or up to a constant depth) Evaluate Terminal states (Leafs) propagate Min-Max values up from leafs Search for MAX best next move, so that no matter what MIN does MAX will be better off For branching factor b and depth search d the complexity is O(b d )

4 MinMax first Example

5

6

7 1

8 1-2

9 1-2 1

10 Cuting Off Search We want to prune the tree: stop exploring subtrees with values that will not influence the final MinMax root decision In the worst case, no pruning. –The complexity is O(b d ). –In practice, O(b d/2 ), with branching factor of b 1/2 instead of b.

11 Alpha Beta First Example

12 Alpha and Beta values At a Max node we will store an alpha value –the alpha value is lower bound on the exact minimax score –the true value might be   –if we know Min can choose moves with score <  then Min will never choose to let Max go to a node where the score will be  or more At a Min node,  value is similar but opposite Alpha-Beta search uses these values to cut search

13 Alpha Beta in Action Why can we cut off search? Beta = 1 < alpha = 2 where the alpha value is at an ancestor node At the ancestor node, Max had a choice to get a score of at least 2 (maybe more) Max is not going to move right to let Min guarantee a score of 1 (maybe less)

14 Alpha and Beta values Max node has  value –the alpha value is lower bound on the exact minimax score –with best play Max can guarantee scoring at least  Min node has  value –the beta value is upper bound on the exact minimax score –with best play Min can guarantee scoring no more than  At Max node, if an ancestor Min node has  <  –Min’s best play must never let Max move to this node therefore this node is irrelevant –if  = , Min can do as well without letting Max get here so again we need not continue

15 Alpha-Beta Pruning Rule Two key points: –alpha values can never decrease –beta values can never increase Search can be discontinued at a node if: – Max node: the alpha value is  the beta of any Min ancestor this is beta cutoff –Min node: the beta value is  the alpha of any Max ancestor this is alpha cutoff

16 #2b Left->Right  = - ,  = + 

17 #2b Left->Right  = - ,  = + 

18 #2b Left->Right  = - ,  = + 

19 #2b Left->Right  = - ,  = +   = - ,  = 4  = - ,  = + 

20 #2b Left->Right  = - ,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4

21 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4

22 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = + 

23 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = + 

24 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = + 

25 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = +   = 8,  = +   = 4,  = + 

26 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = +   = 8,  = +   = 4,  = +  = 8,  = + 

27 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = +   = 8,  = +   = 4,  = +  = 8,  = + 

28 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = +   = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = + 

29 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = +   = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +  (Alpha pruning)

30 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +  (Alpha pruning)

31 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8 (Alpha pruning)

32 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8 (Alpha pruning)

33 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8 (Alpha pruning)

34 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)

35 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)

36 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8

37 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8

38 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 8

39 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 8

40 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8

41 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6

42 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 5,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6

43 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 6,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6

44 #2b Left->Right  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 6  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 6,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6

45 #2b Left->Right  = 6,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 6  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 6,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6

46 #2b Left->Right  = 6,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 6  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 6,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6  = 6,  = + 

47 #2b Left->Right  = 7,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 6  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 6,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8  = 5,  = 6  =5,  =8  =5,  =6  = 6,  = + 

48 Beta Pruning  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 4,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8 9

49 Beta Pruning  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 9,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8 9

50 Beta Pruning  = 4,  = +   = - ,  = 4  = - ,  = +  = - ,  = 4  = 4,  = 8  = 8,  = +   = 4,  = +  = 8,  = 6  = 8,  = +   = 9,  = 8  = 4,  = 3  = 4,  = 8 (Alpha pruning)  = 4,  = 8 9 (Beta pruning)

51 #2b Right->Left  = - ,  = + 

52 #2b Right->Left  = - ,  = + 

53 #2b Right->Left  = 7,  = +   = - ,  = + 

54 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = + 

55 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = + 

56 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = + 

57 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = + 

58 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 12  =7,  =+ 

59 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 12  =7,  =+ 

60 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+ 

61 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)

62 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = + 

63 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = + 

64 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = + 

65 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = + 

66 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+ 

67 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)

68 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)

69 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)

70 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)

71 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)  = 7,  = + 

72 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)  = 7,  = + 

73 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)  = 7,  = 7  = 7,  = + 

74 #2b Right->Left  = 7,  = +   = - ,  = +  = 7,  = 6  = 7,  = +   = 7,  = 6  =7,  =+  (Alpha pruning)  = 7,  = +  = 7,  = -1  =7,  =+  (Alpha pruning)  = 7,  = 7  = 7,  = +  (Alpha pruning)

75 - 2a


Download ppt "Min-Max Trees Based on slides by: Rob Powers Ian Gent Yishay Mansour."

Similar presentations


Ads by Google