Last time: Simulated annealing algorithm Idea: Escape local extrema - - PowerPoint PPT Presentation

last time simulated annealing algorithm
SMART_READER_LITE
LIVE PREVIEW

Last time: Simulated annealing algorithm Idea: Escape local extrema - - PowerPoint PPT Presentation

Last time: Simulated annealing algorithm Idea: Escape local extrema by allowing bad moves, but gradually decrease bad moves, but gradually decrease their size and frequency. Note: goal here is to - maximize E. 1 Last time:


slide-1
SLIDE 1

Last time: Simulated annealing algorithm

Idea: Escape local extrema by allowing

“bad moves,” but gradually decrease bad moves, but gradually decrease their size and frequency.

Note: goal here is to maximize E.

  • 1
slide-2
SLIDE 2

Last time: Simulated annealing algorithm

Idea: Escape local extrema by allowing

“bad moves,” but gradually decrease bad moves, but gradually decrease their size and frequency.

Algorithm when goal is to minimize E. <

  • 2
slide-3
SLIDE 3

This time: Outline

Game playing

The minimax

l ith algorithm

Resource limitations alpha-beta pruning 3 alpha beta pruning Elements of chance

slide-4
SLIDE 4

What kind of games?

Abstraction: To describe a game we

must capture every relevant aspect of the game. Such as:

Chess Tic-tac-toe …

Accessible environments: Such

games are characterized by perfect

4

games are characterized by perfect information

slide-5
SLIDE 5

What kind of games?

Search: game-playing then consists of

a search through possible game positions

Unpredictable opponent: introduces

uncertainty thus game-playing must uncertainty thus game playing must

deal with contingency problems

5

slide-6
SLIDE 6

Searching for the next move

Complexity: many games have a huge

search space search space

Chess:

b = 35, m= 100 ⇒ nodes = 35 100 if each node takes about 1 ns to explore p then each move will take about 10 50

millennia to calculate.

6

slide-7
SLIDE 7

Searching for the next move

Resource (e.g., time, memory) limit:

  • ptimal solution not feasible/possible,
  • ptimal solution not feasible/possible,

thus must approximate

1 Pruning: makes the search more efficient

  • 1. Pruning: makes the search more efficient

by discarding portions of the search tree that cannot improve quality result.

  • 2. Evaluation functions: heuristics to

evaluate utility of a state without exhaustive

7

search.

slide-8
SLIDE 8

Two-player games

A game formulated as a search problem:

Initial state: ?

Operators: ?

Operators: ? Terminal state: ?

Utilit f ti ?

Utility function: ?

8

slide-9
SLIDE 9

Game vs. search problem

9

slide-10
SLIDE 10

Example: Tic-Tac-Toe

Question:

  • 1. b (branching factor) = ?

2 m (max depth) = ?

  • 2. m (max depth) = ?

10

slide-11
SLIDE 11

Type of games

11

slide-12
SLIDE 12

The minimax algorithm

  • Perfect play for deterministic

environments with perfect information

  • Basic idea: choose move with highest

minimax value = best achievable payoff against best play p y

12

slide-13
SLIDE 13

The minimax algorithm

  • Algorithm:

1.

Generate game tree completely

2.

Determine utility of each terminal state

3.

Propagate the utility values upward in the three by applying MIN and MAX operators on the nodes in applying MIN and MAX operators on the nodes in the current level

4.

At the root node use minimax decision to select the move with the max (of the mins) utility value

  • Steps 2 and 3 in the algorithm assume that

13

  • Steps 2 and 3 in the algorithm assume that

the opponent will play perfectly.

slide-14
SLIDE 14

Generate Game Tree

14

slide-15
SLIDE 15

Generate Game Tree

x

1 ply 1 move

  • x

x

  • x
  • x o

15

slide-16
SLIDE 16

A subtree

x x o

win lose

x x

  • x

lose draw

x x

  • x

x x

  • x

x x x

  • x

x x o

  • x

x x x

  • x

x x x

  • x

x x x

  • x

x x

  • x

x x

  • x

x x

  • x
  • x
  • x
  • x
  • x
  • x

x

  • x

x x x

  • x

x x x

  • x
  • x

x

  • x
  • x

x x

  • x

16

  • x

x

  • x

x x x

  • x

x

  • x

x

  • x

x

  • x o
  • x

x

slide-17
SLIDE 17

What is a good move?

x x o

win lose

x x

  • x

lose draw

x x

  • x

x x

  • x

x x x

  • x

x x o

  • x

x x x

  • x

x x x

  • x

x x x

  • x

x x

  • x

x x

  • x

x x

  • x
  • x
  • x
  • x
  • x
  • x

x

  • x

x x x

  • x
  • x

x

  • x
  • x

x x

  • x

17

  • x

x

  • x

x x

  • x

x

  • x

x

  • x o
  • x

x

slide-18
SLIDE 18

Minimax

3 8 12 4 6 14 2 5 2

Mi i i t’ h

  • Minimize opponent’s chance
  • Maximize your chance

18

slide-19
SLIDE 19

minimax = maximum of the minimum

1st ply 2nd ply 2 ply

19

slide-20
SLIDE 20

JavaApplet

  • Minimx java applet

dd dd

20

slide-21
SLIDE 21

Minimax: Recursive implementation p

21

Complete: ? Optimal: ? Time complexity: ? Space complexity: ?

slide-22
SLIDE 22
  • 1. Move evaluation without

complete search

Complete search is too complex and impractical Evaluation function: evaluates value of state

using heuristics and cuts off search

New MI NI MAX:

CUTOFF-TEST: cutoff test to replace the termination

condition (e.g., deadline, depth-limit, etc.) l f l l f

EVAL: evaluation function to replace utility function

(e.g., number of chess pieces taken)

22

slide-23
SLIDE 23

Do We Have To Do All That Work?

MAX MIN 3 8 12

23

slide-24
SLIDE 24

Evaluation functions

Weighted linear evaluation function:

to combine n heuristics: f = w1f1 + w2f2 +

+ wnfn

to combine n heuristics: f

w1f1 + w2f2 + … + wnfn E.g,

w’s could be the values of pieces (1 for prawn, 3 for bishop) 24

p ( p , p)

f’s could be the number of type of pieces on the board

slide-25
SLIDE 25

Note: exact values do not matter

Ordering is preserved

25

slide-26
SLIDE 26

Minimax with cutoff: viable algorithm?

Assume we have 100 seconds, evaluate 104 nodes/s; can nodes/s; can evaluate 106 nodes/move

26