adversarial search
play

Adversarial Search Rob Platt Northeastern University Some images - PowerPoint PPT Presentation

Adversarial Search Rob Platt Northeastern University Some images and slides are used from: AIMA CS188 UC Berkeley What is adversarial search? Adversarial search: planning used to play a game such as chess or checkers algorithms are


  1. Adversarial Search Rob Platt Northeastern University Some images and slides are used from: AIMA CS188 UC Berkeley

  2. What is adversarial search? Adversarial search: planning used to play a game such as chess or checkers – algorithms are similar to graph search except that we plan under the assumption that our opponent will maximize his own advantage...

  3. Some types of games Chess Solved/unsolved? Checkers Solved/unsolved? Tic-tac-toe Solved/unsolved? Go Solved/unsolved? Outcome of game can be predicted from any initial state assuming both players play perfectly

  4. Examples of adversarial search Chess Unsolved Checkers Solved Tic-tac-toe Solved Go Unsolved Outcome of game can be predicted from any initial state assuming both players play perfectly

  5. Examples of adversarial search Chess Unsolved ~10^40 states Checkers Solved ~10^20 states Tic-tac-toe Solved Less than 9!=362k states Go Unsolved ? Outcome of game can be predicted from any initial state assuming both players play perfectly

  6. Different types of games Deterministic / stochastic Two player / multi player? Zero-sum / non zero-sum Perfect information / imperfect information

  7. Different types of games Deterministic / stochastic Zero Sum: Two player / multi player? – utilities of all players sum to zero – pure competition Zero-sum / non zero-sum Non-Zero Sum: – utility function of each play Perfect information / imperfect information could be arbitrary – optimal strategies could involve cooperation

  8. Formalizing a Game Given: Action that player p Calculate a policy: should take from state s

  9. Formalizing a Game Given: How? Action that player p Calculate a policy: should take from state s

  10. How solve for a policy? Use adversarial search! – build a game tree

  11. This is a game tree for tic-tac-toe

  12. This is a game tree for tic-tac-toe You

  13. This is a game tree for tic-tac-toe You Them

  14. This is a game tree for tic-tac-toe You Them You

  15. This is a game tree for tic-tac-toe You Them You Them

  16. This is a game tree for tic-tac-toe You Them You Them Utility

  17. What is Minimax? Consider a simple game: 1. you make a move 2. your opponent makes a move 3. game ends

  18. What is Minimax? Consider a simple game: What does the minimax tree 1. you make a move look like in this case? 2. your opponent makes a move 3. game ends

  19. What is Minimax? Consider a simple game: What does the minimax tree 1. you make a move look like in this case? 2. your opponent makes a move 3. game ends Max (you) Min (them) Max 3 12 8 2 4 6 14 5 2 (you)

  20. What is Minimax? Max (you) Min (them) Max 3 12 8 2 4 6 14 5 2 (you) These are terminal utilities – assume we know what these values are

  21. What is Minimax? Max (you) Min 3 2 2 (them) Max 3 12 8 2 4 6 14 5 2 (you)

  22. What is Minimax? 3 Max Max (you) (you) Min Min 3 2 2 (them) (them) Max 3 12 8 2 4 6 14 5 2 (you)

  23. What is Minimax? 3 Max (you) This is called “backing up” Min 3 2 2 the values (them) Max 3 12 8 2 4 6 14 5 2 (you)

  24. Minimax Okay – so we know how to back up values ... … but, how do we construct the tree? 3 12 8 2 4 6 14 5 2 This tree is already built...

  25. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense.

  26. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense.

  27. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3

  28. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 12

  29. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 12 8

  30. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 3 12 8

  31. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 3 12 8

  32. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 2 3 12 8 2 4 6

  33. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. 3 3 2 2 3 12 8 2 4 6 14 5 2

  34. Minimax Notice that we only get utilities at the bottom of the tree … – therefore, DFS makes sense. – since most games have forward progress, the distinction between tree search and graph search is less important

  35. Minimax

  36. Minimax properties Is it always correct to assume your opponent plays optimally? Max (you) Min ? (them) Max (you) 10 10 9 100

  37. Minimax properties Is minimax optimal? Is it complete?

  38. Minimax properties Is minimax optimal? Is it complete? Time complexity = ? Space complexity = ?

  39. Minimax properties Is minimax optimal? Is it complete? Time complexity = Space complexity =

  40. Minimax properties Is minimax optimal? Is it complete? Time complexity = Space complexity = Is it practical? In chess, b=35, d=100

  41. Minimax properties Is minimax optimal? Is it complete? Time complexity = Space complexity = Is it practical? In chess, b=35, d=100 is a big number...

  42. Minimax properties Is minimax optimal? Is it complete? Time complexity = Space complexity = Is it practical? In chess, b=35, d=100 is a big number... So what can we do?

  43. Evaluation functions Key idea: cut off search at a certain depth and give the corresponding nodes an estimated value. 1 -6 1 Cut off -5 -6 3 1 recursion here

  44. Evaluation functions Key idea: cut off search at a certain depth and give the corresponding nodes an estimated value. the evaluation function 1 makes this estimate. -6 1 Cut off -5 -6 3 1 recursion here

  45. Evaluation functions How does the evaluation function make the estimate? – depends upon domain For example, in chess, the value of a state might equal the sum of piece values. – a pawn counts for 1 – a rook counts for 5 – a knight counts for 3 ...

  46. A weighted linear evaluation function number of pawns on the board number of knights on the board A pawn counts for 1 A knight counts for 3 Eval = 3-2.5=0.5 Eval = 3+2.5+1+1-2.5 = 5

  47. A weighted linear evaluation function number of pawns on the board number of knights on the board A pawn counts for 1 A knight counts for 3 Maybe consider other factors as well? Eval = 3-2.5=0.5 Eval = 3+2.5+1+1-2.5 = 5

  48. Evaluation functions Problem: In realistic games, cannot search to leaves! Solution: Depth-limited search Instead, search only to a limited depth in the tree Replace terminal utilities with an evaluation function for non-terminal positions Example: Suppose we have 100 seconds Can explore 10K nodes / sec So can check 1M nodes per move Guarantee of optimal play is gone More plies makes a BIG difference Use iterative deepening for an anytime algorithm

  49. At what depth do you run the evaluation function? Option 1: cut off search at a fixed depth 1 Option 2: cut off search at particular states deeper than a certain threshold -6 1 -5 -6 3 1 The deeper your threshold, the less the quality of the evaluation function matters...

  50. Alpha/Beta pruning

  51. Alpha/Beta pruning 3 3 12 8

  52. Alpha/Beta pruning 3 3 12 8

  53. Alpha/Beta pruning 3 3 12 8 2

  54. Alpha/Beta pruning 3 3 12 8 2 4

  55. Alpha/Beta pruning 3 We don't need to expand this node! 3 12 8 2 4

  56. Alpha/Beta pruning 3 We don't need to expand this node! Why? 3 12 8 2 4

  57. Alpha/Beta pruning Max Min 3 We don't need to expand this node! Why? 3 12 8 2 4

  58. Alpha/Beta pruning Max 3 Min 3 2 2 3 12 8 2 14 5 2

  59. Alpha/Beta pruning So, we don't need to expand these nodes in order to back up correct values! Max 3 Min 3 2 2 3 12 8 2 14 5 2

  60. Alpha/Beta pruning So, we don't need to expand these nodes That's alpha-beta in order to back up correct values! pruning. Max 3 Min 3 2 2 3 12 8 2 14 5 2

  61. Alpha/Beta pruning: algorithm α: MAX’s best option on path to root β: MIN’s best option on path to root def max-value(state, α, β): def min-value(state , α, β): initialize v = -∞ initialize v = +∞ for each successor of state: for each successor of state: v = max(v, v = min(v, value(successor, value(successor, α, β)) α, β)) if v ≥ β return v if v ≤ α return v α = max(α, v) β = min(β, v) return v return v

  62. Alpha/Beta pruning (-inf,+inf)

  63. Alpha/Beta pruning (-inf,+inf) (-inf,+inf)

  64. Alpha/Beta pruning (-inf,+inf) Best value for far for MIN along path to root (-inf,3) 3 3

  65. Alpha/Beta pruning (-inf,+inf) Best value for far for MIN along path to root (-inf,3) 3 3 12

  66. Alpha/Beta pruning (-inf,+inf) Best value for far for MIN along path to root (-inf,3) 3 3 12 8

  67. Alpha/Beta pruning Best value for far for MAX along path to root (3,+inf) (-inf,3) 3 3 12 8

  68. Alpha/Beta pruning (3,+inf) (-inf,3) (3,+inf) 3 3 12 8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend