Sunday, March 15, 2015

Week 8: Assignment 2

Assignment 2 was ... confusing. Especially for the strategy minimax. It took me several hours to argue with my partner about how it really works, with pages of doodles and nonsense, and ended up even more confused and frustrated than before. We could not go asking for TA's help, because of their prolonged strike, which has no sign of ending at this point when I am writing this slog. Luckily, after hours of waiting in the line, I finally got the chance to discuss with Prof. Heap about my confusion, and he easily solved the problem in less than a minute.

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