Edit: I've been mixing up "pure" minimax, with minimax + heuristic. I've edited my answer to resolve this.
Maybe it would help to define minmax. From An article by a UC Berkeley student:
minimax(player,board)
if(game over in current board position)
return winner
children = all legal moves for player from this board
if(max's turn)
return maximal score of calling minimax on all the children
else (min's turn)
return minimal score of calling minimax on all the children
With minimax, you are trying to minimize your losses, not maximize your gains. So, "your" turn is min's
turn. With this definition, if you could ever lose by selecting a square, then it will be marked -1
. If you could ever tie, but will never lose, it will be marked 0
. Only if it is a guaranteed win will it be marked 1
.
Should I check each table for a block
If you are defining your score and algorithm correctly (matching the right players to the right logic), you need not "check for a block". Any game sub-tree where the player didn't block should implicitly be evaluated -1
, because at some point (probably very quickly) it will evaluate to a loss, and that loss will bubble up.
The real problem with this algorithm (and where you may be getting results that you aren't expecting) is when all sub-trees result in possible losses. At that point, you will need to use a heuristic to get any better information on which move you should take. You will need something better than simply {-1, 0, 1}
, because some moves could allow you to win, but you'd block them out because you could also lose.