alpha beta prouning

26
ALPHA BETA PROUNING By HASHMISAF ([email protected])

Upload: hashmi-saf

Post on 17-Jan-2015

153 views

Category:

Engineering


1 download

DESCRIPTION

Alpha Beta Prouning

TRANSCRIPT

Page 1: Alpha beta prouning

ALPHA BETA PROUNING

By HASHMISAF ([email protected])

Page 2: Alpha beta prouning

Another Alpha-Beta Example

[-∞, +∞]

[-∞,+∞]

Range of possible values

Do DF-search until first leaf

Page 3: Alpha beta prouning

Alpha-Beta Example (continued)

[-∞,3]

[-∞,+∞]

Page 4: Alpha beta prouning

Alpha-Beta Example (continued)

[-∞,3]

[-∞,+∞]

Page 5: Alpha beta prouning

Alpha-Beta Example (continued)

[3,+∞]

[3,3]

Page 6: Alpha beta prouning

Alpha-Beta Example (continued)

[-∞,2]

[3,+∞]

[3,3]

This node isworse for MAX

Page 7: Alpha beta prouning

Alpha-Beta Example (continued)

[-∞,2]

[3,14]

[3,3] [-∞,14]

,

Page 8: Alpha beta prouning

Alpha-Beta Example (continued)

[−∞,2]

[3,5]

[3,3] [-∞,5]

,

Page 9: Alpha beta prouning

Alpha-Beta Example (continued)

[2,2][−∞,2]

[3,3]

[3,3]

Page 10: Alpha beta prouning

Alpha-Beta Example (continued)

[2,2][-∞,2]

[3,3]

[3,3]

Page 11: Alpha beta prouning

General alpha-beta pruning

• Consider a node n in the tree ---

• If player has a better choice at:– Parent node of n– Or any choice point further up

• Then n will never be reached in play.

• Hence, when that much is known about n, it can be pruned.

Page 12: Alpha beta prouning

Alpha-beta Algorithm

• Depth first search

– only considers nodes along a single path from root at any time

= highest-value choice found at any choice point of path for MAX

(initially, = −infinity)

= lowest-value choice found at any choice point of path for MIN

(initially, = +infinity)

• Pass current values of and down to child nodes during search.

• Update values of and during search:

– MAX updates at MAX nodes

– MIN updates at MIN nodes

• Prune remaining branches at a node when ≥

Page 13: Alpha beta prouning

When to Prune

• Prune whenever ≥ .

– Prune below a Max node whose alpha value becomes greater than or equal to the beta value of its ancestors.

• Max nodes update alpha based on children’s returned values.

– Prune below a Min node whose beta value becomes less than or equal to the alpha value of its ancestors.

• Min nodes update beta based on children’s returned values.

Page 14: Alpha beta prouning

Alpha-Beta Example Revisited

, , initial valuesDo DF-search until first leaf

=− =+

=− =+

, , passed to kids

Page 15: Alpha beta prouning

Alpha-Beta Example (continued)

MIN updates , based on kids

=− =+

=− =3

Page 16: Alpha beta prouning

Alpha-Beta Example (continued)

=− =3

MIN updates , based on kids.No change.

=− =+

Page 17: Alpha beta prouning

Alpha-Beta Example (continued)

MAX updates , based on kids.=3 =+

3 is returnedas node value.

Page 18: Alpha beta prouning

Alpha-Beta Example (continued)

=3 =+

=3 =+

, , passed to kids

Page 19: Alpha beta prouning

Alpha-Beta Example (continued)

=3 =+

=3 =2

MIN updates ,based on kids.

Page 20: Alpha beta prouning

Alpha-Beta Example (continued)

=3 =2

≥ ,so prune.

=3 =+

Page 21: Alpha beta prouning

Alpha-Beta Example (continued)

2 is returnedas node value.

MAX updates , based on kids.No change. =3

=+

Page 22: Alpha beta prouning

Alpha-Beta Example (continued)

,=3 =+

=3 =+

, , passed to kids

Page 23: Alpha beta prouning

Alpha-Beta Example (continued)

,

=3 =14

=3 =+

MIN updates ,based on kids.

Page 24: Alpha beta prouning

Alpha-Beta Example (continued)

,

=3 =5

=3 =+

MIN updates ,based on kids.

Page 25: Alpha beta prouning

Alpha-Beta Example (continued)

=3 =+

2 is returnedas node value.

2

Page 26: Alpha beta prouning

Alpha-Beta Example (continued)

Max calculates the same node value, and makes the same move!

2