Introduction to Artificial Intelligence Game Playing

Introduction to Artificial Intelligence Game Playing

Introduction to Artificial Intelligence Game Playing Bernhard Beckert UNIVERSITÄT KOBLENZ-LANDAU Wintersemester 2003/2004 B. Beckert: Einführung in die KI / KI für IM – p.1 Outline Perfect play Resource limits α-β pruning Games of chance Games of imperfect information B. Beckert: Einführung in die KI / KI für IM – p.2 Characteristics of game playing “Unpredictable” opponent: Solution is a strategy specifying a move for every possible opponent reply Time limits: Unlikely to find goal, must approximate Games vs. Search Problems Game playing is a search problem Defined by – Initial state – Successor function – Goal test – Path cost / utility / payoff function B. Beckert: Einführung in die KI / KI für IM – p.3 Games vs. Search Problems Game playing is a search problem Defined by – Initial state – Successor function – Goal test – Path cost / utility / payoff function Characteristics of game playing “Unpredictable” opponent: Solution is a strategy specifying a move for every possible opponent reply Time limits: Unlikely to find goal, must approximate B. Beckert: Einführung in die KI / KI für IM – p.3 Game Playing Plan of attack Computer considers possible lines of play [Babbage, 1846] Algorithm for perfect play [Zermelo, 1912; Von Neumann, 1944] Finite horizon, approximate evaluation [Zuse, 1945; Wiener, 1948; Shannon, 1950] First chess program [Turing, 1951] Machine learning to improve evaluation accuracy [Samuel, 1952–57] Pruning to allow deeper search [McCarthy, 1956] B. Beckert: Einführung in die KI / KI für IM – p.4 Types of Games deterministic chance perfect information chess, checkers, backgammon go, othello monopoly imperfect information bridge, poker, scrabble nuclear war B. Beckert: Einführung in die KI / KI für IM – p.5 Game Tree: 2-Player / Deterministic / Turns MAX (X) X X X MIN (O) X X X X X X X O X O X . MAX (X) O X O X X O X O . MIN (O) X X . X O X X O X X O X . TERMINAL O X O O X X O X X O X O O Utility −1 0 +1 B. Beckert: Einführung in die KI / KI für IM – p.6 Minimax Perfect play for deterministic, perfect-information games Idea Choose move to position with highest minimax value, i.e., best achievable payoff against best play B. Beckert: Einführung in die KI / KI für IM – p.7 Minimax: Example 2-ply game MAX 3 A A A 1 2 3 MIN 3 2 2 A A A A A A A A A 11 12 13 21 22 23 31 32 33 3 12 8 2 4 6 14 5 2 B. Beckert: Einführung in die KI / KI für IM – p.8 Minimax Algorithm function MINIMAX-DECISION(game) returns an operator for each op in OPERATORS[game] do VALUE[op] MINIMAX-VALUE(APPLY(op, game), game) end return the op with the highest VALUE[op] function MINIMAX-VALUE(state, game) returns a utility value if TERMINAL-TEST[game](state) then return UTILITY[game](state) else if MAX is to move in state then return the highest MINIMAX-VALUE of SUCCESSORS(state) else return the lowest MINIMAX-VALUE of SUCCESSORS(state) B. Beckert: Einführung in die KI / KI für IM – p.9 Yes, if tree is finite (chess has specific rules for this) Yes, against an optimal opponent. Otherwise?? O(bm) (depth-first exploration) O(bm) (depth-first exploration) Note Finite strategy can exist even in an infinite tree Properties of Minimax Complete Optimal Time Space B. Beckert: Einführung in die KI / KI für IM – p.10 Yes, against an optimal opponent. Otherwise?? O(bm) (depth-first exploration) O(bm) (depth-first exploration) Note Finite strategy can exist even in an infinite tree Properties of Minimax Complete Yes, if tree is finite (chess has specific rules for this) Optimal Time Space B. Beckert: Einführung in die KI / KI für IM – p.10 O(bm) (depth-first exploration) O(bm) (depth-first exploration) Note Finite strategy can exist even in an infinite tree Properties of Minimax Complete Yes, if tree is finite (chess has specific rules for this) Optimal Yes, against an optimal opponent. Otherwise?? Time Space B. Beckert: Einführung in die KI / KI für IM – p.10 O(bm) (depth-first exploration) Note Finite strategy can exist even in an infinite tree Properties of Minimax Complete Yes, if tree is finite (chess has specific rules for this) Optimal Yes, against an optimal opponent. Otherwise?? Time O(bm) (depth-first exploration) Space B. Beckert: Einführung in die KI / KI für IM – p.10 Note Finite strategy can exist even in an infinite tree Properties of Minimax Complete Yes, if tree is finite (chess has specific rules for this) Optimal Yes, against an optimal opponent. Otherwise?? Time O(bm) (depth-first exploration) Space O(bm) (depth-first exploration) B. Beckert: Einführung in die KI / KI für IM – p.10 Properties of Minimax Complete Yes, if tree is finite (chess has specific rules for this) Optimal Yes, against an optimal opponent. Otherwise?? Time O(bm) (depth-first exploration) Space O(bm) (depth-first exploration) Note Finite strategy can exist even in an infinite tree B. Beckert: Einführung in die KI / KI für IM – p.10 Standard approach Cutoff test e.g., depth limit (perhaps add quiescence search) Evaluation function Estimates desirability of position Resource Limits Complexity of chess b ≈ 35, m ≈ 100 for “reasonable” games Exact solution completely infeasible B. Beckert: Einführung in die KI / KI für IM – p.11 Resource Limits Complexity of chess b ≈ 35, m ≈ 100 for “reasonable” games Exact solution completely infeasible Standard approach Cutoff test e.g., depth limit (perhaps add quiescence search) Evaluation function Estimates desirability of position B. Beckert: Einführung in die KI / KI für IM – p.11 Evaluation Functions Estimate desirability of position White to move Black to move Black winning White slightly better B. Beckert: Einführung in die KI / KI für IM – p.12 Example w1 = 9 f1(s) = (number of white queens) − (number of black queens) Evaluation Functions Typical evaluation function for chess Weighted sum of features EVAL(s) = w1 f1(s) + w2 f2(s) + ···+ wn fn(s) B. Beckert: Einführung in die KI / KI für IM – p.13 Evaluation Functions Typical evaluation function for chess Weighted sum of features EVAL(s) = w1 f1(s) + w2 f2(s) + ···+ wn fn(s) Example w1 = 9 f1(s) = (number of white queens) − (number of black queens) B. Beckert: Einführung in die KI / KI für IM – p.13 Digression: Exact Values Do Not Matter MAX MIN 1 2 1 20 1 2 2 4 1 20 20 400 Behaviour is preserved under any monotonic transformation of EVAL Only the order matters: payoff in deterministic games acts as an ordinal utility function B. Beckert: Einführung in die KI / KI für IM – p.14 Not really, because ::: 4-ply ≈ human novice (hopeless chess player) 8-ply ≈ typical PC, human master 12-ply ≈ Deep Blue, Kasparov Cutting Off Search Does it work in practice? bm = 106; b = 35 ) m = 4 B. Beckert: Einführung in die KI / KI für IM – p.15 Cutting Off Search Does it work in practice? bm = 106; b = 35 ) m = 4 Not really, because ::: 4-ply ≈ human novice (hopeless chess player) 8-ply ≈ typical PC, human master 12-ply ≈ Deep Blue, Kasparov B. Beckert: Einführung in die KI / KI für IM – p.15 α-β Pruning Example MAX 3 MIN 3 3 12 8 B. Beckert: Einführung in die KI / KI für IM – p.16 α-β Pruning Example MAX 3 MIN 3 2 X X 3 12 8 2 B. Beckert: Einführung in die KI / KI für IM – p.16 α-β Pruning Example MAX 3 MIN 3 2 14 X X 3 12 8 2 14 B. Beckert: Einführung in die KI / KI für IM – p.16 α-β Pruning Example MAX 3 MIN 3 2 14 5 X X 3 12 8 2 14 5 B. Beckert: Einführung in die KI / KI für IM – p.16 α-β Pruning Example MAX 3 3 MIN 3 2 14 5 2 X X 3 12 8 2 14 5 2 B. Beckert: Einführung in die KI / KI für IM – p.16 Effectiveness Good move ordering improves effectiveness Time complexity with “perfect ordering”: O(bm=2) Doubles depth of search For chess: Can easily reach depth 8 and play good chess Properties of α-β Effects of pruning Reduces the search space Does not affect final result B. Beckert: Einführung in die KI / KI für IM – p.17 Properties of α-β Effects of pruning Reduces the search space Does not affect final result Effectiveness Good move ordering improves effectiveness Time complexity with “perfect ordering”: O(bm=2) Doubles depth of search For chess: Can easily reach depth 8 and play good chess B. Beckert: Einführung in die KI / KI für IM – p.17 The Idea of α-β α is the best value (to MAX) found so far off the current path MAX If value x of some node below V is known to be less than α, MIN then value of V is known to be at most x, .. i.e., less than α, .. .. therefore MAX will avoid node V MAX Consequence MIN V No need to expand further nodes below V B. Beckert: Einführung in die KI / KI für IM – p.18 The α-β Algorithm function MAX-VALUE(state, game, α, β) returns the minimax value of state inputs: state /* current state in game */ game /* game description */ α /* the best score for MAX along the path to state */ β /* the best score for MIN along the path to state */ if CUTOFF-TEST(state) then return EVAL(state) for each s in SUCCESSORS(state) do α MAX(α, MIN-VALUE(s, game, α, β)) if α ≥ β then return β end return α B.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    65 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us