1 / 31

Game and Tree Searching

Game and Tree Searching . Learning Objectives. Introduction to games Optimal decisions in games Alpha-Beta pruning Real-time decisions. Introduction to Games. Games as Search Problems Frameworks: two-player, multi-player; zero-sum; perfect information Minimax algorithm Perfect decisions

glenys
Download Presentation

Game and Tree Searching

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 and Tree Searching TCSS435A Isabelle Bichindaritz

  2. Learning Objectives • Introduction to games • Optimal decisions in games • Alpha-Beta pruning • Real-time decisions TCSS435A Isabelle Bichindaritz

  3. Introduction to Games • Games as Search Problems • Frameworks: two-player, multi-player; zero-sum; perfect information • Minimax algorithm • Perfect decisions • Imperfect decisions (based upon static evaluation function) • Issues • Quiescence • Horizon effect • Need for pruning (alpha-beta pruning) TCSS435A Isabelle Bichindaritz

  4. Introduction to Games • Perfect Play • General framework(s) • What could agent do with perfect info? • Resource Limits • Search ply • Static evaluation: from heuristic search to heuristic game tree search • Examples • Tic-tac-toe, connect four, checkers, connect-five • Chess, go • Games with Uncertainty • Explicit: games of chance (e.g., backgammon, Monopoly, blackjack) • Implicit TCSS435A Isabelle Bichindaritz

  5. Games versus Search Problems • Unpredictable Opponent • Games are adversarial search problems • Solution is strategy, contingency plan • Time limits • Unlikely to find goal • Must approximate • Plan of Attack • Algorithm for perfect play (J. von Neumann, 1944) • Finite horizon, approximate evaluation (C. Zuse, 1945; C. Shannon, 1950, A. Samuel, 1952-1957) • First chess program (Turing, 1951) • Pruning to allow deeper search (J. McCarthy, 1956) TCSS435A Isabelle Bichindaritz

  6. Types of Games • Information: Can Know (Observe) • … outcomes of actions / moves? • … moves committed by opponent? • Uncertainty • Deterministic vs. nondeterministic outcomes • Thought exercise: sources of nondeterminism? TCSS435A Isabelle Bichindaritz

  7. Minimax • Games with two players MIN and MAX are a search problem with: • Initial state • Successor function • Terminal test / state • Utility function (objective / payoff) • Win / loss / draw (chess) • +1 / -1 / 0 (chess) • -192 … +192 (backgammon) TCSS435A Isabelle Bichindaritz

  8. Minimax TCSS435A Isabelle Bichindaritz

  9. Minimax • Perfect play for deterministic, perfect-information games • Choose move to position with highest minimax value = best achievable payoff against best play • Simple example: 2-ply game, a ply being a half-move • Game ends after one move each by MAX and MIN (one move deep) TCSS435A Isabelle Bichindaritz

  10. Minimax TCSS435A Isabelle Bichindaritz

  11. Minimax Algorithm:Decision and Evaluation  what’s this?  what’s this? TCSS435A Isabelle Bichindaritz

  12. Properties of Minimax • Complete? TCSS435A Isabelle Bichindaritz

  13. Properties of Minimax • Complete? • … yes, provided following are finite: • Number of possible legal moves (generative breadth of tree) • “Length of game” (depth of tree) – more specifically? • A finite strategy can exist even in an infinite tree! • Perfect vs. imperfect information? • Q: What search is perfect minimax analogous to? • A: Bottom-up breadth-first TCSS435A Isabelle Bichindaritz

  14. Properties of Minimax • Complete? • … yes, provided the tree is finite: • Number of possible legal moves (generative breadth of tree) • “Length of game” (depth of tree) – more specifically? • Optimal? TCSS435A Isabelle Bichindaritz

  15. Properties of Minimax • Complete? • … yes, provided the tree is finite • Optimal? • … yes, provided perfect info (evaluation function) and opponent is optimal! • … otherwise, guaranteed if evaluation function is correct • Time Complexity? TCSS435A Isabelle Bichindaritz

  16. Properties of Minimax • Complete? • … yes, provided the tree is finite: • Optimal? • … yes, provided perfect info (evaluation function) and opponent is optimal! • Time Complexity? • Depth of tree: m • Legal moves at each point: b • O(bm) – NB, m 100, b 35 for chess! • Space Complexity? TCSS435A Isabelle Bichindaritz

  17. Properties of Minimax • Complete? • … yes, provided the tree is finite: • Optimal? • … yes, provided perfect info (evaluation function) and opponent is optimal! • Time Complexity? • Depth of tree: m • Legal moves at each point: b • O(bm) – NB, m 100, b 35 for chess! • Space Complexity? O(bm) – why? TCSS435A Isabelle Bichindaritz

  18. Resource Limits TCSS435A Isabelle Bichindaritz

  19. Static Evaluation Function Example: Chess TCSS435A Isabelle Bichindaritz

  20. Do Exact Values Matter? TCSS435A Isabelle Bichindaritz

  21. Cutting Off Search TCSS435A Isabelle Bichindaritz

  22. 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 TCSS435A Isabelle Bichindaritz

  23. Why Prune? TCSS435A Isabelle Bichindaritz

  24. Game Tree Search • Perfect Play (TBD from Perfect Information) • Common framework: two-player (or multi-player), zero-sum • Deterministic or known probability distribution function, totally observable • Minimax algorithm given ability to search for arbitrary ply • Assumptions about • … game? • … opponent? • Specifications and Ramifications • Combinatorics: finite depth (m), breadth (b) of search • Resource limits: need for static evaluation function • Practical Issues • Effects of depth cutoff • Need for pruning TCSS435A Isabelle Bichindaritz

  25. - Pruning • Properties of - pruning • Pruning does not affect final result • Good move ordering improves effectiveness of pruning • With “perfect ordering,” time complexity = O(bm/2) • Depth of tree: m • Legal moves at each point: b • Effective branching factor becomes b1/2 • Can easily reach depth 8 and play good chess • A simple example of the value of reasoning about which computations are relevant ( a form of metareasoning) TCSS435A Isabelle Bichindaritz

  26. - Pruning •  is the value of the best (i.e. highest value) choice we have found so far at any choice point along the path for MAX •  is the value of the best (i.e. lowest value) choice we have found so far at any choice point along the path for MIN. TCSS435A Isabelle Bichindaritz

  27. Alpha-Beta (-) Pruning:Definitions TCSS435A Isabelle Bichindaritz

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

  29. ≥ 3 MAX MIN 3 ≤ 2 ≤ 14 ≤5 2 MAX 2 3 12 8 14 5 2 Alpha-Beta (-) Pruning Example What are ,  values here? TCSS435A Isabelle Bichindaritz

  30. Alpha-Beta (-) Pruning:Modified Minimax Algorithm TCSS435A Isabelle Bichindaritz

  31. Alpha-Beta (-) Pruning Properties • Perfect Play (TBD from Perfect Information) • Common framework: two-player (or multi-player), zero-sum • Deterministic or known probability distribution function, totally observable • Minimax algorithm given ability to search to arbitrary ply • Assumptions about • … game? • … opponent? • Specifications and Ramifications • Combinatorics: finite depth (m), breadth (b) of search • Resource limits: need for static evaluation function • Practical Issues • Effects of depth cutoff • Need for pruning TCSS435A Isabelle Bichindaritz

More Related