Thursday 12 March 2015

Week 8

This week we learned about linked lists, which are a special type of list made up of nodes that reference other nodes.  In this way, each of the nodes are linked together.  I originally found the concept confusing, but after drawing pictures and practising some of the lab exercises I had a better understanding of the order in which to perform the operations in my code so as not to lose any essential data from the list.

Assignment 2 was also due this week.  My group and I had only three functions left to complete: minimax, winner, and rough_outcome.  Minimax worked with subtract square, but we had yet to test it with a game of tippy.  I realized that our original solution for checking for a tippy was inefficient and would take too long to write and debug. Therefore, I suggested that we only check for horizontal tippys and then rotate the board four times and return whether a tippy is found.  Using this code, we only had to deal with the two cases of horizontal tippys rather than the four cases we had to account for prior to my suggestion. We worked out a few errors in the code, such as where it would not detect a tippy in a large compact group of X's or O's, or where it would only detect the first tippy in a row and not all the tippy's. For example, before debugging, our code would incorrectly return on the following boards:

X|X|X|X|
X|X|X|X|
X|X|X|X|
O|O|O|O|

and

X|X|O|O|X|X|O|
O|X|X|O|O|X|X|
X|O|X|O|X|O|X|
O|X|O|X|O|X|O|
X|O|X|O|X|O|X|
O|X|O|X|O|X|O|
X|O|X|O|X|O|X|

After completing winner, we found out, much to our dismay, that minimax did not work correctly for a game of tippy.  Luckily, we had lots of time to find the errors and fix them, and we did so fairly quickly.  We then implemented rough_outcome without any major errors, although we were not concerned about that function as it wasn't used in the assignment.  After fixing some more minor errors, we ran our code multiple times with a game of tippy and it correctly picked the middle square on a 3X3 grid every time. 

1 comment:

  1. I know exactly what you mean! I also had a lot of little errors and bugs that did not work for Tippy, but worked for subtract square! Man it was a good chunk of time for me, and as I can see you, to debug minimax and make sure it works. Feels good to know I am not the only one!

    ReplyDelete