Wednesday, 25 March 2015

Thoughts on A3

                I have just started working on A3 yesterday. A3 is different from the previous assignments in that we get to choose from two choices. We can either improve on our strategy minimax, or we can work on functions for a gamestate tree. My partner and I chose to work on the second option, since we we’re not confident in our strategy minimax.

                The first few functions in the assignment were very similar to a lot of tree recursion functions we did earlier in the semester. The functions were fairly easy to implement. I recall in my second slog, I was still struggling with recursion. That was when we first started learning about it. Now, whenever I have to come up with a function that involves recursion, I still use the method I learn from a month ago, which is to come up with a if statement for the most basic case, then an else statement for more complicated case using recursion. I think my skills of using recursion have improved because of practice from this last one and a half month.


                I think this assignment is surprisingly the easiest assignment we had. This may be because while the difficulty of the assignment remained the same, I improved a lot from one month ago. However, the last two functions are supposedly very difficult. I look forward to completing them soon.

Monday, 16 March 2015

Test 2 Reflections

                Last Wednesday we had our second term test of the year. For me the second term test felt slightly easier than the first one. The test covered topics of binary trees, binary tree nodes, linked lists, and linked lists node.

                The first question on the test was on the length of binary trees and the order of the nodes visited. This was a fairly straightforward question, since it was mostly based on basic knowledge of tree structures and the definitions. The second question was to come up with a binary search tree function list_even_between. The question is similar to a function we touched upon in the tutorials. The solution involves making a left list, a middle list, and a right list, while calling recursion on both the left and right side of the binary search tree. The third question is a linkedlist function called absorb value, which deletes a value and adds it to the value after it. This question is also similar to another function in the tutorial. Luckily, I had some of the tutorial functions recorded in my cheat sheet, which really helped me on this question.


                Because of the TA strike, we did not have a tutorial last week. This was a shame, since this class’s tutorials really helped a lot.

Monday, 9 March 2015

LLNode and LinkedList

  Last week we started a new class, Linkedlist and LLNode. A LinkedList is, as its name suggests, a bunch of lists that are linked together. Class LLNode is specific to LinkedLists, and LinkedLists are essentially one or more LLNodes combined. This concept was confusing to me at the beginning. However, it really helped when I reviewed the codes posted online. By carefully looking through the code and starter functions provided, I have a much better idea of how the classes work.


  Because of the TA strike, there was no tutorial last week. I briefly tried the tutorial exercise on LinkedList and found it much harder than I expected. This is when I realized I still don’t understand the material well enough. Fortunately, the solution posted on the course website helped me a lot on this topic. After looking at the solution for the first function, I had a much better idea of what to do. With the help of while loops, we can find the correct section of the LinkedList we want to work with. By the way, as Danny suggested, drawing pictures really helped. For me, it shows and reminds me where to “disconnect” or “connect” the LinkedList in different functions.

Monday, 2 March 2015

Thoughts on A2

  For the past two weeks, I have been working on assignment 2. This assignment is in a way an extension of assignment 1 because we are working with the same classes (Gamestate, Gameview, Move, Strategy). However, the game Tippy is more complicated than Subtract Square (referred as SS). For example, there are different situations the game Tippy can end, while SS can only end with the number being 0. Also Tippy can end in a tie, another new condition that needs to be considered.

  I did not encounter any major slumps while working on class TippyGameState and class TippyMove. Most of the functions are straightforward and very similar to those in assignment 1. One tip I noticed is the importance to come up with a plan first before starting coding. In this case, it was important to know how I was going to represent the squares on the board. I chose to use coordinates in the form of tuples, and several important functions were dependent on this choice.

  In the past few days I was stuck for the longest time on class Minimax. There were two problems that I could not solve for my suggest_move function to work properly. The first was to return an available move at the state. Since the suggest_move function uses recursion and calls upon itself, the move that it analyzes when it calls on itself is a move in the next step. Eventually, the move it will return is that in the final step it analyzes. The other problem lies in the scores 1 and -1 that are assigned to each player in each state of the game. When the function uses recursion and analyzes the next state, the state.next_player variable switches, and the scores should be flipped. As of now, we have not found a way to implement this into our code.

  There is still three days left until the assignment is due. With all other parts of the assignment done, I am positive that we can come up with a way to implement class Minimax.

Sunday, 15 February 2015

Object Oriented Programming - Tree Class

    This week we continued on the topic of object oriented programming. In both lectures and our tutorial, we learned about the class tree. During the lectures, we were given worksheets and followed Professor Heap constructing functions for class tree. For me this tutorial was the most challenging so far, and I faced multiple slumps while solving the tutorial problems.

    In the tutorial, I was first stuck trying to come up with the algorithm for the first function, list_all. I could do the first two step of the three step procedure and found them straight-forward. However for a while I couldn’t solve the third step, which is to combine my results from the first two steps using recursion. I was stuck on where to implement the gather_list function in the algorithm. First I tried to trace the recursion steps and come up with the algorithm, but this proved to be ineffective. I eventually solved it through constant experimentation. Even though this is a legitimate way to solve problems, I am unsure about the fact that I cannot explain why I would write my code like this. I think I might’ve just gotten lucky. The other questions in the tutorials are much easier after finishing the first one since the gather_list function is implemented the same way. However I got stuck once again on the last function list_to_depth, in which I did not solve in the end because the tutorial session was over.

    In conclusion, I am not confident in my ability to come up with algorithms using recursion. The quiz this week was also the first quiz I wasn’t 100% sure about. I certainly need to practice more during the break, starting the second assignment as well as finishing up the tutorial question.


Sunday, 8 February 2015

First Impressions

* Since last week I talked about recursion (which is supposed to be this week's topic), I am going to discuss last week's topic in this entry.
  In the first few weeks, we learned about classes. Despite having learned about classes in csc108, most of the content, such as subclasses, abstract data types, property, and list comprehension, were new. In lectures, I feel like I "sort of" understand the material, but can’t really tell because of the lack of actually solving problems. While Danny's lecture style is identical to that of csc165, a class I genuinely enjoyed, I found it harder to follow up in the first few weeks. However, I found the tutorials and assignment1 very helpful, since those are the times when we actually do hands on programming. I think for the first two weeks, I was still trying to get used to this new style of lectures (in contrast to csc108, where we had in class worksheets), but now I think it’s a nice balance with the tutorials and assignments. That's mostly my impressions pf the lectures and labs, and for the rest of the entry I'm going to briefly talk about my impressions of each new topic we touched upon.
Classes and Subclasses
CSC148 started with classes, right where we left out in csc108. The only new stuff we learned that I remember is the __repr__ method. The first two lessons on this subject felt like a review session of last semester's material, which was a good transition into a new class. As for subclasses, it was easy to understand

ADT

We were introduced to a new class Stack. We talked about common ADTs that we already know, such as list and dictionary. There may be more about ADT, since our most recent lab was on this subject.

Property
Property is a new concept that we learned about classes. This was not touched upon in tutorials, and therefore I don’t think I fully understand its implementation.
List Comprehension


This is an easy and useful trick that we learned to use instead of writing loops for a list. We learned this in the first lesson, and it was brought up again later on.

Monday, 2 February 2015

Recursion

  Last week we moved into a new chapter: recursion. In class and in the tutorial we did several examples of tracing function that uses recursion. I find recursion a very tricky concept. I have no problem tracing the functions, however I always get stuck writing a function using recursion.

  We were introduced to recursion in three levels. First, we encountered a function using recursion including its docstring. This was simple, since we can “cheat” and know what to expect from the docstring, without perhaps a solid understanding of how the code works. Next, we did several questions in the tutorial of functions without the docstring. This is only slightly trickier, since after a few examples of tracing the code, the logic of the recursion shows up. However, I have difficulties going the opposite direction: coming up with my own code using recursion. I feel like I understand the concept of building and accumulating from the special case (since when tracing, everything eventually reduces to the special case, in most of our cases when the object is not a list), but I think I need more practice.


  It is a relief knowing that in our term test we will only need to trace recursion functions. However, I will have to catch up on implementing recursion in my own code, since it will be a very useful and necessary skill.

Sunday, 25 January 2015

Why geeks should write

  Why should geeks write? A geek is one who is, as described by Wikipedia, “an expert or enthusiast or a person obsessed with a hobby or intellectual pursuit”. Geeks are often portrayed as introverted people obsessed with subjects such as math, computer, or science-fiction. Being introverted, writing may be a good way for geeks to express themselves and relate with the rest of the world. But the benefits of writing are greater than communication, and everyone, not only geeks, should be actively writing. In the process of writing, we go through a lot of reflection before putting our thoughts down. Writing helps us explain what is going around us. It is a process that materializes an abstract concept, and through it we can enhance our understanding of the matter.


  Writing is an especially powerful skill for geeks. In verbal communication, much can be lost in jargon of the relative field, hindering a geek from expressing oneself. The public is also a beneficiary from geek writings. Specializing in their distinct fields, geek writings most likely contain knowledgeable content that can benefit people who want to learn more about a subject. I myself certainly have benefited from websites and forums online explaining math questions and python related problems, and some of it are most likely answered by people who we call “geeks”.