1 / 31

Games: Expectimax

Games: Expectimax. Andrea Danyluk September 25, 2013. Announcements. Programming Assignment 2: Games Anyone still looking for a partner? Partner can’t be the same as for Assignment 1. Today’s Lecture. Just a bit more on α-β pruning Games with more than 2 players Expectimax Pacman.

donoma
Download Presentation

Games: Expectimax

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Games:Expectimax Andrea Danyluk September 25, 2013

  2. Announcements • Programming Assignment 2: Games • Anyone still looking for a partner? • Partner can’t be the same as for Assignment 1

  3. Today’s Lecture • Just a bit more on α-β pruning • Games with more than 2 players • Expectimax • Pacman

  4. Is there a problem here??? α = 8 Β = +inf α = 8 Β = +inf 2 8 2 8 9 8 8 7 9 1 6 11 19 8 3 4 5

  5. functionαβSEARCH(state) returns an action a v = MAX-VALUE(state, -infinity, +infinity) return action a in ACTIONS(state) with value v function MAX-VALUE(state, α, β) returns a utility value v if TERMINAL-TEST(state) then return UTILITY(state) v = -infinity for each ainACTIONS(state) do v = MAX(v, MIN-VALUE(RESULT(state, a), α, β)) ifv ≥ βthen returnv α = MAX(α, v) returnv function MIN-VALUE(state, α, β) returns a utility value v if TERMINAL-TEST(state) then return UTILITY(state) v = infinity for each ainACTIONS(state) do v = MIN(v, MAX-VALUE(RESULT(state, a), α, β)) ifv ≤ αthen returnv β = MIN(β, v) returnv

  6. Node Order Matters Best ordering for maximum pruning? A MAX B C D min 3 7 8 10 8 4 2 7 5

  7. Move Ordering • Can we order moves in such a way that α-β will prune more rather than less? • Chess? • Connect 4? • Don’t worry about this for Pacman assignment

  8. Properties of α-β • Pruning does not affect the final result (but be careful) • Good move ordering improves effectiveness of pruning • If search depth is d, what is the time complexity of minimax? • O(bd) • With perfect pruning, get down to O(bd/2) • Doubles solvable depth [Adapted from Russell]

  9. Games with > 2 players • Up to 4 players • Player tries to place all 21 of his/her pieces • Hopes to block opponents from placing their pieces

  10. A Four-Player Game (5,7,2,9) Blue to move (5,7,2,9) (4,4,4,4) Yellow to move … (5,7,2,9) (8,7,6,5) (6,4,19,8) (4,4,4,4) Red … … (3,5,1,8) (8,7,6,5) (6,4,19,8) (3,5,7,9) (5,7,2,9) (9,7,1,3) (4,3,2,1) (4,4,4,4) … … … Green … (5,7,2,9) (4,3,1,1) (2,6,10,2) (6,4,19,8)

  11. Multi-Player Games • Evaluation function returns a vector of utilities • Each player chooses the move that maximizes its utility. • Is Pacman with 2 ghosts a multi-player game?

  12. Stochastic Games

  13. Expectimax • Introduce chance nodes into a minimax tree 3 -1 0.5 0.5 0.5 0.5 -2 2 4 0 2 4 7 4 6 0 5 -2

  14. Expectimax • Introduce chance nodes into a minimax tree

  15. Expectimax • Introduce chance nodes into a minimax tree 0.5 0.5

  16. Expectimax • Introduce chance nodes into a minimax tree 0.5 0.5 2 2 4

  17. Expectimax • Introduce chance nodes into a minimax tree 1+ 0.5 0.5 2 2 4

  18. Expectimax • Introduce chance nodes into a minimax tree 1+ 0.5 0.5 2 4 2 4 7 4

  19. Expectimax • Introduce chance nodes into a minimax tree 3 0.5 0.5 2 4 2 4 7 4

  20. Expectimax • Introduce chance nodes into a minimax tree 3 0.5 0.5 0.5 0.5 2 4 2 4 7 4

  21. Expectimax • Introduce chance nodes into a minimax tree 3 0.5 0.5 0.5 0.5 2 4 0 2 4 7 4 6 0

  22. Expectimax • Introduce chance nodes into a minimax tree 3 0+ 0.5 0.5 0.5 0.5 2 4 0 2 4 7 4 6 0

  23. Expectimax • Introduce chance nodes into a minimax tree 3 0+ 0.5 0.5 0.5 0.5 -2 2 4 0 2 4 7 4 6 0 5 -2

  24. Expectimax • Introduce chance nodes into a minimax tree 3 -1 0.5 0.5 0.5 0.5 -2 2 4 0 2 4 7 4 6 0 5 -2

  25. Expectimax • Introduce chance nodes into a minimax tree 3 -1 0.5 0.5 0.5 0.5 -2 2 4 0 2 4 7 4 6 0 5 -2 [From Russell]

  26. Expectimax

  27. Evaluation Functions Revisited 1 2 2 4 1 20 20 400 Behavior is preserved under any monotonic transformation of EVAL [From Russell]

  28. Evaluation Functions Revisited 2.1 40.9 1.3 21 .9 .9 .9 .1 .1 .1 .1 .9 30 2 3 1 4 20 1 400 1 1 20 20 30 30 1 400 2 2 3 3 1 4 4 400 Behavior is preserved only under positive linear transformation of EVAL [From Russell]

  29. ExpectimaxPacman def value(s) if s is a max node return maxValue(s) if s is an exp node return expValue(s) if s is a terminal node return eval(s) def maxValue(s) values = [value(s1) for s1 in succ(s)] return max(values) def expValue(s) values = [value(s1) for s1 in succ(s)] weights = [prob(s,s1) for s1 in succ(s)] return expectation(values, weights) [Verbatim from CS 188]

  30. Depth-limited Expectimax 1 ply 1 7 3 4 6 2 5 1 Don’t forget: Magnitudes of the utilities / heuristic evaluations need to be meaningful.

  31. Why Pacman Can Starve He knows his score can go up by eating now. He knows his score can go up by eating later. Within this search window there are no other eating opportunities.

More Related