Time passed by so fast, by this time I noticed this semester has almost came to an end. I have learned many new things and strengthened by knowledge of python this semester. I have learned many new python classes that each has a specific role in keep tracking different values, and also learned many different recursions for these classes that is very helpful for writing functions and methods. I loved the three assignments, where we made simple games from scratch. Tutorial was very fun, I am impressed that there are so many computers in BA, where my tutorial is at. Classes was very interesting, we learned many new concepts for programming and many new ideas were been introduced.
Now as I look back to my past SLOGs it made me feel very accomplished, as its like a diary were all the things I have learned and all my struggles is been recorded. I have also learned many new things that I didn't notice before over the past weeks as I study for term-test 2 and doing assignment 3. For example, as look back on my Week 7 SLOG, I was talking about recursion and how it works, at that time I did understand the concept, however as my experience grow after these weeks I noticed many small tricks that could be helpful when writing recursive functions that I would like to add to my previous post. These might seems very obvious, but after writing many recursive functions I have made countless mistakes around these small things that I have forgot, so I felt these are very important to check after writing a recursive function.
1. Check for parameters in recursive function, check if when calling the function itself inside the function body all the parameters has been given, and do they have the correct value.
2 . Check for children before using them. Example: When writing recursive functions with BTNode type of class don't forget to check for self.left and self.right before using them, otherwise there might be an error because they might not exits.
Sunday, March 29, 2015
Sunday, March 22, 2015
Week 10 - MiniMax Testing
In this week's lecture professor Danny talked about how to write the best and most efficient test cases for testing programs like MiniMax. This was very interesting for me because I myself had done it in the previous assignment 2 while writing MiniMax. However hearing him teaching us about how to test MiniMax made me felt very uncomfortable, because it made me feel that my testing was not that well thought and my code might have some flaws.
Sunday, March 15, 2015
Week 9 - Exam Week
This week was very busy for me, with may assignments and a presentation due as well as a 2nd mid-term exam for this course. There are no tutorial for this week due to the strike and the class was cut short because of the exam so there is not much to talk about for this week's blog.
I basically studied and worked all week, I first looked up past exams to get a general idea of what to be expected in this mid-term, due to all the past exams were about writing functions of recursive codes I did not expect word questions on the test that test our knowledge of programming terms like different 'nodes' and technical terms for ways to count a tree. I did very bad on the first part because I got overconfident and overlooked materials that weren't covered in the past exams and didn't prepare for the definition part.
I basically studied and worked all week, I first looked up past exams to get a general idea of what to be expected in this mid-term, due to all the past exams were about writing functions of recursive codes I did not expect word questions on the test that test our knowledge of programming terms like different 'nodes' and technical terms for ways to count a tree. I did very bad on the first part because I got overconfident and overlooked materials that weren't covered in the past exams and didn't prepare for the definition part.
Sunday, March 8, 2015
Week 8 - LLNode and LinkedList
This week was also a busy week because we had to hand in assignment 2 on Thursday before 10 pm and I had to do a lot of final checking and check all my function files with pep8 and change all the format preference errors.
In this week's lecture we learned a quite interesting example of python class LinkedList which use another python class LLNode in itself. This was a very interesting concept as it is very hard and confusing to understand for me at first. Basically LLNode acts like a 'value' class for the LinkedList class, where LLNode only shows its current value (like BTNode) and 'nxt' which shows a recursion of LLNode inside it. (like BTNode could also be None) LinkedList is basically its like a 'list recorder' for LLNode that shows the last BTNode in the LinkedList and the whole chain of BTNode in the LinkedList.
There was no tutorial this week due to the TA strike, and I had to do tutorial at home. However although at first it was very challenging to understand the concept of writing function and method for BTNode and LinkedList, after a few fails I started to get the hang of it, and with the help of answer sheet I was able to quickly write all the functions in the tutorial handout.
In this week's lecture we learned a quite interesting example of python class LinkedList which use another python class LLNode in itself. This was a very interesting concept as it is very hard and confusing to understand for me at first. Basically LLNode acts like a 'value' class for the LinkedList class, where LLNode only shows its current value (like BTNode) and 'nxt' which shows a recursion of LLNode inside it. (like BTNode could also be None) LinkedList is basically its like a 'list recorder' for LLNode that shows the last BTNode in the LinkedList and the whole chain of BTNode in the LinkedList.
There was no tutorial this week due to the TA strike, and I had to do tutorial at home. However although at first it was very challenging to understand the concept of writing function and method for BTNode and LinkedList, after a few fails I started to get the hang of it, and with the help of answer sheet I was able to quickly write all the functions in the tutorial handout.
Friday, February 27, 2015
Week 7 - Recursion and Assignment 2
This week is probably the most exhausting week for CSC148, not because of lecture nor test, but it's because of the coming due date of assignment 2. When I first started university, I had handed in many late assignments, not because of I didn't complete the work in time, but it was because of that I completed just in time, and went on a break forgetting about handing the assignment in. Due to these bad incidents I have made a habit of starting assignment earlier than before, so same with this assignment I started right on the night of Friday of this week.
Recursion is super important nowadays, everything function I write this week involves some sort of recursion, like assignment 2 and even what we learned in class and tutorial. This week's lecture we learned to write functions for a new class, BTnode, of course involving recursion. Basically BTnode is a class that similar to list and Tree, where it creates a variable, that can contain up to 2 variables, which can be either a number (int) or BTnode. Since this is similar to list and Tree, there are so many new functions that we learned to write using recursion.
There were so many challenges with the assignment, first I had to read and understand completely the given game view and game state structure, and on top of that I had to follow the formula and make a harder game state with a more intelligent move chooser. The hardest part for me was writing the winner function for Tippy (a function that checks if either player had won the game) and suggest_move function for MiniMax strategy. The winner function for Tippy was hard in the sense that I had to write so many lines to check all the possibilities for each position on the game board and restrict places that were been checked on the board. The suggest_move function for MiniMax strategy was without a doubt the hardest part in this assignment for me, and as the title of this week's blog suggest it is related to recursion, and in fact I had to write two very hard helper function using recursion to make suggest_move work, and as you can imagine all the different bugs I had when writing suggest_move, where I spend most of the time tracing values in the recursion functions.
So... what is recursion? Basically to put into the simplest words recursion is preformed when a function calls it self in the program. Recursion can be useful when writing harder functions (like ones I mentioned in assignment 2). For example, there is a list that contains many list and integer, and those list inside also could potentially contain more lists and integer (nested list with integer), and we want to write a function that adds all the integer in the list up. By writing a function with a for loop looping each variables (whether a list or integer) and calls the itself (the function) with the variables we can simply accomplish this task, no matter how many list is nested inside the first list.
![]() |
| (sample function by me) |
![]() |
| (example of BTnode from week 7 lecture slide) |
Thus to conclude my adventure for this week, I found understanding recursion and knows how to write it is very important for writing Python functions (or maybe as well for other programming language). Although it was very tiring this week trying to fix all the bugs in assignment 2 tracing recursions, but I found it very exciting to program those functions, and very rewarding when I found that my programmed AI can beat me most of the times. Especially when AI goes first on Tic Tac Toe (very similar to Tippy I made on spare time), the win rate for AI is really high!
Sunday, February 15, 2015
Week 6 - Tree and Writing Recursion
This week's lecture was pretty challenging, we learned class Tree and how to write recursion for Tree. I have some knowledge on how Tree works as I have studied class Tree last week in preparation of the midterm, but it was still challenging to write recursion for Tree. Basically the class Tree works pretty much as a list with list value inside, except the current list or so called 'node' has a value to it. Also it is possible for a node to have no 'children' or no sub-list.
![]() |
| Visual representation of a Tree object. (Writing Recursion Exercise) |
The tutorial for this week is very hard, probably the hardest tutorial I have had so far, and this is the first time where I have not able to finish all method example on lab handout. Similar to lecture this week's lab is about writing recursion for class Tree, and it is very tricky. Methods that we were asked to write like return all the value in Tree object where it has at least one children are extremely complicated and requires a lot of thinking. The quiz in the end was also very tricky, where we were asked to write a function that returns the maximum depth in the Tree object, and I had little confidence on the correctness of my answer.
Week 5 - Midterm Review
We have a midterm exam in this week's lecture... although I am writing this blog a week late but I can still recall what happened during that week. I started reviewing past exams few days before the exam, and studied many questions even ones with tree and exceptions. The exam was pretty easy however, with just questions about writing hidden methods, tracing recursion calls and inherit sub-class methods. Surprisingly there is no question about stack in the exam, which I thought its a must have question form observation though past exams.
The tutorial was very interesting, we learned a new class similar to stack which is called queue. The main difference with queue and stack is that when use the method .pop() on stack it delete and returns the object the top of the list while use the method .pop() on queue it delete and returns the first object in the list.
The tutorial was very interesting, we learned a new class similar to stack which is called queue. The main difference with queue and stack is that when use the method .pop() on stack it delete and returns the object the top of the list while use the method .pop() on queue it delete and returns the first object in the list.
Friday, January 30, 2015
Week 4 - Recursion
This week was a long week for me, with many assignments due and most importantly the first assignment on in this course is due on Thursday. I started the assignment very early in this week, and finished all the codes and got it working on Monday, however I wasn't paying enough attention on reading the weight of assignment 1 handout, which made me to miss read that we have to make 5 class part, so instead of writing 5 classes I only wrote 2. I quickly noticed the mistake by the reminder of a friend and added 3 more classes and got them working before Tuesday evening. I worked pretty hard these days on this assignment and got really tired the next day, but still I managed to finish all the doc strings, and due to I was pretty tired I only did minimal amount of testing, and the next day I did lots of testing and handed in on 9:59 PM, just before the deadline.
In this week's class we learned a very interesting programming technique, which is recursion. It is basically used for finding or getting information from lists with many nested lists, like the example below.
Recursion can be preformed in a program simply by calling itself in the program. Where we must assume L (in the example above) must either an element of int, or list of elements that satisfies the assumption.
This week's tutorial was very good, the best tutorial I have been to so far in my opinion. The lab handout was easier than the ones before, and it really helped me, step by step to get a good understanding of recursion and was a great practice for writing traces for recursions.
In this week's class we learned a very interesting programming technique, which is recursion. It is basically used for finding or getting information from lists with many nested lists, like the example below.
![]() |
| (From course note January 26, nested list examples.) |
This week's tutorial was very good, the best tutorial I have been to so far in my opinion. The lab handout was easier than the ones before, and it really helped me, step by step to get a good understanding of recursion and was a great practice for writing traces for recursions.
Friday, January 23, 2015
Week 3 - Why should geeks write?
Another new semester started, and not long before I have realized three weeks has already passed. It's only been three weeks of school and I already could not clearly recall what have I done with my precious time in the long summer break. In the other hand when I look back at the Blog I have been posting when I took CSC165, I can suddenly remember all those important things I have learned over the course. Now as the topic asked 'why should geeks write?' This I felt is the main reason why should we write, to continuously gives us chance to refresh our memories burred deep down in us.
In other successful programmer's blog they said that it is also important for us to write clear comments and technical specs for our programs so that other programmers will understand our code. I felt that this is really important aspect of computer programming, due to programs are usually done in a developing group, and having a clear and good communication is the key to success.
It is also very important for us to keep a debugging journal. A debugging journal is very useful for us to record different types of bugs that can occur unexpectedly during programming. Writing a debug journal is really important for helping us to recall different types of bugs, and ways to solve them. I felt that the difference between a good computer programmer and a bad computer programmer really depends on their wisdom and experience on programming, and this is why I felt its really important to write debugging journal.
In other successful programmer's blog they said that it is also important for us to write clear comments and technical specs for our programs so that other programmers will understand our code. I felt that this is really important aspect of computer programming, due to programs are usually done in a developing group, and having a clear and good communication is the key to success.
It is also very important for us to keep a debugging journal. A debugging journal is very useful for us to record different types of bugs that can occur unexpectedly during programming. Writing a debug journal is really important for helping us to recall different types of bugs, and ways to solve them. I felt that the difference between a good computer programmer and a bad computer programmer really depends on their wisdom and experience on programming, and this is why I felt its really important to write debugging journal.
Subscribe to:
Posts (Atom)





