Saturday 7 March 2015

CSC148 Lecture Week 8

   Assignment 2 was due this week, and I am very glad that I was able to finish it. When I first looked over the assignment, I though that it would be pretty easy so I didn't start anything until the Saturday before it was due. Coding TippyGameState was relatively easy. winner() and rough_outcome() were pretty long since my group just did that by brute force. On Piazza, Danny answered a question about winner() and said that there was no really elegant way for it to be implemented, so just decided to go through the whole board and check for all four possible tippies.
   What really cause me trouble was minimax. My whole group had a lot of trouble with it and we came up with some really complicated methods that did not work. After taking a step back and rereading the assignment page, I realized that we were probably over-complicating it. The assignment handout pretty much gave us the exact algorithm for the minimax strategy:
I then worked on translating this algorithm to code. I had trouble pairing the moves with their scores, but that was fixed with the help of a helper function (they're so helpful aren't they?). 
   The final problem was that minimax worked with subtract square and not tippy. It took a lot of tracing through the Wing debugger, but we eventually realized that apply_move() in TippyGameState was changing the original game state. This was fixed with the use of deepcopy() (Thanks again to Piazza).

2 comments:

  1. We had the same issue as you when we encountered the minimax. We has been told that follow the algorithm while doing minimax that would be helpful during office hour, which was a good approach. And I also agree with you that helper function is useful as we applied helper function to almost every function in A3.

    ReplyDelete
    Replies
    1. It's nice to see that other people also struggled with minimax. It makes me fell less alone.

      Helper functions are super useful. I also used them for almost every function in A3.

      Thanks for the comment.

      Delete