So, I have been playing around with min-max trees to create a simple computer player in a two-person board game. I understand the basics of the algorithm, but there is a case that eludes my turkey infused brain ... what happens when MIN can win in two steps?

For example, assume a connect4/tic-tac-toe type game where only one of the two players can own a square. How do I get MAX to occupy a square solely to prevent MIN from getting the square?

Let's try a simplified example (shown in nifty ASCII art) where the options are Left and Right. Assume the tree is too big to traverse to the terminal states, so intermediate values are calculated based on a heuristics function (marked with * below). -INF is a terminal state where MIN wins.

MAX (a)

/ \

A B

/ \

MIN (b) MIN (c)

/ \ / \

A B A B

/ | | \

-INF *5 *22 *20

MIN is going to pick action A in the state (b) for a score of -INF

MIN is going to pick action B in the state (c) for a score of +20

MAX is going to pick action B in the state (a) for a score of +20

The problem - of course - is that if MAX picks B then MIN will perform action A (since that square is still available) and thus MIN will win. I need to get MAX to realize the value of picking action A in the state (a) to prevent MIN from getting -INF in the next move.

I would put a bunch of tests into the code to check if MIN can win, but it seems to me that the algorithm should take care of this. I think I am missing a piece in the determination of the value with regards to MAX which is causing this.