The prompt of this week is to revisit one of my earlier slogs and to see whether I still agree with it or not. Midterm Summary is one of my favourite slog, because it genuinely reflects my state of mind at that time, and I would like to see how my thought has changed or remained the same.
In Midterm Summary, I mention the differences between CSC108 and CSC148. When I talk with my friends, almost everyone agrees that the materials of CSC148 are harder; we have been intimidated, but we generally are able to handle them after continuous practices. After all, learning is a series of systematical progresses.
I also talk about how great Prof. Heap is, and now I rate him even better. He is literally the best. The strike has been distressing for a lot of us, and Prof. Heap helps us to get it through. My friends and I all think that he really cares about us.
At the end of Midterm Summary, I complain about my stressful timetable. Because of the strike, lots of labs and tutorials have been canceled, and I have more free time in return. I am quite good at learning on my own, so it is actually beneficial for me in some ways. This semester is about to end soon, and with all of our TA’s back, I believe everything will finish without any trouble.
Sunday, March 29, 2015
Monday, March 23, 2015
Week 9: Midterm 2
We had the second midterm test on Wednesday of week 9, and it lasted an hour. Prof. Heap had more office hours than usual to answer our questions before the test, since the TA's were on strike. He was extremely helpful, and I admired the fact that he kept patient and kind to us even though he was very tired.
The test was quite related to the materials covered in the lectures, so I would say it's a fair test. We were allowed to bring a aid sheet with us, same as the first midterm. As a matter of fact, I found that preparing a aid sheet helped me mastering study materials, since I needed to fully understand them in order to plan out the content of my aid sheet.
After the test, we had an hour of lecture, which was mainly about binary search tree (BST) functions. Prof. Heap went through the implementing process of function insert and function delete with us. He asked questions and drew graphs so that we could understand how these two functions work under different circumstances. It was frustrating to have a lecture right after the test, but we made it.
Sunday, March 15, 2015
Week 8: Assignment 2
Assignment 2 was ... confusing. Especially for the strategy minimax. It took me several hours to argue with my partner about how it really works, with pages of doodles and nonsense, and ended up even more confused and frustrated than before. We could not go asking for TA's help, because of their prolonged strike, which has no sign of ending at this point when I am writing this slog. Luckily, after hours of waiting in the line, I finally got the chance to discuss with Prof. Heap about my confusion, and he easily solved the problem in less than a minute.
The main point of minimax is to keep score for both players to determine how good or how bad their positions are. As described in the guideline file of assignment 2, the score system is:
If the game is over, A's score is:
1 if A wins;
-1 if A loses;
0 if it's a tie.
I could not understand how it works in a situation that both A and B have a legal move that leads to a new position where their score is 1. Wouldn't both of their scores be 1 in the above situation? But clearly someone's score should be -1. My partner tried to convince me that I should only look at one player's score and ignore the other, but I doubted that's the case.
In the end, Prof. Heap helped me to get out of this paradox. He told me that it's about who is the current player in the situation. If A is the current player, than A will choose a move that leads A's score to be 1, and A will never choose a move that leads B's score to be 1. No matter how many moves there are and no matter how many new positions these moves could lead to, the only one matters is the one that is the best for the current player, and that position determines the scores for both players.
After Prof. Heap's simple and effective explanation, the whole paradox was no longer confusing. I was so happy and relieved. It didn't take us much time to work out the code as long as we understood the rationale behind it.
The main point of minimax is to keep score for both players to determine how good or how bad their positions are. As described in the guideline file of assignment 2, the score system is:
If the game is over, A's score is:
1 if A wins;
-1 if A loses;
0 if it's a tie.
B's score is -1 times A's score, since this is a zero-sum game: what's good for A is bad for B.
Suppose the game is not over, and the current player is A. Then A's score is:
1, if at least one A's legal moves leads to a new position where A's score is 1 (or B's score is -1, since B is the current player in the new position);
-1, if every legal move for A leads to a position where A's score is -1 (or B's score is 1, since B is the current player in the new position);
0, if at least one of A's legal moves leads to a score of 0, but none lead to a score of 1. I could not understand how it works in a situation that both A and B have a legal move that leads to a new position where their score is 1. Wouldn't both of their scores be 1 in the above situation? But clearly someone's score should be -1. My partner tried to convince me that I should only look at one player's score and ignore the other, but I doubted that's the case.
In the end, Prof. Heap helped me to get out of this paradox. He told me that it's about who is the current player in the situation. If A is the current player, than A will choose a move that leads A's score to be 1, and A will never choose a move that leads B's score to be 1. No matter how many moves there are and no matter how many new positions these moves could lead to, the only one matters is the one that is the best for the current player, and that position determines the scores for both players.
After Prof. Heap's simple and effective explanation, the whole paradox was no longer confusing. I was so happy and relieved. It didn't take us much time to work out the code as long as we understood the rationale behind it.
Sunday, March 8, 2015
Week 7: Binary Tree
In week 7, we learned the data structure of binary tree. Basically, it is the same with tree data structure, except that a binary tree has at most two children, which are referred to as the left child and the right child. While visiting other students' slogs, I noticed some students posted code on their slogs, and I found it made the abstract description easy to understand. Therefore, here are some binary tree code:
class BTNode:
'''Binary Tree node.'''
def __init__(self, data, left=None, right=None):
''' (BTNode, object, BTNode, BTNode) -> NoneType
Create BTNode (self) with data and children left and right.
'''
self.data, self.left, self.right = data, left, right
Professor Heap led us to implement a function for the BTNode class, which is called evaluate, through exercise. Evaluate makes calculation based on the data of BTNode using recursion. I found it easier than writing functions for tree, or maybe I am just getting used to it.
def evaluate(b):
''' (BTNode) -> float
Evaluate the expression rooted at b. If b is a leaf,
return its float data. Otherwise, evaluate b.left and
b.right and combine them with b.data.
Assume: -- b is a non-empty binary tree
-- interior nodes contain data in {'+', '-', '*', '/'}
-- interior nodes always have two children
-- leaves contain float data
>>> b = BTNode(3.0)
>>> evaluate(b)
3.0
>>> b = BTNode('*', BTNode(3.0), BTNode(4.0))
>>> evaluate(b)
12.0
'''
if b.left is None and b.right is None:
return b.data
else:
return eval(str(evaluate(b.left)) +
b.data +
str(evaluate(b.right)))
We also learned binary search tree (BST), which is a special kind of binary tree. It needs to fulfill the restriction that self.left.data < self.data < self.right.data. We then implemented more functions about binary tree and BST in the lab.
Moreover, I started assignment 2 in week 7. I found an awesome teammate, and he made the whole process joyful and relaxed, even though this assignment is hard in some way. I will write in more details next week.
Sunday, March 1, 2015
Midterm Summary
At first, let me indicate clearly: I would like to choose my summary of OOP to be graded.
Then I have to talk about something else to get this slog done. Since we are right on the mid-point of this semester, it is a good time to sum up what I have learned during the first half of this semester, and my thoughts on these materials.
Compared with CSC108, CSC148 takes us to the next stage of python. CSC108 was more about how to use the built-in functions of python, such as string, list, and dictionary. On the other hand, CSC148 is leading us to build our own programs using python by implementing classes and subclasses. We also learned complicated programming method such as recursion. Step by step, we are on the exciting way of becoming a mature programmer.
Also, I love Professor Heap's style of teaching. I am surprised that he can call many of us by name, since this is such a large class. He has designated a large proportion of the course for interactive activities, such as making students to demonstrate how the binary search tree works using cards with number. I enjoy these activities, and I think they help me to understand the course materials better.
To be honest, this semester is tough for me because that I enrolled in six courses. My timetable is full, and as much as I want to, I cannot spend a sufficient amount of time on CSC148. Nevertheless, I managed to master all the study materials, and got an excellent mark on the first midterm test (98%). This is truly remarkable, and I am very proud of myself. Hopefully, my time-manage skills will help me to walk through the remaining half of the semester as well.
ps. I am already missing the reading break!
Subscribe to:
Posts (Atom)




