Properties of - //the leaf node (terminal state) ) 9 ( The - - - PowerPoint PPT Presentation

properties of
SMART_READER_LITE
LIVE PREVIEW

Properties of - //the leaf node (terminal state) ) 9 ( The - - - PowerPoint PPT Presentation

G Game Playing Pl i - Pruning Pruning Introduction to Artificial Intelligence Hadi Moradi 1 2. - pruning: search cutoff Pruning: eliminating a branch of the search tree from consideration without exhaustive examination


slide-1
SLIDE 1

G Pl i Game Playing

α-β Pruning α β Pruning

Introduction to Artificial Intelligence Hadi Moradi

1

slide-2
SLIDE 2
  • 2. α-β pruning: search cutoff

Pruning: eliminating a branch of the search tree

from consideration without exhaustive examination of each node

Does it work?

Yes, it roughly cuts the branching factor from b to √b

l i i d bl f l k h d h i i resulting in double as far look-ahead than pure minimax

2

slide-3
SLIDE 3

α-β pruning: example

≥ 6 MAX 6 MIN 6 12 8

3

slide-4
SLIDE 4

α-β pruning: example

≥ 6 MAX 6 ≤ 2 MIN 6 12 8 2

4

slide-5
SLIDE 5

α-β pruning: example

≥ 6 MAX 6 ≤ 2 ≤ 5 MIN 6 12 8 2 5

5

slide-6
SLIDE 6

α-β pruning: example

≥ 6 MAX Selected move 6 ≤ 2 ≤ 5 MIN 6 ≤ 2 ≤ 5 6 12 8 2 5

6

6 12 8 2 5

slide-7
SLIDE 7

α-β pruning: general principle

Player Opponent

m

α = 6

Opponent

If α > v then MAX will chose m so prune tree under n Similar for β for MIN

6

Player

β

7

Opponent

n v = 2

slide-8
SLIDE 8

Properties of α-β

8

slide-9
SLIDE 9

The α-β algorithm

//the leaf node (terminal state) ( )

9

slide-10
SLIDE 10

The α-β algorithm (cont.)

//the leaf node (terminal state)

10

slide-11
SLIDE 11

Remember Minimax: Recursive implementation p

11

Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(bm) Space complexity: O(bm) (= DFS

Does not keep all nodes in memory.)

slide-12
SLIDE 12

More on the α-β algorithm: t t f Mi i start from Minimax

12

slide-13
SLIDE 13

The α-β algorithm

Note: These are both Local variables. At the Start of the algorithm, l h We initialize them to

α = -∞ and β = +∞

13

slide-14
SLIDE 14

A Walk Through Example p

α : Best choice so far for MAX MAX

α = -∞ β +

α : Best choice so far for MAX β : Best choice so far for MIN

β = +∞

MIN MAX

14

5 10 4 2 8 7

slide-15
SLIDE 15

In Max-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ V= -∞

β

MIN

Max-Value loops

  • ver these

MAX 5 10 4 2 8 7

15

5 10 4 2 8 7

slide-16
SLIDE 16

In Max-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN

α= -∞ β= +∞

MAX 5 10 4 2 8 7

16

5 10 4 2 8 7

slide-17
SLIDE 17

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= +∞ v= +∞ v= +∞

MAX 5 10 4 2 8 7

17

5 10 4 2 8 7

slide-18
SLIDE 18

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= +∞ v= +∞ v= +∞

Min-Value loops

  • ver these

MAX 5 10 4 2 8 7

18

5 10 4 2 8 7

slide-19
SLIDE 19

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= +∞ v= +∞ α= -∞ β= +∞

MAX 5 10 4 2 8 7

19

5 10 4 2 8 7

Utility(state) =5

slide-20
SLIDE 20

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= +∞ v= 5 v= 5

MAX 5 10 4 2 8 7

20

5 10 4 2 8 7

slide-21
SLIDE 21

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α = -∞ β = +∞

β

MIN

α= -∞ β= 5 v= 5 v= 5

MAX 5 10 4 2 8 7

21

5 10 4 2 8 7

slide-22
SLIDE 22

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α = -∞ β = +∞

β

MIN

α= -∞ β= 5 v= 5 α= -∞ β= 5 v= 5

MAX 5 10 4 2 8 7

22

5 10 4 2 8 7

slide-23
SLIDE 23

α : Best choice so far for MAX β: Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= 5 v= 5 α= -∞ β= 5

MAX 5 10 4 2 8 7

23

5 10 4 2 8 7

Utility(state) =10

slide-24
SLIDE 24

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α = -∞ β = +∞

β

MIN

α= -∞ β= 5 v= 5 <10

MAX 5 10 4 2 8 7

24

5 10 4 2 8 7

slide-25
SLIDE 25

α : Best choice so far for MAX β: Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= 5 v= 5 α= -∞ β= 5

MAX 5 10 4 2 8 7

25

5 10 4 2 8 7

Utility(state) =4

slide-26
SLIDE 26

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= 5 v= 5 >4

MAX 5 10 4 2 8 7

26

5 10 4 2 8 7

slide-27
SLIDE 27

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= 5 v= 4

MAX 5 10 4 2 8 7

27

5 10 4 2 8 7

slide-28
SLIDE 28

In Min-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= -∞

MIN

α= -∞ β= 4 v= 4

MAX 5 10 4 2 8 7

28

5 10 4 2 8 7

slide-29
SLIDE 29

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= -∞ β= +∞ v= 4

MIN MAX 5 10 4 2 8 7

29

5 10 4 2 8 7

slide-30
SLIDE 30

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= 4 β= +∞ v= 4

MIN MAX 5 10 4 2 8 7

30

5 10 4 2 8 7

slide-31
SLIDE 31

In Max-Value:

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN

α= 4 β= +∞ v= 4

MAX 5 10 4 2 8 7

31

5 10 4 2 8 7

slide-32
SLIDE 32

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN

α= 4 β= +∞ v= +∞

MAX 5 10 4 2 8 7

32

5 10 4 2 8 7

slide-33
SLIDE 33

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN MAX 5 10 4 2 8 7

4

33

5 10 4 2 8 7

α= 4 β= +∞ v= +∞

slide-34
SLIDE 34

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN MAX 5 10 4 2 8 7

4

34

5 10 4 2 8 7

α= 4 β= +∞

slide-35
SLIDE 35

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN

α= 4 β= +∞ v= 2

MAX 5 10 4 2 8 7

35

5 10 4 2 8 7

slide-36
SLIDE 36

α : Best choice so far for MAX β : Best choice so far for MIN MAX

α= -∞ β= +∞ v= -∞

β

MIN

α= 4 β= +∞ v= 2

MAX 5 10 4 2 8 7

36

5 10 4 2 8 7

slide-37
SLIDE 37

α : Best choice so far for MAX β : Best choice so far for MIN MAX β

α= 4 β= +∞ v= 4 >2

MIN MAX 5 10 4 2 8 7

37

5 10 4 2 8 7

slide-38
SLIDE 38

Another way to understand the algorithm

From:

http://yoda.cis.temple.edu:8080/UGAIWWW/lectures95/se h/ l h b t ht l arch/alpha-beta.html

For a given node N,

α is the value of N to MAX β is the value of N to MIN

38

slide-39
SLIDE 39

Alpha/Beta pruning - example (4)

A move (max) B move (min) A move (max)

8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2 39 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2

slide-40
SLIDE 40

Alpha/Beta pruning - example (4)

A move (max) B move (min) A move (max)

8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2 40 8 7 3 9 1 6 2 4 1 1 3 5 3 9 2 6 5 2 1 2 3 9 7 2

slide-41
SLIDE 41

State-of-the-art for deterministic games

41

slide-42
SLIDE 42

Chess As An Example

Ch b i

Chess basics

8x8 board, 16 pieces per side, average branching

factor of 38 factor of 38

Rating system based on competition

500

  • -- beginner/legal

1200

  • -- good weekend warrier

2000

  • -- world championship level

2500+ --- grand master

2500 grand master

time limited moves important aspects: position, material 42

slide-43
SLIDE 43

Sketch of Chess History

First discussed by Shannon, Sci. American, 1950 Initially, two approaches

human-like brute force search

1966 MacHack ---1100 --- average tournament

player

1970’s

discovery that 1 ply = 200 rating points 43 hash tables quiescence search

slide-44
SLIDE 44

Sketch of Chess History

Chess 4.x reaches 2000 (expert level),

1979

Belle 2200, 1983

special purpose hardware special purpose hardware

1986 --- Cray Blitz and Hitech 100,000 to

120 000 position/sec using special 120,000 position/sec using special purpose hardware

44

slide-45
SLIDE 45

Deep Blue History

1985, Hsu build BLSI move generator (using

DARPA funding!) g )

Anantharaman combined with chess program

leading to 50K moves/second algorithm

1986 CCC ---- no luck, but notice “blind forced

move” was a problem

singular extension: if you see a position where only

a single move determines the line, follow it

1987 l ith (Chi t t) 400

45

1987 --- new algorithm won (Chiptest) 400-

500K position/sec

slide-46
SLIDE 46

IBM checks in

Deep thought:

250 chips (2M pos/sec /// 6-7M pos/soc) Evaluation hardware

piece placement pawn placement pawn placement passed pawn eval file configurations

120 t t t

120 parameters to tune

Tuning done to master’s games

hill climbing and linear fits

46

g

1989 --- rating of 2480 = = = Kasparov beats

slide-47
SLIDE 47

IBM Checks In

Deep Blue is the next generation

parallel version of deep thought

p p g

200 M pos/sec 60B positions in the 3 minutes

allotted for move DB 1 32 R /6000’ ith 6 h / d

DB 1 = 32 Rs/6000’s with 6 chess proc/node DB 2 = faster 32 nodes w 8 chess proc/node (256 proc) message passing architecture message passing architecture search as much as 20-30 levels deep using sing.

extension

In 1997, Kasparov beaten

Kasparov changed strategy in earlier games 47 As much a psychological as mental victory

http://www.research.ibm.com/deepblue/

slide-48
SLIDE 48

Nondeterministic games Nondeterministic games

48

slide-49
SLIDE 49

Algorithm for nondeterministic games

49

slide-50
SLIDE 50

Remember: Minimax algorithm

50

slide-51
SLIDE 51

Nondeterministic games: the element of chance

CHANCE

?

expectimax and expectimin, expected values over all possible outcomes

3 ? 0.5 0.5

CHANCE

? 8

51

8 17

slide-52
SLIDE 52

Evaluation functions: Exact values DO matter

Order-preserving transformation do not necessarily behave the same!

52

NOTE: It is not the same as MINIMAX algorithm

slide-53
SLIDE 53

State-of-the-art for nondeterministic games

53

slide-54
SLIDE 54

Summary

54

slide-55
SLIDE 55

Exercise: Game Playing

C id th f ll i t i hi h th l ti f ti l

(a) Compute the backed up

Consider the following game tree in which the evaluation function values are shown below each leaf node. Assume that the root node corresponds to the maximizing player. Assume the search always visits children left-to-right.

(a) Compute the backed-up values computed by the minimax algorithm. Show your answer by writing

A Max

your answer by writing values at the appropriate nodes in the above tree. (b) Compute the backed-up

A B C D Min

(b) Compute the backed up values computed by the alpha-beta algorithm. What nodes will not be

E F G H I J K Max

examined by the alpha- beta pruning algorithm? (c) What move should Max

L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

55

( ) choose once the values have been backed-up all the way?

slide-56
SLIDE 56

Exercise: Game Playing

A Max

α = -∞ β = +∞

Max-Value loops

B C D Max Min

Max-Value loops

  • ver these

E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

56

slide-57
SLIDE 57

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min

Min-Value loops

E F G H I J K Max

  • ver these

L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

57

slide-58
SLIDE 58

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max

Max-Value loops

L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

p

  • ver these

58

slide-59
SLIDE 59

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

59

slide-60
SLIDE 60

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

60

slide-61
SLIDE 61

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

61

slide-62
SLIDE 62

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

62

slide-63
SLIDE 63

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

63

slide-64
SLIDE 64

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

64

slide-65
SLIDE 65

Exercise: Game Playing

A Max

α = -∞ β = +∞

B C D Max Min E F G H I J K Max L M N O P Q R S T U V W Y X 2 3 8 5 7 6 1 5 2 8 4 2 10 Min

65

slide-66
SLIDE 66

66

slide-67
SLIDE 67

67