Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V....

56
Artificial Intelligence Adversarial search Chapter 6, AIMA presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who in turn borrowed from C. Dyer,...
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    219
  • download

    0

Transcript of Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V....

Page 1: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Artificial Intelligence

Adversarial searchChapter 6, AIMA

This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who in turn borrowed from C. Dyer,...

Page 2: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Adversarial search

• At least two agents and a competitive environment: Games, economies.

• Games and AI:– Generally considered to require

intelligence (to win)– Have to evolve in real-time– Well-defined and limited environment

Page 3: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

© Thierry DichtenmullerBoard games

Page 4: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Games & AI

Deterministic Chance

perfect info Checkers, Chess, Go, Othello

Backgammon, Monopoly

imperfect info Bridge, Poker, Scrabble

Page 5: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Games and search

Traditional search: single agent, searches for its well-being, unobstructed

Games: search against an opponent

Example: two player board game (chess, checkers, tic-tac-toe,…)Board configuration: unique arrangement of "pieces“

Representing board games as goal-directed search problem (states = board configurations):– Initial state: Current board configuration– Successor function: Legal moves– Goal state: Winning/terminal board configuration– Utility function: Current board configuration

Page 6: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

• Initial state: 33 empty table.

• Successor function: Players take turns marking or in the table cells.

• Goal state: When all the table cells are filled or when either player has three symbols in a row.

• Utility function: +1 for three in a row, -1 if the opponent has three in a row, 0 if the table is filled and no-one has three symbols in a row.

Initial state

Goal stateUtility = 0

Goal stateUtility = +1

Goal stateUtility = -1

Page 7: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

The minimax principle

Assume the opponent plays to win and always makes the best possible move.

The minimax value for a node = the utility for you of being in that state, assuming that both players (you and the opponent) play optimally from there on to the end.

Terminology: MAX = you, MIN = the opponent.

Page 8: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

Your (MAX) move

()

Assignment: Expand this tree to the end of the game.

Page 9: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

Utility = +1 Utility = 0 Utility = 0 Utility = 0 Utility = 0 Utility = +1

Your (MAX) move

Opponent (MIN) move

Your (MAX) move

Page 10: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

Utility = +1 Utility = 0 Utility = 0 Utility = 0 Utility = 0 Utility = +1

Your (MAX) move

Opponent (MIN) move

Your (MAX) move

+1 +10 0 0 0Minimaxvalue

Page 11: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

Utility = +1 Utility = 0 Utility = 0 Utility = 0 Utility = 0 Utility = +1

Your (MAX) move

Opponent (MIN) move

Your (MAX) move

+1 +10 0 0 0Minimaxvalue

0 0 0Minimaxvalue

Page 12: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Example: Tic-tac-toe

Utility = +1 Utility = 0 Utility = 0 Utility = 0 Utility = 0 Utility = +1

Your (MAX) move

Opponent (MIN) move

Your (MAX) move

+1 +10 0 0 0Minimaxvalue

0 0 0Minimaxvalue

0

Minimaxvalue

Page 13: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

The minimax value

Minimax value for node n =

Utility(n) If n is a terminal node

Max(Minimax-values of successors) If n is a MAX node

Min(Minimax-values of successors) If n is a MIN node

High utility favours you (MAX), therefore choose move with highest utility

Low utility favours the opponent (MIN), therefore choose move with lowest utility

Page 14: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

The minimax algorithm1. Start with utilities of terminal nodes2. Propagate them back to root node by choosing the

minimax strategy

EDB C

A

EDB C

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

EDB C

A

E1

D0

B-5

C-6

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

min

EDB C

A

E1

D0

B-5

C-6

A1

M1

N3

O2

K0

L2

F7

G-5

H3

I9

J-6

max

Figure borrowed from V. Pavlovic

Page 15: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

The minimax algorithm1. Start with utilities of terminal nodes2. Propagate them back to root node by choosing the

minimax strategy

EDB C

A

EDB C

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

EDB C

A

E1

D0

B-5

C-6

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

min

EDB C

A

E1

D0

B-5

C-6

A1

M1

N3

O2

K0

L2

F7

G-5

H3

I9

J-6

max

Figure borrowed from V. Pavlovic

Page 16: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

The minimax algorithm1. Start with utilities of terminal nodes2. Propagate them back to root node by choosing the

minimax strategy

EDB C

A

EDB C

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

EDB C

A

E1

D0

B-5

C-6

A

M1

N3

O2

K0

L2

F-7

G-5

H3

I9

J-6

min

EDB C

A

E1

D0

B-5

C-6

A1

M1

N3

O2

K0

L2

F7

G-5

H3

I9

J-6

max

Figure borrowed from V. Pavlovic

Page 17: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Complexity of minimax algorithm

• A depth-first search– Time complexity O(bd)– Space complexity O(bd)

• Time complexity impossible in real games (with time constraints) except in very simple games (e.g. tic-tac-toe)

Page 18: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Strategies to improve minimax

1. Remove redundant search paths- symmetries

2. Remove uninteresting search paths- alpha-beta pruning

3. Cut the search short before goal- Evaluation functions

4. Book moves

Page 19: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

1. Remove redundant paths

Tic-tac-toe has mirror symmetries

and rotational symmetries

= = =

Page 20: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Image from G. F. Luger, ”Artificial Intelligence”, 2002

First three levels of the tic-tac-toe state space reduced by symmetry

3 states(instead of 9)

12 states(instead of 8·9 = 72)

Page 21: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

2. Remove uninteresting paths

If the player has a better choice m at n’s parent node, or at any node further up, then node n will never be reached.

Prune the entire path below node m’s parent node (except for the path that m belongs to, and paths that are equal to this path).

Minimax is depth-first keep track of highest () and lowest () values so far.

Called alpha-beta pruning.

Page 22: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

B

N4

F G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

A

Alpha-Beta Example

minimax(A,0,4)

max CallStack

A

AAα=?

Slide adapted from V. Pavlovic

minimax(node, level, depth limit)

Page 23: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

B

N4

F G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(B,1,4)

max CallStack

A

BBβ=?

B

min

Slide adapted from V. Pavlovic

Page 24: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

Bβ=?

N4

F G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(F,2,4)

max CallStack

A

FFα=?

B

min

max

F

Slide adapted from V. Pavlovic

Page 25: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

Bβ=?

N4

Fα=?

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(N,3,4)

max CallStack

A

N4

B

min

max

F

gold: terminal state

N

Slide adapted from V. Pavlovic

Page 26: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

Bβ=?

N4

Fα=

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(F,2,4) is returned to

maxCall

Stack

A

alpha = 4, maximum seen so far

B

min

max

F

Fα=4

gold: terminal state

Slide adapted from V. Pavlovic

Page 27: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

O

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(O,3,4)

maxCall

Stack

AB

min

max

FO

min OOβ=?

gold: terminal state

Slide adapted from V. Pavlovic

Page 28: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=?

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(W,4,4)

max CallStack

AB

min

max

FO

W-3

min

W

gold: terminal stategold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 29: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(O,3,4) is returned to

max CallStack

A

beta = -3, minimum seen so far

B

min

max

FO

min Oβ=-3

gold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 30: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

O's beta (-3) < F's alpha (4): Stop expanding O (alpha cut-off)

B

min

max

FO

min

gold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 31: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta ExampleWhy?

Smart opponent selects W or worse O's upper bound is –3

So MAX shouldn't select O:-3 since N:4 is better

maxCall

Stack

AB

min

max

FO

min

gold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 32: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=?

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(F,2,4) is returned to

maxCall

Stack

AB

min

max

Fmin

X-5

alpha not changed (maximizing)

gold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 33: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(B,1,4) is returned to

maxCall

Stack

AB

min

max

min

X-5

beta = 4, minimum seen so far

Bβ=4

gold: terminal state (depth limit)

Slide adapted from V. Pavlovic

Page 34: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(G,2,4)

maxCall

Stack

AB

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G

G-5

Slide adapted from V. Pavlovic

Page 35: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(B,1,4) is returned to

maxCall

Stack

AB

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

beta = -5, minimum seen so far

Bβ=-5

Slide adapted from V. Pavlovic

Page 36: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(A,0,4) is returned to

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

alpha = -5, maximum seen so far

Aα=-5

Slide adapted from V. Pavlovic

Page 37: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(C,1,4)

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

C

Cβ=?

Page 38: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(H,2,4)

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

C

Cβ=?

H

H-10

Page 39: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

minimax(C,1,4) is returned to

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

C

Cβ=?

H-10

beta = -10, minimum seen so far

Cβ=-10

Page 40: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

C

Cβ=?

H-10

Cβ=-10

C's beta (-10) < A's alpha (-5): Stop expanding C (alpha cut-off)

Page 41: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

D

Cβ=?

H-10

Cβ=-10

minimax(D,1,4)

D0

Page 42: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

Cβ=?

H-10

Cβ=-10

D0

Aα=0

minimax(D,1,4) is returned to

Page 43: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

Cβ=?

H-10

Cβ=-10

D0

Aα=0

minimax(D,1,4) is returned to

Which nodes will be expanded?

Page 44: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

Cβ=?

H-10

Cβ=-10

D0

Aα=0

Which nodes will be expanded?

Kα=5

Mα=-7

Eβ=-7

All

Page 45: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

Cβ=?

H-10

Cβ=-10

D0

Aα=0

minimax(D,1,4) is returned to

What if we expandfrom right to left?

Page 46: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Oβ=-3

W-3

Bβ=

N4

Fα=4

G-5

X-5

ED0C

R0

P9

Q-6

S3

T5

U-7

V-9

K MH-10

I8 J L

2

Aα=?

Alpha-Beta Example

maxCall

Stack

A

min

max

min

X-5

Bβ=4

gold: terminal state (depth limit)

G-5

Bβ=-5

Aα=-5

Slide adapted from V. Pavlovic

Cβ=?

H-10

Cβ=-10

D0

Aα=0

Mα=-7

Eβ=-7

What if we expandfrom right to left?

Only 4

Page 47: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Alpha-Beta pruning rule

Stop expandingmax node n if n > higher in the treemin node n if n < higher in the tree

Page 48: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Alpha-Beta pruning rule

Stop expandingmax node n if n > higher in the treemin node n if n < higher in the tree

Which nodes will not be expanded when expanding from left to right?

= 8

= 2

= 2= 4

= 4= 4

= 2

= 8

= 4

= 3

= 3

= 3

= 3

= 2

Page 49: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Alpha-Beta pruning rule

Stop expandingmax node n if n > higher in the treemin node n if n < higher in the tree

Which nodes will not be expanded when expanding from left to right?

Page 50: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Alpha-Beta pruning rule

Stop expandingmax node n if n > higher in the treemin node n if n < higher in the tree

Which nodes will not be expanded when expanding from right to left?

= 9

= 9 = 4

= 2

= 2

= 3

= 3

= 3

= 3

= 3

= 8

= 2

= 8 = 7

= 4

= 9 = 2

Page 51: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Alpha-Beta pruning rule

Stop expandingmax node n if n > higher in the treemin node n if n < higher in the tree

Which nodes will not be expanded when expanding from right to left?

Page 52: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

3. Cut the search short

• Use depth-limit and estimate utility for non-terminal nodes (evaluation function)– Static board evaluation (SBE)– Must be easy to compute

Example, chess:

...Control"Center "Balance" Material" SBE

Material balance = value of white pieces – value of black pieces, wherepawn = +1, knight & bishop = +3, rook = +5, queen = +9, king = ?

The parameters (,,,...) can be learned (adjusted) from experience.

Page 53: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

http://en.wikipedia.org/wiki/Computer_chess

Leaf evaluation

For most chess positions, computers cannot look ahead to all final possible positions. Instead, they must look ahead a few plies and then evaluate the final board position. The algorithm that evaluates final board positions is termed the "evaluation function", and these algorithms are often vastly different between different chess programs.

Nearly all evaluation functions evaluate positions in units and at the least consider material value. Thus, they will count up the amount of material on the board for each side (where a pawn is worth exactly 1 point, a knight is worth 3 points, a bishop is worth 3 points, a rook is worth 5 points and a queen is worth 9 points). The king is impossible to value since its loss causes the loss of the game. For the purposes of programming chess computers, however, it is often assigned a value of appr. 200 points.

Evaluation functions take many other factors into account, however, such as pawn structure, the fact that doubled bishops are usually worth more, centralized pieces are worth more, and so on. The protection of kings is usually considered, as well as the phase of the game (opening, middle or endgame).

Page 54: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

4. Book moves

• Build a database (look-up table) of endgames, openings, etc.

• Use this instead of minimax when possible.

Page 55: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

http://en.wikipedia.org/wiki/Computer_chess

Using endgame databases

Nalimov Endgame Tablebases, which use state-of-the-art compression techniques, require 7.05 GB of hard disk space for all five-piece endings. It is estimated that to cover all the six-piece endings will require at least 1 terabyte. Seven-piece tablebases are currently a long way off.

While Nalimov Endgame Tablebases handle en passant positions, they assume that castling is not possible. This is a minor flaw that is probably of interest only to endgame specialists.

More importantly, they do not take into account the fifty move rule. Nalimov Endgame Tablebases only store the shortest possible mate (by ply) for each position. However in certain rare positions, the stronger side cannot force win before running into the fifty move rule. A chess program that searches the database and obtains a value of mate in 85 will not be able to know in advance if such a position is actually a draw according to the fifty move rule, or if it is a win, because there will be a piece exchange or pawn move along the way. Various solutions including the addition of a "distance to zero" (DTZ) counter have been proposed to handle this problem, but none have been implemented yet.

Page 56: Artificial Intelligence Adversarial search Chapter 6, AIMA This presentation owes a lot to V. Pavlovic @ Rutgers, who borrowed from J. D. Skrentny, who.

Games with chance

• Dice games, card games,...• Extend the minimax tree with chance

layers.Aα=

Bβ=2

7 2

Cβ=6

9 6

Dβ=0

5 0

Eβ=-4

8 -4

50/50 50/50

.5 .5 .5 .5

max

chance

min

Animation adapted from V. Pavlovic

50/504

50/50-2

Compute the expectedvalue over outcomes.

Aα=4

Select move withthe highestexpected value.