Thursday, 12 March 2015
Week 9: Impressions of Week 8
Hello everyone! The main topic covered in week 8 was on Linked Lists, but I will talk about my group's unsuccessful attempt to finishing assignment 2...
We felt were close, but unfortunately we couldn't figure out how to properly implement minimax, despite the hint given from Danny on Piazza. Our group understood exactly what needed to be done, but we simply couldn't think of the code to implement it. The method apply_move in TippyGameState took a lot of time to implement, but it really threw us off on how we could implement that within minimax to alternate the moves. Overall, a lot of time was used on TippyGameState, which left us very little time for minimax. We started the assignment a bit too late and that ultimately cost us with the improper and rushed completion of the assignment.
My group has learned our lesson from this and we must immediately start an assignment as soon as we can instead of being overwhelmed with it near the end. We will definitely keep this in mind with coding in the future - whether it's for a university assignment or if it's for a project from potential jobs down the line. It's great that I personally learned this early on and I will definitely make future accommodations to finish well before deadlines in case of bugs appearing in the code. Our group was gutted by our performance on this assignment, but we can't be too down on ourselves as there is also another assignment where we can redeem ourselves! The key is to remain optimistic and learn from your mistakes! I hope you (Reader) keep that in mind!
The main lesson I learned from this? Manage your time folks! There is nothing more important in university than time management!
Going to a less disheartening topic, before going to Monday's lecture, I read the recommended Think Like a Computer Scientist topic on Linked Lists.
I feel the name of the topic for them most part explains the concept - essentially linked lists has a node from a tree that refers to the next node in line as some form of a 'link' between the two. This pattern carries on until the next node is suddenly of 'NoneType', which means that we are finally at the end of the 'list'. Recursion is not necessarily required in Linked Lists, but it could still be used..
Here is a diagram from Think Like a Computer Scientist that illustrates this:
Essentially, 'cargo' refers to the current value of the node and 'next' links to the next node. Since there is no node after node3, 'next' is referring to None, which means our list has reached an end.
I immediately thought: why is this needed? When am I ever going to need this? So I went into Monday's class, specifically keeping these questions in mind.
Danny entrusted us with the idea of using diagrams to help with writing the code for Linked Lists. He gave us two options to draw the diagrams - 1) Make a diagram of a big list with a sublist within that big list, a sublist within the first sublist, and so on. 2) Make a diagram similar to the diagram from Think Like a Computer Scientist with each node referring to a next value.
Option 1 is useful on its own to get an idea of how the code would look like, but option 2 was much simpler to create, organize and potentially change and I much prefer this method. This is also the option Danny suggested to use.
Designing the class for LinkedLists seems fairly straightforward to the definition I provided:
Please do note that the default parameter of nxt=None, which means that if LLNode is implemented with only one parameter, it means that it's the only item in that successive list, meaning it's just a node.
A more suitable approach to give a bit more information about the linked list is using the LLNode as a wrapper:
The self.front instance variable refers to the front of the LinkedList, the self.back instance variable refers to the back of the Linked and self.size refers to the size of the list itself. This option naturally gives us more information about the specified LinkedList, which could make the code more efficient than using the previous LLNode class.
Here is a method, __contains__ we were asked to implement in lecture (This was a method for Class LinkedList.
The basic idea is to go from the front of LinkedList, through each node, until we get to the back of the LinkedList.
Danny told us to keep this procedure in mind when walking through lists. I felt his diagram really helped here:
You start off by referring the current node to the front of the LinkedList and you enter the while loop based on a specific condition. At the end of that while loop, you change the current node so it refers to the next node in the LinkedList. You can keep doing this until you reach self.back, which means you've hit the end of the list. Keeping this method in mind made it quite easy for me to follow along and understand how __contains__ was implemented.
This is the body for __contains__:
We start off by referring to the front of the LinkedList. The while loop condition continues iterating to the next node in the LinkedList until you either find the appropriate value, or until cur_node refers to NoneType, which means you've reached the end of the LinkedList. This skips through the while loop body and immediately returns False because the value is not within that LinkedList.
That's the gist of LinkedLists. I hope you gained some insight on the topic by reading my SLOG!
Subscribe to:
Post Comments (Atom)






No comments:
Post a Comment