So, I played with minmax trees to create a simple computer player in a dual-player board game. I understand the basics of the algorithm, but there is a case that eludes my intuitive brain infusion ... what happens when MIN can win in two stages?
For example, suppose a game is like connect4 / tic-tac-toe, where only one of the two players can have a square. How to get MAX to occupy a square solely to prevent MIN from getting a square?
Try a simplified example (shown in elegant ASCII text), where the options are Left and Right. Suppose the tree is too large to travel to its final states, so the intermediate values ββare calculated based on the heuristic function (indicated * below). -INF is the state of the terminal in which MIN wins.
MAX (a) / \ AB / \ MIN (b) MIN (c) / \ / \ ABAB / | | \ -INF *5 *22 *20
MIN is about to choose action A in state (b) to evaluate -INF
MIN is about to select action B in state (c) to estimate +20
MAX is about to select action B in state (a) for a score of +20
The problem, of course, is that if MAX chooses B, then MIN will perform action A (since this square is still available), and thus MIN will win. I need to get MAX in order to implement the walking action value A in state (a), to prevent MIN from getting -INF next turn.
I would put a bunch of tests in 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 part in determining the value with respect to the MAX that causes this.
(Edited for clarification)
source share