I should have written about assignment 2 sometime ago, but having a million of other things going on, I didn't even manage to finish it on time. I was stuck on minimax since 6pm on the due date(due 10pm), and I started debugging with my broken minimax till 10pm. Considering even though successfully fixed minimax would probably not give me 5 more marks, I didn't further my struggle after submitting my unfinished assignment 2 to mark us, and then totally forgot about it.
It was not until I saw Danny's code of Minimax on lecture today that I realized I didn't actually implement minimax correctly. Maybe it was due to my lack of understanding of the handout, maybe it's my laziness to seek for help from office hours or TA, maybe it was my own stupidity...but anyways, I was supposed to do minimax in such a way: find out all possible game over states and their scores, for all possible next moves from the original game state, transforming these scores in opponent's point of view and the move with the lowest score is my best move. This would make sure that if there is a move that guarantees a win, we will definitely choose it. Then I decided to redo my minimax.
What troubled me the most is that minimax only process score-move data bundle, and it would only return such a bundle as well, but our suggest_move should only return a Move object, I was stuck on that part for quite a while. The solution turned out to be very simple: use a helper function. We can let the helper function do all the work, and pass the returned bundle to suggest_move, which will extract the desired piece of information from the bundle.
Minimax greatly improve my understanding on recursion as well as many techniques and little hacks of recursion. Recursion is really a power tool, and it marks the milestone of introduction to Computer Science, instead of Programming!