MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid...

70
MiniMax and Alpha Beta Pruning

Transcript of MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid...

Page 1: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

MiniMax andAlpha Beta Pruning

Page 2: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

Minimax

• Algorithm that finds an optimal move for you (maximizer) in a two player game

• A game can be seen as a tree where nodes are possible game states.

• One of components of a game state is whose move it is:

• your (maximizer’s)

• your opponent’s (minimizer’s)

Page 3: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

• The initial state of the game is the root of the game tree.

• Maximizer starts the game.

• Children of the root tree represent all possible game states resulting from possible moves that maximizer could make.

• Those children nodes have children representing the game states after every possible minimizer’s moves.

• These nodes have children corresponding to the possible second moves of the maximizer.

• ...

• The leaves of the tree are final states of the game.

Page 4: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

• Every game state has a value associated with it

• The value of leaf nodes is obtained by some heuristic

• The heuristic value measures the favorability of the node for the maximizing player

• Internal (non leaf) nodes inherit their value from a child leaf node• At a node maximizer chooses the child with the greatest value, this value

becomes the value of the node• At a node minimizer chooses the child with the smallest value, this value becomes

the value of the node

Page 5: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

• The full minimax search explores some parts of the tree it does not have to.

• Expanding the entire game tree may be even infeasible.

• One of the solutions is to only search the tree to a specified depth. When the depth limit of the search is exceeded, apply evaluation function to the node as if it were a leaf

• Another solution is to prune some of the branches (using, for example, alpha-beta pruning technique)

Page 6: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

Alpha-Beta Pruning

Alpha-beta pruning allows to avoid searching subtrees of moves which do not lead to the optimal minimax solution.

Page 7: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

Page 8: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

path we are currently exploring

path to currently best-known solution

explored but not the best path

pruned (not explored) branches

Page 9: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

Page 10: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

≥ "

Page 11: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

Page 12: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

≤ "

Page 13: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

≤ "

Page 14: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

≤ "

≥ %

Page 15: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

≤ "

≥ %

Page 16: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 6 1 3 11622 74 9 2

= "

= "

≥ $

Page 17: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

6

Page 18: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

6

Page 19: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

6

Page 20: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

≥ %

6

Page 21: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

6

Page 22: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

Page 23: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

Page 24: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

Page 25: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

Page 26: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

≥4

Page 27: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

Page 28: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

≤ 7

Page 29: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

≤ 7

Page 30: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

≤ 7

≥ '

Page 31: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

≤ 7

≥ '

Page 32: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

≥ "

= %

≤ %

6

=7

= 7

≥ '

Page 33: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

5 2 7 1 3 11622 74 9 2

= "

= "

≥ $

=7

= %

≤ %

6

=7

= 7

≥ '

Page 34: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

Why “Alpha-beta” ?

Any new node is considered as a game-state of a poten4al solu4on only if the following equa4on holds

α ≤ # ≤ $where # is the current (es4mate of the) value of the node.

Therefore α ≤ $

Page 35: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

Page 36: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

≥ ∞≤ -∞

Page 37: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = ∞$ = -∞

Page 38: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = ∞$ = -∞

! = ∞$ = -∞

Page 39: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = ∞$ = -∞

! = ∞$ = -∞

5

Page 40: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = ∞$ = -∞

! = ∞$ = 5

5

Page 41: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = ∞$ = -∞

! = ∞$ = 5

5 2

Page 42: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

5

Page 43: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = -∞5

Page 44: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = -∞

7

5

Page 45: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

5

Page 46: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

5 7

Page 47: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = -∞

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

5 7

5

Page 48: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

5 7

5

Page 49: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !! = ∞$ = 5

5 7

5

Page 50: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !! = ∞$ = 5

5 7

5

! = ∞$ = 5

Page 51: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = ∞$ = 5! = ∞

$ = 5

5

75

Page 52: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = ∞$ = 5! = ∞

$ = 5

5

75

3

Page 53: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = ∞$ = 5! = ∞

$ = 5

5

75

3

3

Page 54: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

Page 55: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5

! = 5$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

Page 56: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

Page 57: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 5

Page 58: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 5

4

Page 59: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 5

4 7

Page 60: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = ∞$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

Page 61: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

Page 62: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 5

Page 63: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

Page 64: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

α ≰ !

Page 65: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

α ≰ !9

Page 66: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

α ≰ !9

7

Page 67: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

α ≰ !9

7

7

Page 68: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

! = 7$ = 5! = 5

$ = -∞

! = ∞$ = 5

5 2

! = 5$ = 7

7

α ≰ !

1

! = 3$ = 5! = ∞

$ = 5

5

75

3

3

α ≰ !3

! = ∞$ = 5

! = ∞$ = 7

4 7

7

! = 7$ = 9

9

α ≰ !9

7

7

Page 69: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

Alpha-Beta Pruning Prac2ce

h"p://inst.eecs.berkeley.edu/~cs61b/fa14/ta-materials/apps/ab_tree_prac=ce/

Page 70: MiniMax and Alpha Beta Pruning - GitLab · Alpha-Beta Pruning Alpha-beta pruningallows to avoid searching subtrees of moves which do not lead to the optimal minimax solution. 5 2

Optimizing even more...

• Order in which children are visited is relevant• Some branches will never be played by ra6onal players