Sunday, 5 April 2015

SLOG9: End of the semester

It is so amazing that we are at the end of the term now! It is indisputable that I have spent a fabulous semester of learning CSC148 with my dear prof, Danny Heap, and numerous outstanding geeks in this lesson. I feel excited and satisfied.

As far as I am concerned, CSC148 is a course that contains much more knowledge, tricks, methods and modes than CSC108 which I took last semester. Though we gained sufficient basic knowledge and rules in the latter course, putting them together and make them make sense and work could always be another thing. For example, even if I learned loop in CSC108 and could use it fluently, I could never know that there exist more efficient approaches without further learning of CSC148, or even in the area of Computer Science. Here I wan to talk about recursion, which is one of the most important methods I learned in this course. What recursion uses is no more than some loops, if-statement and calling ht function itself, yet it makes a big difference. It could deal with every complicated (mainly nested or multi-layered) conditions via defining the basic one and calling itself again and again. Methods like this is exactly what we need to learn after getting the basic and easy knowledge of programming.

Moreover, it also provided me an opportunity to brainstorm. I still remember the experience of designing and making Assignment2 in CSC148. The process of working on Minimax Strategy, in particular, impressed me a lot. There is no doubt that designing such a new strategy only by the result that the computer should gain the best opportunity to win the game is not easy for me. In order to tackle the task, what I could do was to study the specific logical process of such a strategy, and then brainstorm numerous possible solutions of every step. It really took me long time and much thinking on it, but I have to say that I gained deeper understanding for the strategy in a game, and, more ideas of designing a logical algorithm for a program. Now I would figure out the logical structure every time I write a computer program, A3 included.

All in all, I really appreciate that I could learning CSC148 and attain a large amount of new knowledge and idea in this semester. As I have applied for CS Minor, I am sure that I will learn about CSC course further in the future. The battle just begins!


SLOG8: Revisit for SLOG4

The application of recursion is just beyond my original imaginary. Though I have talked about my experience for recursion before, with further learning in CSC148, now I just grasped more knowledge about recursion.

In the previous SLOG4 posted by myself, I mainly shared my opinion of the logical idea of recursion, such as defining one basic condition and connections between basic and complex ones. They are not wrong somehow, yet, I just missed something, or let me say that I misunderstood pats of the idea. At that time I believe that every recursion has to be here with a return value and when it meets a complicated condition, it would use the return value form last step to do the next running. However, that is not necessarily true. As I have mentioned last week, recursion could be called by a condition, and return nothing. This is so important for me since I could apply recursion further and deeper in the future coding work.

Anyway, making mistakes is also an essential part of making progress. Though I met some problems when I began working for A3, I actually gained new knowledge and experience from it.

SLOG7: Impression of the week

With time going by, it gets closer and closer to the end of the semester. Simultaneously, knowledge, ideas and solutions in our minds getting more and more.

This week the main concentration of mine was on the new coming Assignment 3, which asks us to do more study of game strategy via writing a series of recursive functions. The general idea of them is to regard a game state as a tree with nodes as current game states and children as next possible game states with different next moves. You can even use a "grow" function to get all the possible potential conditions from a single original game state node.

I have to say that the "grow" function in A3 really changed my idea of recursion somehow. In the past I believe that any recursive function should have a return value since the next step of recursion would be based on the return value from last step. In other words, if one function is recursive, sentence like "return f(x)" should be contained in the body part. However, in fact, it is not necessarily true. The "grow" function just need be called again by every item in "children" parameter without a return value. And, as defined in its docstring, the "grow" function itself does not have a return value, but actually it could be fulfilled via recursion.

For A3 I find another student as a partner and one of my tasks is to finish the "grow" function. I really appreciate it since I got an opportunity to know more about recursion and could use it more effectively. Moreover, I convinced myself that the working process of computer code and logic design are never set curved in stone. They could fit any condition and requirement as long as used properly.

Though the writing work is not done yet, I believe that we could get a high mark for this assignment with tough studying.

Sunday, 15 March 2015

SLOG6: Impression of Test 2

The wave of strike seems to be still high and keep rising. As a consequence, we have no choice but to gain some of the knowledge and do exercises by ourselves.

First I need to talk about Test 2 which was finished this week. As I have mentioned before, the strike could never prevent us from gaining knowledge and doing relevant exercises, tests included. So the test went as planned and I worked very hard for the test. Based on what we have learned recently, Test 2 mainly contained the idea of Tree (Binary Tree included) and LinkedList, which could be regarded as a special Tree. There is no doubt that both of them presented the idea of connection between elements in different levels, and lower levels were connected to the upper ones all the time. From this point, recursive thinking is often applied to solve these problems. However, as long as you figure out the basic condition and how each levels are connected, it could be easy to solve recursive functions, and, do well in Test 2. My job was not bad, but still not enough!

Besides, though the test was over, learning can not stop. Actually I gain deeper understanding for recursion and Tree class from the test, and I would apply it as much as possible in the further learning, for example, the coming Assignment 3.

Due to the strike, the marking of Test 2 might be delayed more or less. Anyway, good luck to all of you!

Sunday, 8 March 2015

SLOG5: Impression of the week

In the last week a TA strike attacked the whole school and we lost many labs and tutorials, CSC148 lab included. However, the learning of CSC148 course would never stop during these reasons, and perceiving and grasping new knowledge would keep going on, too.

This week we learned a new concept named "linked list", which is similar to but not the same as the concept of tree. Though they both use "nodes" as a super level and contain elements called "leaves" in the sublevel via each list, and elements in lists could be other nodes at the same time, the number of nodes in the list of linked list could only be one. That means, every node contains an element and a list which contains another single node. That is quite interesting since elements are not standing as a line simply. Instead, each two nearby elements are connected tightly and if you delete the form node then the latter one would vanish.

The concept of linked list provides a different option for us to storage elements like integers, floats, strings and so on. In the past we may tend to storage what we want by using list, tuple and dictionary. Yet none of them may create a connection between every two elements. Now via linked list we could achieve it easily, which may make a difference in the future learning and coding.

The other thing is that Assignment 2 was due this week. I cannot deny that during the past two weeks I spent the majority of my after-class time to work for this assignment. At first I really met lots of trouble, such as the form of a move, the storage of current places of checkers, the judgement of rough outcome and the idea of minimax strategy. In particular, I really had no idea how to design a strategy for the computer when I got the handout. With tough working, thinking and coding, I solved each them gradually and eventually complete the whole assignment. Though the strategy is not perfect, I tried my best and make it matter for most cases.

We will face Test 2 in the next week. Tough what will be shown in the test is certainly more difficult, I believe I could get them with sufficient exercise. Good luck to every geek in CSC148!

Sunday, 1 March 2015

SLOG4: Recursion

As the processing of the course CSC148, we have grasped several essential concepts and skills of coding. Recursion, as the latest but a crucial kind of method for us, is showing how efficient and effective it is to us. There is no doubt that recursion method really presents the strong function of computer programs.

In computer science any object or class or method could apply recursion approach as long as they could treat a set of possible cases somehow towards the base case(s). Therefore, the most important identity of recursion is that it could treat numerous conditions (e.g. every state in a game) with only a few lines of codes. Inside these lines the function itself would be recalled until the final conditions are arrived. The process could be so long but we could throw it into a recursion and let it deal with the situation for us within seconds.

 As I have mentioned in last week's SLOG, a Tree class could exhibit recursive behaviour since there are two basic cases: if there is only one number, then we call it a leaf; else if it contains a number and one another list and the list is non-empty, then we call it a node. For those nodes cases we could always treat it towards leaves via using recursion, which means a function that could call itself while running. Since the basic element of node is the leaf, we could let the recursion function call itself if the variable of the function is a node until every variable we meet is a leaf.

The application of recursion could even be further. During the last two weeks we were concentrating on CSC148 Assignment 2, which includes a strategy called Minimax. It requires us to consider all possible states when a move is applied in a game state. Here we could divide conditions into several cases: win, lose, tie, or the game is not over. For the last one it is a sound choice to use recursion to make the assumption until the game is thought to be (but not actually be) over, and then we could judge whether the player would win or not and therefore decide which move for the current player has more opportunities to win. Since it is impossible for us to list out all the states step by step, recursion is efficient enough for us to make it. For every possible moves we could analyze the first step by ourselves and then apply recursion to "make" (assume to make) next possible moves until the game is over and there is no more possible moves. After that, what we need to do is only returning the max score for the final state of every possible move we analyzed at first. Here we omit doing numerous analyzing manually and give this task to the recursion.

Grasping recursion is also an essential harvest for me. In the past, the only method I could come up with to cope with problem that need to execute some commands more than once was the loop. Yet the definition of loop decides that it could only be applied to solve those simple problems which only need to repeat some identical and simple codes and conditions. Now with knowledge of recursion I am able to tackle more complicated conditions with changing antecedents and variables such as the states of one processing game. I could even say that recursion makes my codes become more intelligent!

The assignment would due in next week and there is not much time for me to complete it. I believe that as I finish it thoroughly I would gain more understanding of recursion and could use it more in the future studying.






Wednesday, 11 February 2015

SLOG3: Impression about recursion

In this week, we learned a class named "Trees" and designed some methods of it. Those methods all show the idea of recursion for us, which is a really effective way for coding.

The most prior feature of recursion is that it could use itself while executing. For instance, if the variable of the function is a list of list of list, or even more layers of lists inside, and this function are asked to do something towards every single non-list elements, then we could apply the method of recursion, which means that if the function meet a list, it would focus on every items inside the list and if there is another list inside, it would focus on elements inside the interior list, and could execute the procedure above more times until every variable is a non-list parameter. There is no doubt that the length of codes would be reduced effectively via such a method.

Coming back to the Trees class, in such a class, there must exist a single number which is called "node". Besides, there might be a list of numbers or "Trees" called "children", which derive from the "node". As mentioned before, by recursion we could focus on every node easily, and then do some further job like judging whether one number is equal to one of the nodes.