Game playing
Download
1 / 27

Game Playing - PowerPoint PPT Presentation


  • 94 Views
  • Uploaded on

Game Playing. Introduction to Artificial Intelligence CS440/ECE448 Lecture 7 FIRST HOMEWORK DUE TODAY. Last lecture. Constraint satisfaction problems Line-drawing interpretation This lecture Games Minimax  pruning Reading Chapter 6. Line Drawing Interpretation.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Game Playing' - heath


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Game playing

Game Playing

Introduction to Artificial Intelligence

CS440/ECE448

Lecture 7

FIRST HOMEWORK

DUE TODAY


Last lecture
Last lecture

  • Constraint satisfaction problems

    • Line-drawing interpretation

      This lecture

      Games

    • Minimax

    •  pruning

      Reading

  • Chapter 6


Line drawing interpretation
Line Drawing Interpretation

  • Goal: Given a line drawing of a 3-D

    object, label edges as being

    Convex: +

    Concave: -

    Occluding:

+

-


Constraints junction labels
Constraints (Junction Labels)

Complete junction catalog for line drawings of trihedral-vertex polyhedra


Nonsense objects
Nonsense objects

  • A consistent labeling is a necessary condition for a line drawing to correspond to a physically realizable object (e.g. a polyhedron with trihedral vertices)


Types of games
Types of Games

Chance

Deterministic

Perfect

Information

Imperfect

Information


Games vs search problems
Games vs. search problems

  • “Unpredictable” opponent

     solution is a contingency plan.

  • Time limits  unlikely to find goal, must approximate.

  • Plan of attack:

    • algorithm for perfect play [Von Neumann, 1944];

    • finite horizon, approximate evaluation [Zuse, 1945; Shannon, 1950; Samuel, 1952-57];

    • pruning to reduce costs [McCarthy, 1956].


Deterministic two person games
Deterministic Two-person Games

  • Two players move in turn.

  • Each Player knows what the other has done and can do.

  • Either one of the players wins (and the other loses) or there is a draw.


Games as search grundy s game nilsson chapter 3
Games as Search: Grundy’s Game [Nilsson, Chapter 3]

  • Initially a stack of pennies stands between two players.

  • Each player divides one of the current stacks into two unequal stacks.

  • The game ends when every stack contains one or two pennies.

  • The first player who cannot play loses.

  • Min starts. Can we devise a winning strategy for Max?

MAX

MIN


Grundy s game states

6, 1

5, 2

4, 3

Max’s turn

Min’s turn

3, 2, 2

5, 1, 1

4, 2, 1

3, 3, 1

4, 1, 1, 1

3, 2, 1, 1

2, 2, 2, 1

Max’s turn

MAX Loses

3, 1, 1, 1, 1

2, 2, 1, 1, 1

Min’s turn

Min Loses

2, 1, 1, 1, 1, 1

Max’s turn

MAX Loses

Grundy’s Game: States

Min’s turn

7


When is there a winning strategy for max
When is there a winning strategy for Max?

  • When it is MIN’s turn to play, a win must be obtainable for MAX from all the results of the move.

  • When it is MAX’s turn, a win must be obtainable from at least one of the results of the move.


Minimax
Minimax

  • Initial state: Board position and whose turn it is.

  • Operators: Legal moves that the player can make.

  • Terminal test: A test of the state to determine if game is over; set of states satisfying terminal test are terminal states.

  • Utility function:numeric value for outcome of game (leaf nodes).

    • E.g. +1 win, -1 loss, 0 draw.

    • E.g. # of points scored if tallying points as in backgammon.

  • Assumption: Opponent will always chose operator (move) to maximize own utility.


Minimax1
Minimax

  • Perfect play for deterministic, perfect-information games.

  • Max’s strategy: choose action with highest minimax value

    ) best achievable payoff against best play by min.

  • Consider a 2-ply (two step) game:

    Max want’s largest outcome --- Min want’s smallest.


Properties of minimax
Properties of Minimax

Yes, if tree is finite.

Yes, against an optimal opponent. Otherwise??

O(bm).

O(bm).

  • Complete:

  • Optimal:

  • Time complexity:

  • Space complexity:

Note: For chess, b  35, m  100 for a “reasonable game.”

  • Solution is completely infeasible

    Actually only 1040 board positions, not 35100


Resource limits
Resource limits

Suppose we have 100 seconds, explore 104 nodes/second

 106 nodes per move.

Standard approach:

  • cutoff test

    e.g., depth limit,

  • evaluation function = estimated desirability of position

    (an approximation to the utility used in minimax).


Cutting off search
Cutting off search

  • Replace MinimaxValue with MinimaxCutoff .

  • MinimaxCutoff is identical to MinimaxValue except

    1. Terminal? is replaced by Cutoff?

    2. Utility is replaced by Eval.

    Does it work in practice?

    bm= 106, b=35  m=4

    4-ply lookahead is a hopeless chess player!

    4-ply human novice

    8-ply typical PC, human master

    12-ply Deep Blue, Kasparov


Evaluation function
Evaluation Function

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 black queens)

w2 = 5 with

f2(s) = (number of white rooks) - (number of black rooks)


Digression exact values don t matter
Digression: Exact Values Don't Matter

MAX

MIN

  • Behavior is preserved under any monotonic transformation of Eval.

  • Only the order matters:

    payoff in deterministic games acts as an ordinal utility function.


Horizon effect
Horizon effect

Bad news may be hidden beyond the cutoff depth.

Black to move..


Another idea
Another idea

  •  Pruning

  • Essential idea is to stop searching down a branch of tree when you can determine that it is a dead end.


Pruning example

=3

=2

 2

 14

 5

X

X

14

2

5

2

 Pruning Example

 3

MAX

=3

MIN

12

8

3


How is the search tree pruned
How is the search tree pruned?

  •  is the best value (to MAX) found so far.

  • If V, then the subtree containing V will have utility no greater than V.

     Prune that branch

  •  can be defined similarly from MIN’s perspective.


Properties of
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;

  • 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).


Deterministic games in practice
Deterministic games in practice

Checkers: In 1994 Chinookended 40-year-reign of human world champion Marion Tinsley. Used an endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 443,748,401,247 positions.

Chess:Deep Blue defeated human world champion Gary Kasparov in a six-game match in 1997. Deep Blue searches 200 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply.

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

Go: Human champions refuse to compete against computers, who are too bad. In Go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves.


ad