The main point of minimax is to keep score for both players to determine how good or how bad their positions are. As described in the guideline file of assignment 2, the score system is:
If the game is over, A's score is:
1 if A wins;
-1 if A loses;
0 if it's a tie.
B's score is -1 times A's score, since this is a zero-sum game: what's good for A is bad for B.
Suppose the game is not over, and the current player is A. Then A's score is:
1, if at least one A's legal moves leads to a new position where A's score is 1 (or B's score is -1, since B is the current player in the new position);
-1, if every legal move for A leads to a position where A's score is -1 (or B's score is 1, since B is the current player in the new position);
0, if at least one of A's legal moves leads to a score of 0, but none lead to a score of 1. I could not understand how it works in a situation that both A and B have a legal move that leads to a new position where their score is 1. Wouldn't both of their scores be 1 in the above situation? But clearly someone's score should be -1. My partner tried to convince me that I should only look at one player's score and ignore the other, but I doubted that's the case.
In the end, Prof. Heap helped me to get out of this paradox. He told me that it's about who is the current player in the situation. If A is the current player, than A will choose a move that leads A's score to be 1, and A will never choose a move that leads B's score to be 1. No matter how many moves there are and no matter how many new positions these moves could lead to, the only one matters is the one that is the best for the current player, and that position determines the scores for both players.
After Prof. Heap's simple and effective explanation, the whole paradox was no longer confusing. I was so happy and relieved. It didn't take us much time to work out the code as long as we understood the rationale behind it.

No comments:
Post a Comment