Game+Search1

Embed Size (px)

Citation preview

  • 8/2/2019 Game+Search1

    1/25

    Adversarial Search

  • 8/2/2019 Game+Search1

    2/25

    Outline

    Adversarial Search

    Game Theory

    Formal Definition of Game Optimal decisions

    - pruning

    Imperfect, real-time decisions

  • 8/2/2019 Game+Search1

    3/25

    ADVERSARIAL SEARCH

    Competitive environments,in which

    the agents goals are in conflict,give riseto adversarial search problems often

    known as games.

  • 8/2/2019 Game+Search1

    4/25

    GamesMathematical Game Theory,a branch ofeconomics,views any multiagent environment as a

    game

    Agents are cooperative or competitive.

    AI games are,two-player, turn-taking and fullyobservable environments

    utility values at the end of the game are alwaysequal and opposite. For example,if one player winsthe game of chess(+1),the other player necessarilyloses(-1). It is this opposition between the agents

    utility functions that makes the situation adversarial.

  • 8/2/2019 Game+Search1

    5/25

    Formal Definition of GameConsider the games (Tic-tac-toe) with two players,whom we will callMAX and MIN. MAX moves first,and then they take turns moving until

    the game is over. At the end of the game, points are awarded to thewinning player and penalties are given to the loser. A game can beformally defined as a search problem with the following components :

    o The initial state,which includes the board position and

    identifies the player to move.o A successor function,which returns a list of (move,state)pairs,each indicating a legal move and the resulting state.o A terminal test,which describes when the game is over.States where the game has ended are called terminal

    states.oA utility function (also called an objective function orpayoff function),which give a numeric value for the terminalstates. In chess,the outcome is a win,loss,or draw,with

    values +1,-1,or 0.

  • 8/2/2019 Game+Search1

    6/25

    Games vs. search problems

    "Unpredictable" opponent specifying amove for every possible opponent reply

    Time limits unlikely to find goal, mustapproximate

  • 8/2/2019 Game+Search1

    7/25

    Game tree (2-player,deterministic, turns)

  • 8/2/2019 Game+Search1

    8/25

    Minimax

    Perfect play for deterministic games

    Idea: choose move to position with highest minimax

    value= best achievable payoff against best play

    E.g., 2-ply game:

  • 8/2/2019 Game+Search1

    9/25

    function minimax(node,depth)if depth

  • 8/2/2019 Game+Search1

    10/25

    Minimax algorithm

  • 8/2/2019 Game+Search1

    11/25

    Properties of minimax

    Complete? Yes (if tree is finite)

    Optimal? Yes (against an optimal opponent)

    Time complexity? O(bm)

    Space complexity? O(bm) (depth-first exploration)

    For chess, b 35, m 100 for "reasonable" games exact solution completely infeasible

  • 8/2/2019 Game+Search1

    12/25

    - pruning example

  • 8/2/2019 Game+Search1

    13/25

    - pruning example

  • 8/2/2019 Game+Search1

    14/25

    - pruning example

  • 8/2/2019 Game+Search1

    15/25

    - pruning example

  • 8/2/2019 Game+Search1

    16/25

    - pruning example

  • 8/2/2019 Game+Search1

    17/25

    Properties of -

    Pruning does not affect final result

    Good move ordering improves effectiveness of pruning

    With "perfect ordering," time complexity = O(bm/2)doubles depth of search

    A simple example of the value of reasoning about whichcomputations are relevant (a form of metareasoning)

  • 8/2/2019 Game+Search1

    18/25

    Why is it called -?

    is the value of thebest (i.e., highest-value) choice foundso far at any choicepoint along the pathfor max

    If vis worse than ,maxwill avoid it

    prune that branch

  • 8/2/2019 Game+Search1

    19/25

    The - algorithm

  • 8/2/2019 Game+Search1

    20/25

    The - algorithm

  • 8/2/2019 Game+Search1

    21/25

    Resource limits

    Suppose we have 100 secs, explore 104nodes/sec106nodes per move

    Standard approach:

    cutoff test:

    e.g., depth limit (perhaps add quiescence search)

    evaluation function

  • 8/2/2019 Game+Search1

    22/25

    Evaluation functions

    For chess, typically linear weighted sum of features

    Eval(s) = w1 f1(s) + w2 f2(s) + + wn fn(s)

    e.g., w1 = 9 with

    f1(s) = (number of white queens) (number of blackqueens), etc.

  • 8/2/2019 Game+Search1

    23/25

    Cutting off search

    MinimaxCutoffis identical to MinimaxValueexcept1. Terminal?is replaced by Cutoff?2. Utilityis replaced by Eval3.

    Does it work in practice?

    bm = 106, b=35 m=4

    4-ply lookahead is a hopeless chess player!

    4- l human novice

  • 8/2/2019 Game+Search1

    24/25

    Deterministic games in practice

    Checkers: Chinook ended 40-year-reign of human world championMarion Tinsley in 1994. Used a precomputed endgame databasedefining perfect play for all positions involving 8 or fewer pieces onthe board, a total of 444 billion positions.

    Chess: Deep Blue defeated human world champion Garry Kasparovin a six-game match in 1997. Deep Blue searches 200 millionpositions per second, uses very sophisticated evaluation, andundisclosed methods for extending some lines of search up to 40ply.

    Othello: human champions refuse to compete against computers,who are too good.

    Go: human champions refuse to compete against computers, whoare too bad. In go, b > 300, so most programs use patternknowledge bases to suggest plausible moves.

  • 8/2/2019 Game+Search1

    25/25

    Summary

    Games are fun to work on!

    They illustrate several important pointsabout AI

    perfection is unattainable mustapproximate

    good idea to think about what to think

    about