Game playing - PowerPoint PPT Presentation

1 / 40
About This Presentation
Title:

Game playing

Description:

Game playing. Type of games. Deterministic. Chance. Imperfect Information. Backgammon ... We can improve on the performance of the minimax algorithm through ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 41
Provided by: sinaSh
Category:

less

Transcript and Presenter's Notes

Title: Game playing


1
Game playing
2
Type of games
Here we consider Games with Perfect Information
3
Example - Tic-Tac-Toe
0
-10
10
0
-10
10
10
-1
10
0
0
0
4
Minimax search
MAX node
MIN node
value computed by minimax
f value
5
Minimax search
6
Minimax algorithm
7
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
Alpha-beta pruning
  • We can improve on the performance of the minimax
    algorithm through alpha-beta pruning.
  • We dont need to compute the value at this node.
  • No matter what it is it cant effect the value of
    the root node.

2
1
2
7
1
?
9
Alpha-beta pruning
10
Alpha-beta pruning
11
Alpha-beta pruning
12
Why is it called a-ß?
  • a is the value of the best (i.e., highest-value)
    choice found so far at any choice point along the
    path for max If v is worse than a, max will avoid
    it ? prune that branch Define ß similarly for min

13
The Alpha-Beta Procedure
  • There are two rules for terminating search
  • Search can be stopped below any MIN node having a
    beta value less than or equal to the alpha value
    of any of its MAX ancestors.
  • Search can be stopped below any MAX node having
    an alpha value greater than or equal to the beta
    value of any of its MIN ancestors.

14
The a-ß algorithm
15
The a-ß algorithm
16
Properties of a-ß
  • 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

17
The Alpha-Beta Procedure
Example
max
min
max
min

























18
The Alpha-Beta Procedure
Example
max
min
max
min
? 4







4

















19
The Alpha-Beta Procedure
Example
max
min
max
min
? 4

5





4

















20
The Alpha-Beta Procedure
Example
max
min
max
? 3
min
? 3

5





4
3
















21
The Alpha-Beta Procedure
Example
max
min
max
? 3
min
? 3
? 1

5





4
3
1















22
The Alpha-Beta Procedure
Example
max
min
? 3
max
? 3
min
? 3
? 1
? 8

5





4
3
1

8













23
The Alpha-Beta Procedure
Example
max
min
? 3
max
? 3
min
? 3
? 1
? 6

5

6



4
3
1

8













24
The Alpha-Beta Procedure
Example
max
min
? 3
max
? 3
? 6
min
? 3
? 1
? 6

5

6



4
3
1

8
7












25
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
max
? 3
? 6
min
? 3
? 1
? 6

5

6


4
3
1

8
7










26
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
max
? 3
? 6
min
? 3
? 1
? 6
? 2

5

6


4
3
1

8
7
2









27
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
max
? 3
? 6
? 3
min
? 3
? 1
? 6
? 2

5

6


4
3
1

8
7
2









28
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
max
? 3
? 6
? 3
min
? 3
? 1
? 6
? 2
? 5

5

6


4
3
1

8
7
2

5







29
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
max
? 3
? 6
? 3
min
? 3
? 1
? 6
? 2
? 4

5

6

4
4
3
1

8
7
2

5







30
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
? 4
max
? 3
? 6
? 4
min
? 3
? 1
? 6
? 2
? 4

5

6

4
4
3
1

8
7
2

5
4






31
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
? 4
max
? 3
? 6
? 4
min
? 3
? 1
? 6
? 2
? 4
? 6

5

6

4
4
3
1

8
7
2

5
4


6



32
The Alpha-Beta Procedure
Example
? 3
max
min
? 3
? 4
max
? 3
? 6
? 4
min
? 3
? 1
? 6
? 2
? 4
? 6

5

6

4
4
3
1

8
7
2

5
4
7

6



33
The Alpha-Beta Procedure
Example
? 4
max
min
? 3
? 4
max
? 3
? 6
? 4
? 6
min
? 3
? 1
? 6
? 2
? 4
? 6

5

6

4
4
3
1

8
7
2

5
4
7

6
7


34
The Alpha-Beta Procedure
Example
? 4
max
Done!
min
? 3
? 4
max
? 3
? 6
? 4
? 6
min
? 3
? 1
? 6
? 2
? 4
? 6

5

6

4
4
3
1

8
7
2

5
4
7

6
7


35
Games that include chance
  • Possible moves (5-10,5-11), (5-11,19-24),(5-10,10-
    16) and (5-11,11-16)

36
Games that include chance
chance nodes
  • Possible moves (5-10,5-11), (5-11,19-24),(5-10,10-
    16) and (5-11,11-16)
  • 1,1, 6,6 chance 1/36, all other chance 1/18

37
Games that include chance
  • 1,1, 6,6 chance 1/36, all other chance 1/18
  • Cannot calculate definite minimax value, only
    expected value

38
Expected minimax value
  • EXPECTED-MINIMAX-VALUE(n)
  • UTILITY(n) If n is a terminal
  • maxs ? successors(n) MINIMAX-VALUE(s) If n
    is a max node
  • mins ? successors(n) MINIMAX-VALUE(s) If n
    is a max node
  • ?s ? successors(n) P(s) . EXPECTEDMINIMAX(s)
    If n is a chance node
  • These equations can be backed-up recursively all
    the way to the root of the game tree.

39
Position evaluation with chance nodes
  • Left, A1 wins
  • Right A2 wins
  • Outcome of evaluation function may change when
    values are scaled differently.
  • Behavior is preserved only by a positive linear
    transformation of EVAL.

40
Alpha-beta pruning in games with chance
  • We can improve on the performance of the minimax
    algorithm for games with chance through
    alpha-beta pruning.
  • We dont need to compute the value at these nodes.

? 1
? 2.5
? 0.5
Suppose -5 ? e(n) ? 5
  • 3 0.5 (- 1) 0.5 1.0
Write a Comment
User Comments (0)
About PowerShow.com