Post 9
This is the final post. The course is over and now I wait for the exam. I found that this course really made me appreciate computer science. At the beginning of the course, I mentioned that I did not really enjoy computer science because it is very tedious. While it is true, I still very much enjoyed our assignments and labs simply because felt like a accomplished very cool things. With minimax, I designed an algorithm that could defeat any player in a zero sum perfect strategy game. I remember still at three in the morning and playing tippy against the computer and losing every time and feeling very rewarded. With the last assignment, It was cool to see the algorithm work so efficiently and actually find moves for numbers as large as 1000 without taking the entire day.
Naturally, the strike did have an impact and although it did not affect me for most of my courses, I felt like the TAs really helped me understand the harder concepts like recursions and BST and I think I could have done better on the second midterm with their guidance. But learning some of the harder material on my own was it itself a good experience for me.
I very much enjoyed this course overall and was pleased to have taken it. Not only did it help me develop and interest for computer science but it also taught knew problem solving skills that I have been able to use in other subjects as well.
Sunday, 5 April 2015
Post 8
Looking back at my post on recursion, I now feel a lot more comfortable with more advanced minimax programs and recursion in general. I found actually that learning about trees really helped me visualize how recursion really worked. When performing algorithms even as simple as node count or leaf count, I was able to visualize the tree and mentally trace what was being returned in each of the methods. LinkedLists are still a little bit tricky for me even though they usually dont involve recursion. I think that the abstract nature of the wrapper class still makes it a little difficult to understand but I do feel like I am getting much better at them.
The new assignment was posted and it looks very challenging but enjoyable. Pruning seems to be the most challenging of the three methods. Memoization seems pretty straightforward; it simple involves creating a global variable and updating it as you return values in you recursion of the game. Myopia also seems pretty simple; instead only passing in game state, you also pass in the depth to which you wish to check the game. If the game is over before the depth is reached, return the games outcome and if the depth is reached before, simple return rough outcome. To check if the depth is reached, in your recursive call, return (state, depth -1) and include an elif after if game.over which checks if depth is zero and then returns rough outcome.
Looking back at my post on recursion, I now feel a lot more comfortable with more advanced minimax programs and recursion in general. I found actually that learning about trees really helped me visualize how recursion really worked. When performing algorithms even as simple as node count or leaf count, I was able to visualize the tree and mentally trace what was being returned in each of the methods. LinkedLists are still a little bit tricky for me even though they usually dont involve recursion. I think that the abstract nature of the wrapper class still makes it a little difficult to understand but I do feel like I am getting much better at them.
The new assignment was posted and it looks very challenging but enjoyable. Pruning seems to be the most challenging of the three methods. Memoization seems pretty straightforward; it simple involves creating a global variable and updating it as you return values in you recursion of the game. Myopia also seems pretty simple; instead only passing in game state, you also pass in the depth to which you wish to check the game. If the game is over before the depth is reached, return the games outcome and if the depth is reached before, simple return rough outcome. To check if the depth is reached, in your recursive call, return (state, depth -1) and include an elif after if game.over which checks if depth is zero and then returns rough outcome.
Saturday, 4 April 2015
Post 7
This was the second midterm exam week. The second midterm I felt was a lot better than the first one. The first question was quite simple, since it mainly involved simply traversing through a tree in pre-order format and make very simple Binary trees. The second question was also quite simple and was one where the aid sheet helped. I had the list_between method written down and the question asked for list_even_between which only required a minor adjustment to the original code. The last question was kind of tricky, since I was not completely comfortable with LinkedLists. Logically, my code made sense, however, the syntactic component was one I was not too comfortable with.
This week, we learned about unit testing and assertions. I forgot to talk about the assignment in the last post so I will mention it now. Completing this assignment was one of the best learning experiences I have had not only in this course but in all of first - year. Being able to understand an algorithm that seemed complex was extremely gratifying. The previous labs and large emphasis the course seemed to have on recursion was very helpful when coding the minimax algorithm. This weeks assertions and unit testing unit was mainly focussed on the assignment. Diane showed us her version of minimax and ran it through some unit tests to see if it worked for a few cases. She showed that there was a very small chance that the game would win all the cases randomly so if it passed the unit test, it was probably right. We also learned about what kinds of cases were best for the unit test. For example, in Subtract Squares, 3 would be a very bad case since there is only one possible move.
We also looked at assertions, which were useful tools in unit testing. The user could assert a statement, using the proper syntax of course, and the program would raise an error if the assertion wasn't True.
This was the second midterm exam week. The second midterm I felt was a lot better than the first one. The first question was quite simple, since it mainly involved simply traversing through a tree in pre-order format and make very simple Binary trees. The second question was also quite simple and was one where the aid sheet helped. I had the list_between method written down and the question asked for list_even_between which only required a minor adjustment to the original code. The last question was kind of tricky, since I was not completely comfortable with LinkedLists. Logically, my code made sense, however, the syntactic component was one I was not too comfortable with.
This week, we learned about unit testing and assertions. I forgot to talk about the assignment in the last post so I will mention it now. Completing this assignment was one of the best learning experiences I have had not only in this course but in all of first - year. Being able to understand an algorithm that seemed complex was extremely gratifying. The previous labs and large emphasis the course seemed to have on recursion was very helpful when coding the minimax algorithm. This weeks assertions and unit testing unit was mainly focussed on the assignment. Diane showed us her version of minimax and ran it through some unit tests to see if it worked for a few cases. She showed that there was a very small chance that the game would win all the cases randomly so if it passed the unit test, it was probably right. We also learned about what kinds of cases were best for the unit test. For example, in Subtract Squares, 3 would be a very bad case since there is only one possible move.
We also looked at assertions, which were useful tools in unit testing. The user could assert a statement, using the proper syntax of course, and the program would raise an error if the assertion wasn't True.
Post 6
This week we learned about Linked lists, which at first didn't seem useful. It seemed to be easier to just have a regular list. However, some of the problems in the lab made it clear that LinkedLists could be useful. For example, if you want to store an object in a specific place in the list and preserve the order, then you could not use a list. Also, if you wanted want to store the sum of two adjacent numbers in a list the in position of the first number, then you would need a LinkedList. The problems were quite tricky because the the sequence of LLNodes were stored in wrapper method called LinkedList. This was confusing since you had to be careful to make sure that each node pointed to the next correct node because the only thing stored in LinkedList was the start, the end and the size which meant the information of the nodes in the middle was inaccessible directly and you had to traverse through each node to find the one you were looking for. Sometimes you would want to change a Node before a certain node you were looking for, in which case you would traverse through the list using two variables, with one lagging behind the other. Once the first variable found the correct Node, the second one could alter the value of the previous node.
This week we learned about Linked lists, which at first didn't seem useful. It seemed to be easier to just have a regular list. However, some of the problems in the lab made it clear that LinkedLists could be useful. For example, if you want to store an object in a specific place in the list and preserve the order, then you could not use a list. Also, if you wanted want to store the sum of two adjacent numbers in a list the in position of the first number, then you would need a LinkedList. The problems were quite tricky because the the sequence of LLNodes were stored in wrapper method called LinkedList. This was confusing since you had to be careful to make sure that each node pointed to the next correct node because the only thing stored in LinkedList was the start, the end and the size which meant the information of the nodes in the middle was inaccessible directly and you had to traverse through each node to find the one you were looking for. Sometimes you would want to change a Node before a certain node you were looking for, in which case you would traverse through the list using two variables, with one lagging behind the other. Once the first variable found the correct Node, the second one could alter the value of the previous node.
Post 5
Note: Please mark my object-oriented programming post.
This week we talked about binary search trees. At first I was confused as to why the distinction between regular trees and binary trees was being made but considering the advantages of having a binary search tree, it became a lot clearer. Binary search trees organize data in a such a way that for any node, all the nodes in the left child are less than the value of the node and all of the nodes in the right child are greater than the node value. When first doing the lab, I found that the algorithms did not work if you only considered the left child to be less than the node and the right child to be greater. However, I learned that you must consider that all the nodes the left tree and all the nodes of the right tree must follow this rule in order for search-related algorithms to actually be efficient. Otherwise, you would still have to look through every node.
During the lab, I found surprisingly that the BTNode problems were than the tree problems. I think that since children have None values, it made it harder during the base cases for the recursion algorithms. The regular trees were easier in this regard because the nodes with no children would have an empty list as the next node instead of two None values. You also had to check each of the left and right nodes separately since they were stored in different parameters whereas in a regular tree, there was only one parameter in the object for children.
We also learned about Pre Order, Post Order and In order listing of trees which was not too difficult to learn and understand.
Post 4
Object Oriented Programming, as I mentioned in an earlier post, brought a lot of sense to programming for me. It explained how things like strings and lists actually worked and it helped understand how a programming worked in things like games and simulations.
Object Oriented programming allows you to define a certain 'object' and give it the parameters you wish and methods that help you manipulate said parameters as well define interactions with other objects. For example, the Subtract Square class allowed us to define a subtract square game, which had parameters for the score and the players. It also had methods that allowed us to alter the game state, determine possible moves, determine whether the game was over etc.
Some of the necessary methods included the __init__ method, which would initialize the parameters of the object when it was created by the user. the methods __str__, __repr__ and __eq__ overrode the existing string, repr and eq methods so that the object could be printed, repr could be used and '=' could be used to determine equivalence. These method were not used often but were important to avoid errors and were methods that were necessary to any object,
The idea of overriding is closely related to Inheritance, which is a way to efficiently create objects that were closely related to other objects. For Subtract Square, we first made a general Game class that had parameters and methods that were relevant to any game in general. Subtract Square inherited the game class and overrode some of the methods (e.g. __str__, __eq__ etc.) to make the code more specific to the game. However, by inheriting, we saved a lot of code and made the program more efficient and more organized.
Thursday, 2 April 2015
Post 3
This week, we began the recursion unit of the course, a unit that I was very much looking forward to. This was a topic that I found difficult to comprehend when learning about it in high school and I was looking forward to learning about it in a way that would allow me to effectively implement it in my progams. During the lab, I enjoyed tracing through each programs and found the activity to be the right balance of challenging but not frustrating. However, the final task, involving the creation of my own recursive method, was challenging. I did not complete the program during the lab time but I continued to work at it from home and I finally got it to work. The most effective way, I found, to approach designing a recursive method was to create cases starting with n = 1 and then creating more and more complicated cases and letting = 2 , 3 and so on, where n is the number of times the method would be called. I found that once I developed regular methods for the n = 4 cases and then comparing it to the previous ones, I was able to inductively generalize for all n and create a recursive program.
This week was also the week that we had to submit our assignments. I initially thought that the major parts of the assignment i.e. the classes and the subclasses for the game and strategy, would be the most difficult part, so I finished those parts early and left the rest of the work for later. However, when trying to bring all the parts together in the game_view class, I encountered a lot of problems when trying to get each part to cohesively work together. I learned that for the next assignment, I should plan how the overall program will work first and then design each part instead of working on the smaller parts first to avoid overlaps in methods and leaving information out that was needed
This week, we began the recursion unit of the course, a unit that I was very much looking forward to. This was a topic that I found difficult to comprehend when learning about it in high school and I was looking forward to learning about it in a way that would allow me to effectively implement it in my progams. During the lab, I enjoyed tracing through each programs and found the activity to be the right balance of challenging but not frustrating. However, the final task, involving the creation of my own recursive method, was challenging. I did not complete the program during the lab time but I continued to work at it from home and I finally got it to work. The most effective way, I found, to approach designing a recursive method was to create cases starting with n = 1 and then creating more and more complicated cases and letting = 2 , 3 and so on, where n is the number of times the method would be called. I found that once I developed regular methods for the n = 4 cases and then comparing it to the previous ones, I was able to inductively generalize for all n and create a recursive program.
This week was also the week that we had to submit our assignments. I initially thought that the major parts of the assignment i.e. the classes and the subclasses for the game and strategy, would be the most difficult part, so I finished those parts early and left the rest of the work for later. However, when trying to bring all the parts together in the game_view class, I encountered a lot of problems when trying to get each part to cohesively work together. I learned that for the next assignment, I should plan how the overall program will work first and then design each part instead of working on the smaller parts first to avoid overlaps in methods and leaving information out that was needed
Subscribe to:
Posts (Atom)