Game Trees - PowerPoint PPT Presentation

About This Presentation
Title:

Game Trees

Description:

... evaluator to non-terminal nodes ... With Alpha-Beta Pruning. Conclusions. A ... Alpha-Beta Pruning. Transposition Tables. References. Dewdney. The New ... – PowerPoint PPT presentation

Number of Views:491
Avg rating:3.0/5.0
Slides: 28
Provided by: ryandw
Learn more at: http://www.cs.ucf.edu
Category:
Tags: game | nonbeta | trees

less

Transcript and Presenter's Notes

Title: Game Trees


1
Game Trees
  • Ryan Wilson

Chapter 6
2
Trees A Review
  • Trees are a collection of nodes
  • A Tree has a root node and zero or more sub-trees

3
Root Node
A
E
B
G
C
D
F
H
I
An Example Tree
4
CommonTraversalAlgorithm
  • Function TraverseTree( node )
  • visit( node )
  • for each child of node
  • TraverseTree( child )
  • end for
  • End Function
  • TraverseTree( root )

5
Computer Games
  • Problem How do we make an intelligent opponent
    for a human player to compete against?
  • One Possibility
  • Game Trees

6
Game Trees
  • Treat each state of the game as a node in a tree
  • Search the tree to find the best move

7
X
X
X
X
O
O
O
X
X
O
O
X
X
8
Game Trees
  • 3 Components to Implementing a Game Tree
  • Tree Generator
  • Position Evaluator
  • Minimax Method

9
X
Position Evaluator
X
X
O
O
X

O
X
O
O
X
X
0
X
X
X
O
X

O
O
X
X
X
1 Computer Wins 0 Draw -1 Human Wins
X
O
O
O
O
O
1
-1
10
REMEMBER! Higher Score is better for the computer!
40
MAX Computers Turn
40
20
MIN Humans Turn
40
30
60
20
11
Minimax - Computer
  • Function FindComputerMove(GameStateNode)
  • var bestValue
  • if( terminal )
  • return evaluate(GameStateNode)
  • for each child of GameStateNode
  • value FindHumanMove(child)
  • if( value gt bestValue )
  • bestValue value
  • end for
  • End function

12
Minimax - Human
  • Function FindHumanMove(GameStateNode)
  • var bestValue
  • if( terminal )
  • return evaluate(GameStateNode)
  • for each child of GameStateNode
  • value FindHumanMove(child)
  • if( value lt bestValue )
  • bestValue value
  • end for
  • End function

13
Demonstration
  • Tic-Tac-Toe!

14
Conclusions
  • In Tic-Tac-Toe, theres only about 27 legal moves
    for the computer to consider
  • Thats about 30,000 moves
  • But its still kind of slow
  • Almost 45 seconds to make the first move!
  • Experts estimate 10100 legal moves in Chess!
  • Thats approx. 2333 legal positions!

15
What can we do?
  • Apply the position evaluator to non-terminal
    nodes
  • Limit the depth of your search through the tree
  • Have to estimate the value of a position
  • Alpha-Beta Pruning
  • Trim un-needed portions of the tree
  • Transposition Tables

16
Alpha-Beta Pruning
  • Dont need to look at all subtrees of a given
    node if you can already know which one is best

17
Alpha-Pruning
REMEMBER! Higher Score is better for the computer!
gt40
MAX Computers Turn
40
lt20
MIN Humans Turn
40
30
60
20
18
Beta-Pruning
REMEMBER! Higher Score is better for the computer!
lt100
MIN Humans Turn
100
gt120
MAX Computers Turn
100
40
120
30
19
Demonstration
  • Tic-Tac-Toe!
  • With Alpha-Beta Pruning

20
Conclusions
  • A definite improvement!
  • First move only takes about 4 seconds (about 2000
    moves)

21
Transposition Tables
  • In many games, there are multiple ways to arrive
    at the same board position

22
X
X
O
X
O
X
X
X
O
X
O
X
23
Transposition Tables
  • Once weve calculated the value of a given
    position, we save it in a table so its easy to
    look up.
  • For each position in the tree, look that position
    up in the table, if it exists, return the value
    stored in the table.

24
Demonstration
  • Tic-Tac-Toe!
  • With Alpha-Beta Pruning
  • With Transposition Tables

25
Conclusions
  • Another improvement!
  • First move only takes about 3 seconds (918 nodes)
  • Almost ½ as many nodes!

26
Game Trees
  • How-To of Game Trees
  • Alpha-Beta Pruning
  • Transposition Tables

27
References
  • DewdneyThe New Turing Omnibus
  • WeissAlgorithms, Data Structures, and Problem
    Solving with C
  • WeissData Structures Algorithm Analysis in C
Write a Comment
User Comments (0)
About PowerShow.com