So, I have been playing around with minmax 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?
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 for the purpose of preventing MIN from getting the square?
Let's try a simplified example (shown in nifty ASCII art) where the options are Left and Right. Assume he tree is too big to traverse all the way 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 state (b) for a score of -INF
MIN is going to pick action B in state (c) for a score of +20
MAX is going to pick action B in 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 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.
(Edited to clarify)