Thursday, 12 March 2015

Trials and tribulations - Assignment 2

Last week we finished assignment two, so this week I am going to write about my experience with working on it.

Assignment 2 was split into basically two problems, the game Tippy, and the strategy Minimax. Tippy was not exceedingly difficult. I found it mainly to be time consuming. I found that a little planning before starting allowed me to easily complete this part of the assignment. My main technical challenge with Tippy was figuring out the algorithm and writing code for determining who the winner was. I do not know why I found it difficult, even with drawing diagrams and visually solving it multiple times I couldn’t implement it. After a couple attempts I manage to successfully implement it.

The main technical challenge was implementing Minimax. I found the description given in class and found in the assignment handout to not be sufficient, so I had to do some research to fully understand how minimax works. I found this video,


to be extremely helpful. After watching this it took a little more reading, some discussion with some classmates, and some more views of the video until I fully understood how the algorithm was supposed to work. So now that I know what I’m trying to implement it was time to go into the planning stage. I drew diagrams, wrote some test code, and discussed the problem with a friend. After doing this I felt ready to start coding.
I wrote code which I thought it should in theory work, when I started to run some tests on it, not only did it return the wrong move, it went way too fast. Using some print statements I found that it was not traversing the tree correctly. After fixing this problem I ran it again, now it was running for the correct length of time, however it was still returning the wrong value. At least it was what I thought to be the wrong value. In tippy on a 3-by-3 board the middle position (1,1) in the strongest move. After a lot of time, testing and hair pulling I finally realized that my original algorithm needed some slight tweaking in order for it to work. Finally! I had it working. The elation I felt when all my test cases passed was such a relief!


No comments:

Post a Comment