16
Games with Chance 2012/04/25 1

Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Embed Size (px)

Citation preview

Page 1: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Games with Chance

2012/04/25

1

Page 2: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Nondeterministic Games: Backgammon

White moves clockwise toward 25.

Black moves counterclockwise toward 0.

A piece can move to any position unless there are multiple opponent pieces there; if there is one opponent, it is captured and must start over.

White has rolled 6-5 and must choose among four legal moves: (5-10, 5-11), (5-11, 19-24), (5-10, 10-16), (5-11, 11-16)

2

Page 3: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Nondeterministic Games: Backgammon (cont.-1)

• Backgammon– White can decide what his legal moves are, but cannot

determine black’s because that depends on what black rolls

• Game must include chance nodes

• How to pick best move?– Cannot apply minimax directly

3

Page 4: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Nondeterministic Games: Backgammon (cont.-1)

Chance nodes are included in the game tree

4

Page 5: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Nondeterministic Games in General

In nondeterministic games, chance introduced by dice, card-shuffling, face-down shuffling

5

Page 6: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Algorithm for Nondeterministic Games

• Expectiminimax gives perfect play

• Expectiminimax(n) =

Utility(n) if nTerminal

maxsSuccessors(n) Expectiminimax(s) if nMAX

minsSuccessors(n) Expectiminimax(s) if nMIN

sSuccessors(n) P(s)•Expectiminimax(s) if nChance

• Successor function for a chance node n augments the state of n with each possible dice roll to produce successor s and P(s)

6

Page 7: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Pruning in Nondeterministic Game Trees

• A version of - pruning is possible

[-∞,+∞] [-∞,+∞] [-∞,+∞] [-∞,+∞]

[-∞,+∞] [-∞,+∞]

[-∞,2] [-∞,+∞] [-∞,+∞] [-∞,+∞]

[-∞,+∞] [-∞,+∞]

2

[2,2] [-∞,+∞] [-∞,+∞] [-∞,+∞]

[-∞,+∞] [-∞,+∞]

2 2

[2,2] [-∞,2] [-∞,+∞] [-∞,+∞]

[-∞,2] [-∞,+∞]

2 2 2

[2,2] [1,1] [-∞,+∞] [-∞,+∞]

[1.5,1.5] [-∞,+∞]

2 2 2 1

[2,2] [1,1] [-∞,0] [-∞,+∞]

[1.5,1.5] [-∞,+∞]

2 2 2 1 0

[2,2] [1,1] [0,0] [-∞,+∞]

[1.5,1.5] [-∞,+∞]

2 2 2 1 0 1

[2,2] [1,1] [0,0] [-∞,1]

[1.5,1.5] [-∞,0.5]

2 2 2 1 0 1 1

7

Page 8: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Pruning Contd.• More pruning occurs if we can bound the leaf values

[-2,2] [-2,2] [-2,2] [-2,2]

[-2,2] [-2,2]

[-2,2] [-2,2] [-2,2] [-2,2]

[-2,2] [-2,2]

2

[2,2] [-2,2] [-2,2] [-2,2]

[0,2] [-2,2]

2 2

[2,2] [-2,2] [-2,2] [-2,2]

[0,2] [-2,2]

2 2 2

[2,2] [1,1] [-2,2] [-2,2]

[1.5,1.5] [-2,2]

2 2 2 1

[2,2] [1,1] [-2,0] [-2,2]

[1.5,1.5] [-2,1]

2 2 2 1 0

8

Page 9: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Digression: Exact Value DO Matter

• Behavior is preserved only by positive linear transformation of EvalHence Eval should be proportional to the expected payoff

Move to A1 is best Move to A2 is best

9

Page 10: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

10

Nondeterministic games in practice

Page 11: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Games of Imperfect Information• e.g., card game, where opponent’s initial cards are unknown• Typically we can calculate a probability for each possible deal• Seems just like having a big dice roll at the beginning of games• Idea: averaging over clairvoyancy

– compute the minimax value of each action for each possible deal of the cards

– choose the action with the highest expected value over all deals• Special case: if an action is optimal for all deals, it is optimal• GIB (Ginsberg, 1999), current best bridge program, approximate this

idea by modifying averaging over clairvoyancy– generating 100 deals consistent with bidding information– picking the action that wins most tricks on average

11

Page 12: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Example

• Four-card bridge/whist/hearts hand, Max to play first

12

Page 13: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

13

Proper analysis

Page 14: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

- Algorithmfunction ALPHA-BETA-SEARCH ( state ) returns an action inputs: state, current state in game

v MAX-VALUE ( state, – , ) return the action in SUCCESSORS ( state ) with value v

function MAX-VALUE ( state, , ) returns a utility value inputs: state, current state in game

, the value of the best alternative for MAX along the path to state, the value of the best alternative for MIN along the path to state

if TERMINAL-TEST ( state ) then return UTILITY ( state ) v – for a, s in SUCCESSORS ( state ) do v MAX ( v, MIN-VALUE ( s, , )) if v then return v // fail-high MAX ( , v ) return v

14

Page 15: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

- Algorithm (cont.)

function MIN-VALUE ( state, , ) returns a utility value inputs: state, current state in game

, the value of the best alternative for MAX along the path to state, the value of the best alternative for MIN along the path to state

if TERMINAL-TEST ( state ) then return UTILITY ( state ) v for a, s in SUCCESSORS ( state ) do v MIN ( v, MAX-VALUE ( s, , )) if v then return v // fail low MIN ( , v ) return v

15

Page 16: Games with Chance 2012/04/25 1. Nondeterministic Games: Backgammon White moves clockwise toward 25. Black moves counterclockwise toward 0. A piece can

Negamax(B. Chen, 2010)

16