1 / 23

Game Playing

Game Playing. Pruning. Pruning is used to narrow the search down e.g. if we find a branch where we will win no matter what, we don’t need to search that part of the tree anymore And if we find a guaranteed losing line we don’t need to search that part of tree any more. MiniMax.

cecil
Télécharger la présentation

Game Playing

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. Game Playing

  2. Pruning • Pruning is used to narrow the search down • e.g. if we find a branch where we will win no matter what, we don’t need to search that part of the tree anymore • And if we find a guaranteed losing line we don’t need to search that part of tree any more

  3. MiniMax • NIM Search tree 6 Max moves 1-5 2-4 3-3 Min moves 1-1-4 1-2-3 2-2-2 Max moves 1-1-1-3 1-1-2-2 Min moves 1-1-1-1-2

  4. MiniMax • NIM Search tree 6(?) Max moves 1-5 2-4 3-3 Min moves 1-1-4 1-2-3 2-2-2 Max moves 1-1-1-3 1-1-2-2 Min moves 1-1-1-1-2

  5. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4 1-2-3 2-2-2 Max moves 1-1-1-3 1-1-2-2 Min moves 1-1-1-1-2

  6. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3 1-1-2-2 Min moves 1-1-1-1-2

  7. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(?) 1-1-2-2(?) Min moves 1-1-1-1-2

  8. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(?) 1-1-2-2(?) Min moves 1-1-1-1-2(?)

  9. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(?) 1-1-2-2(?) Min moves 1-1-1-1-2(-1)

  10. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(?) Min moves 1-1-1-1-2(-1)

  11. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(?) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(1) Min moves 1-1-1-1-2(-1)

  12. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(1) 1-2-3(?) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(1) Min moves 1-1-1-1-2(-1)

  13. MiniMax • NIM Search tree 6(?) Max moves 1-5(?) 2-4(?) 3-3(?) Min moves 1-1-4(1) 1-2-3(1) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(1) Min moves 1-1-1-1-2(-1)

  14. MiniMax • NIM Search tree 6(?) Max moves 1-5(1) 2-4(?) 3-3(?) Min moves 1-1-4(1) 1-2-3(1) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(1) Min moves 1-1-1-1-2(-1)

  15. MiniMax • NIM Search tree 6(1) Max moves X X 1-5(1) 2-4(?) 3-3(?) Min moves X 1-1-4(1) 1-2-3(1) 2-2-2 Max moves 1-1-1-3(-1) 1-1-2-2(1) Min moves 1-1-1-1-2(-1)

  16. Alpha Beta Pruning • A generalized pruning procedure • During our depth-first search we remember • The score of the best choice so far for Max, alpha • And the best score so far for Min, beta • If we find a point where MIN can choose a move with the utility ≤ alpha. Then we can stop search there since • MAX will not choose a move since there are a alternative route that is better. (Where alpha was found)

  17. MAX MIN ≤5 2 MAX 2 3 12 8 14 5 2 Alpha-Beta (-) Pruning Example ≥ 3 3 ≤ 2 ≤ 14

  18. Alpha Beta Pruning • What can it do for us? • Allows deeper searches without penalty • Allows deeper searches at same time cost • The result is always the same as without pruning, but a lot faster

  19. Do Exact Values Matter?

  20. MiniMax and Heuristics • What about more complex games? • If the search space is too large • We could use a heuristic function to determine which nodes to expand first. (Not very useful though) • Limit our depth and when we reach a certain depth we evaluate the current standing there • After evaluating we use MiniMax as usual

  21. MiniMax and heuristics • Practically, rather than implement MiniMax, we implement MiniCutoff • Don’t build the whole tree. Takes lots of memory. • Limit the depth of “look ahead” • Use a utility function rather than an evaluation function.

  22. Cutting Off Search

  23. Cutting Off Search • Issues • Quiescence • Play has “settled down” • Evaluation function unlikely to exhibit wild swings in value in near future • Horizon effect • “Stalling for time” • Postpones inevitable win or damaging move by opponent • See: Figure 6.9 R&N • Solutions? • Quiescence search: expand non-quiescent positions further • No general solution to horizon problem at present

More Related