Friday, March 27, 2015

Week#10 Revisit Slogs

Revisiting Slogs

In this term's csc148 course, we have developed our skills in python, and the most important thing we learned is recursion.

In past several weeks, I wrote slogs about impression every week. In my opinion, I agree with most of what I write especially the concepts and examples used in the class.

At first, we learned the recursion through simple examples for lists of lists. These examples aimed at create a basic impression of recursion.

However, we mainly learned the recursion through tree and linked lists. As far as I concerned, the most efficiency way to think a recursion method is draw this specific tree, and figure out what nodes(or parents) and leaves(or children) are. What's more, we must ensure that every instance used in the class is understood before we write any method in class.
__init__ method for BTNode which represents a binary tree.

Compare with my friends' experience, I prefer to write codes after drawing the picture of a tree or linked lists on paper. Because this could help  me figure out each steps of each method, I can easily write codes through that specific tree.


Thursday, March 19, 2015

Week#10

There are only two weeks left to complete our courses in 2015 winter term. In this week's csc148, we analyzed our codes written in assignment 2, and learned some methods to strength our ability in python.

In assignment 2, we wrote a specific class called Minimax Strategy, which is a strong strategy for computer to choose the best possible move in current situation. As this method seems to be difficult to thought of, Danny gave us a possible way to get the solution.
one possible solution for minimax
The best way for us to come up with the idea and understand the solution is to draw a tree to represent every possible moves and all the winning position for a specific player. However, the tippy game seems to be so complex, so we will consider the examples in the subtract square game.
Subtract square example

On the other hand, we also learned a new method called assert to simplify our 'if not' statement.





Friday, March 13, 2015

Week#9

For CSC148,  this week we started the topic of mutation (eg. LLNode and LinkedList) and we took term test 2 on Wednesday.

Class Tree, BTNode and LinkedList were tested in midterm 2. As far as I'm concerned, the methods written in the test for BTNode and LinkedList were similar to what we wrote in the lab. As long as we understand the recursion and basic methods written in the classes, the methods for the test would be easily completed.

On the other hand, LinkedList would be the first class that we encountered with mutation. 
LinkedList init
The nodes in the LinkedList are the nodes in LLNode class. As a result, self.front would be continued changing while value and nxt change. (insert_before would be a good example to explain this.)



 

Saturday, March 7, 2015

Week#8 Impression of Week 7 and Assignment 2

After reading week, our CSC148 course seems to be more difficult than before, especially the assignment two. However, our lectures continued the topics on recursion and mutation.
For week 7 and week 8, we learned two different classes called BTNode and LLNode, which can been seen as a tree and a linked list, respectively. Both classes can be closely associated with the recursion steps. We can take LLNode in week 8 as an example. 




LLNode consists value (the current node) and nxt (the node linked with current node) which can be treated as the child of value. The recursion steps happen since the nxt could also be the value of other nodes. The difference between we learned in week 7 and week 8 could be the way we imagine the  diagram of these two classes. For BTNode, we should see the values as leaves in a tree, appending the values in left or right leaves in that tree and calculating the values by a distinct symbol. On the other hand,  LLNode is a class that represents a linked list, each node has its own child, and child can also be the parents of other children. However, the essence of these two classes should be same. They both include the thoughts of recursion and mutation.
BTNode

LLNode


Assignment two seems to be more difficult than the assignment 1, especially  winner in tippy game state and minimax strategy. In winner, we must containing all four possible states of forming a tippy. What's more, minimax could be consider as the most difficult problem we countered. However, once we figure out the recursion steps, and  body of the method can be written easily. In this step, a tree diagram and written score for every steps in the corresponding position on the diagram.