Rice University - Comp 212 - Intermediate Programming

Fall 2001

Lecture #36 - Game Tree and Min-Max Algorithm


Game Tree

Suppose we have a two-player game in which each player takes turn making his/her move.   We assume that the game will always terminate in a draw, win, or loss.  We can conceptualize the game as a tree consisting of all the possible "game board" configurations with the initial configuration as a root node.  Each node in the game tree corresponds to a possible configuration of the game.  A leaf node corresponds to an end game configuration: a win, loss, or draw.

For the sake of definiteness, assume the players are John and Mary.  We can imagine when John is to make a move, he will move to a game node that is best for him.   What's best for John is based on some numerical value that he associates with each of next possible moves.  How are the value of each of the game node calculated?   Here is one such possible computation.

Min-Max Algorithm

For each of the leaf node, John can assign a value of 1 if he wins, 0 if he ties, and -1 if he loses.  Conceptually, John defines a "pay-off" function P as follows:

P (leaf) =

Now, John assigns a value, V(x), to a game node x, as follows:

V (x) =

The heuristic here is that John would make a move to a node that has the maximum value for him, and Mary would do her best by going for the node that has the minimum value (from John's perspective).  This game configuration computation is called the min-max strategy.  

 

Depth-limited Min-Max Algorithm

In general, it is not possible to get to all leaf nodes of a game.   The best one can do is to examine the game tree up to certain depth.  The min-max strategy with depth limitation can be expressed as follows.

Let P (n) be a pay-off function that a player uses to evaluate a game node n.

For a given player, the value of a node x at a depth d is:

V (x, d) =

 


dxnguyen@rice.edu