This week I wrapped up and submitted Assignment 2, where we designed a playable Tippy game state as well as a Minimax computer strategy. While the computer strategy took a while to figure out specifically, and I certainly drew an excessive amount of diagrams, it inevitably amounted to fairly basic recursion. Minimax turned out to be an interestingly powerful implementation of AI, as it not only attempted to win were possible but actively worked against our own victory even when it was impossible for the computer to win. Unfortunately, it took a full minute to decide on a move when starting a 3x3 game and a 4x4 game was downright impractical.
The next most interesting implementation during the game was on how to store the game state of the Tippy game being played. I opted to use a list-within-a-list model where each inner list represented a row in the same and each item in the list represented an item in that row. The problem I later discovered was that creating a new, altered game state retroactively changed the original game state, due to the mutable nature of lists. I ended up using 'deepcopy' to create an immutable copy of the game state, but I think it ended up demonstrating that a mutable data structure is not always ideal and a tuple may have served me more conveniently.
Other than that, I found that rendering the game state in a visually appealing format was the main novel problem of the assignment, which really came down to visual preference. I ended up using a coordinate system but I noticed many people used single numbers to refer to each individual spot on the grid which was a simpler but less intuitive solution, in my opinion. I don't have much else to talk about, in all honesty, so hopefully I'll have more interesting things to say next week and the TA strike will be over (yeah, right)!
CSC148H1F
Saturday, 7 March 2015
Saturday, 28 February 2015
Reconsidering Recursion - Week 7 (Mark this!)
I already wrote about my impressions on recursion, but I figured it has been given enough focus in class and labs to warrant another post. As I talked about earlier, I think that the reason recursion is initially unintuitive is because it feels like the problem you are solving is not precisely resolved by the code you write. What I mean is that, until now, the code we have written has been written to directly perform some function or solve some problem. With recursion, since the data structure being considered is typically arbitrary in nature (eg. a list with unknown depth, a tree with unknown branches and children), we are unable to know exactly what we are working with.
To deal with this, we define what we want the function to do when it reaches a base case, typically after the most simple object in the data structure has been reached (eg. working down a tree to get to a leaf, reaching the objects contained in a list of arbitrary depths). If we have not reached the base case yet, the function executes a different line of code, typically asking the function to recursively perform itself on objects within the original data structure. As long as the base case has not been reached, this code continues to execute.
Considering the approach listed above, it appears that the initially unintuitive nature of recursion is due to the fact that the solution is often simpler than the problem itself. Since the problem itself can be infinitely complex by human standards, it is typically counterproductive to consider the problem as a whole and instead think about how the problem is structured; what is the simplest case and how the problem can become more complex. Instead of directly telling the function how it is going to solve the problem, you are defining how the function will navigate the structure of the problem, since this structure can be extremely simple or infinitely convoluted.
Knowing this, the usefulness of recursion is even more apparent. It is a type of problem solving where considering the problem as a whole can be overwhelming and the structure itself is more important. You are not solving the problem per say, you are providing the function with an algorithm by which it will navigate and solve the problem. As we begin to consider slightly more complex recursive problems, like in assignment 2, I am sure an economic approach to coding will be more important than ever as increasingly large problems exponentially increase the amount of code that needs to be processed. Therefore, any attempts to make the code more efficient may lead to drastic differences in processing time as large problems are considered.
To deal with this, we define what we want the function to do when it reaches a base case, typically after the most simple object in the data structure has been reached (eg. working down a tree to get to a leaf, reaching the objects contained in a list of arbitrary depths). If we have not reached the base case yet, the function executes a different line of code, typically asking the function to recursively perform itself on objects within the original data structure. As long as the base case has not been reached, this code continues to execute.
Considering the approach listed above, it appears that the initially unintuitive nature of recursion is due to the fact that the solution is often simpler than the problem itself. Since the problem itself can be infinitely complex by human standards, it is typically counterproductive to consider the problem as a whole and instead think about how the problem is structured; what is the simplest case and how the problem can become more complex. Instead of directly telling the function how it is going to solve the problem, you are defining how the function will navigate the structure of the problem, since this structure can be extremely simple or infinitely convoluted.
Knowing this, the usefulness of recursion is even more apparent. It is a type of problem solving where considering the problem as a whole can be overwhelming and the structure itself is more important. You are not solving the problem per say, you are providing the function with an algorithm by which it will navigate and solve the problem. As we begin to consider slightly more complex recursive problems, like in assignment 2, I am sure an economic approach to coding will be more important than ever as increasingly large problems exponentially increase the amount of code that needs to be processed. Therefore, any attempts to make the code more efficient may lead to drastic differences in processing time as large problems are considered.
Monday, 16 February 2015
Object-Oriented Programming
Being my first programming language, I initially did not have that great of an understanding of what it means to be an object oriented language. Of course, I understand the concept of objects becoming tangible instances of the abstract classes and functions we write and how these can be stores as variables to store or manipulate data (probably wrong on a technical level, but it makes sense to me for now).
However, recently out of boredom I decided to look into the process of designing an app for iOS. I'm not sure if I'll ever design one. I was just curious. To my surprise, Apple's new programming language (related to Objective-C, if I remember correctly), Swift, is already entirely intuitive to me. There are a few different conventions, such as declaring variables by prefacing the new variable name with "var" and I'm sure there are many concepts unique to app or program development that I have no conception of yet. But everything I learned about defining functions, classes, methods (including special methods), heritability, and so on translated effortlessly. What took me a full half course and part of CSC148 to learn in Python took me an hour to learn in Swift. Even though I lack the truly intuitive understanding of OOP and its relationship to other styles of programming, it's clear to me now that the concepts that make it up are easily transferable between languages.
The prompt this week is particularly vague and I think I lack the perspective of being fluent in non-OOP languages to really appreciate the concepts of OOP. However, it seems like, in a nutshell, the idea of OOP is to create robust 'structures' (or objects) such as functions, classes, and methods, to be as diverse and useful as possible for a variety of scenarios. When specific problems are needed to be solved, concepts such as heritability allow us to focus in on these situations without losing the more broad schematic (basically, superclasses and subclasses). This sort or preparation on what to keep abstract and what to define later one is very interesting to me and I can imagine it being all the more important as our assignments and problem solving becomes more complex and larger in scale.
However, recently out of boredom I decided to look into the process of designing an app for iOS. I'm not sure if I'll ever design one. I was just curious. To my surprise, Apple's new programming language (related to Objective-C, if I remember correctly), Swift, is already entirely intuitive to me. There are a few different conventions, such as declaring variables by prefacing the new variable name with "var" and I'm sure there are many concepts unique to app or program development that I have no conception of yet. But everything I learned about defining functions, classes, methods (including special methods), heritability, and so on translated effortlessly. What took me a full half course and part of CSC148 to learn in Python took me an hour to learn in Swift. Even though I lack the truly intuitive understanding of OOP and its relationship to other styles of programming, it's clear to me now that the concepts that make it up are easily transferable between languages.
The prompt this week is particularly vague and I think I lack the perspective of being fluent in non-OOP languages to really appreciate the concepts of OOP. However, it seems like, in a nutshell, the idea of OOP is to create robust 'structures' (or objects) such as functions, classes, and methods, to be as diverse and useful as possible for a variety of scenarios. When specific problems are needed to be solved, concepts such as heritability allow us to focus in on these situations without losing the more broad schematic (basically, superclasses and subclasses). This sort or preparation on what to keep abstract and what to define later one is very interesting to me and I can imagine it being all the more important as our assignments and problem solving becomes more complex and larger in scale.
Saturday, 7 February 2015
Impressions on Recursion
I think the problem of counting the elements of a list, which are organized in varying depths, is an interesting one because it is a very simplistic problem with a very, initially, unintuitive solution. Up until now, we've been programming for very consistent and concrete parameters, so being faced with a problem involving arbitrary parameters (and I mean the depth of the list argument, not function parameters necessarily) is kind of frightening as it's not immediately clear how to approach it.
Luckily, more intelligent minds have done the work for us and thus we learned recursion. Now, different problems still require fairly differing solutions so it is not exactly a plug-in-the-numbers solution (and I assume recursion will be used for much more complex tasks). But the idea of calling a function on itself seems like cheating or rule-breaking or outside of most people's consideration. So being introduced to a new way of thinking about how functions interact was quite intriguing (and partially terrifying, thinking of the complex problems to come).
Like most logical solutions, it makes sense once you see it written down and tracing, though still confusing at first, is easy enough if you tackle it one item at a time. It'll be interesting to see what happens once we are asked to create our own, novel recursive solutions...
I think the problem of counting the elements of a list, which are organized in varying depths, is an interesting one because it is a very simplistic problem with a very, initially, unintuitive solution. Up until now, we've been programming for very consistent and concrete parameters, so being faced with a problem involving arbitrary parameters (and I mean the depth of the list argument, not function parameters necessarily) is kind of frightening as it's not immediately clear how to approach it.
Luckily, more intelligent minds have done the work for us and thus we learned recursion. Now, different problems still require fairly differing solutions so it is not exactly a plug-in-the-numbers solution (and I assume recursion will be used for much more complex tasks). But the idea of calling a function on itself seems like cheating or rule-breaking or outside of most people's consideration. So being introduced to a new way of thinking about how functions interact was quite intriguing (and partially terrifying, thinking of the complex problems to come).
Like most logical solutions, it makes sense once you see it written down and tracing, though still confusing at first, is easy enough if you tackle it one item at a time. It'll be interesting to see what happens once we are asked to create our own, novel recursive solutions...
My First Few Weeks
First of all, I haven't been posting on schedule. I don't really have an excuse for that other than being busy and it slipping my mind but hopefully this will make up for it and I'll keep on schedule from now on.
As the first term test approached, I realized something. I didn't really have any notes to go through. In CSC108, I created notes for every video, referenced them, studied them, etc. In CSC148, during class, I mainly just payed attention in class and played around in Wing101 to see if I understood it. So instead, I went through the past labs and skimmed through the class slides. That's it.
Now this isn't because I was lazy or Winging (hah) the test. My point is that 108 was very focused on teaching us all of the basic concepts of the course. Methods, classes, importing, loops, operators, etc. In 148, we are still using the same tools. What we've been doing in class is just learning how to apply it in novel, interesting ways and that's what I have enjoyed about this course thus far. In a few weeks, we've used classes to create an entire game, thinking about the concept about abstract classes and which classes should draw information from which and how to leave room for further addition of games.
While it's not wildly more advanced than what we did at the end of 108, it has really helped me realize exactly how these tools are implemented in more practical, large scale projects (not that our assignment was large, but the concepts of creating abstract classes for example). Luckily, I've been keeping up with the material and felt very comfortable with the assignment (although the jury's still out, I don't have my mark back yet haha). I guess what I'm saying is: I realized that 148 teaches you, in some ways, how to think using the tools we've already learned and by the time, the test came around, I already felt confident with most of the material we've discussed until that point.
First of all, I haven't been posting on schedule. I don't really have an excuse for that other than being busy and it slipping my mind but hopefully this will make up for it and I'll keep on schedule from now on.
As the first term test approached, I realized something. I didn't really have any notes to go through. In CSC108, I created notes for every video, referenced them, studied them, etc. In CSC148, during class, I mainly just payed attention in class and played around in Wing101 to see if I understood it. So instead, I went through the past labs and skimmed through the class slides. That's it.
Now this isn't because I was lazy or Winging (hah) the test. My point is that 108 was very focused on teaching us all of the basic concepts of the course. Methods, classes, importing, loops, operators, etc. In 148, we are still using the same tools. What we've been doing in class is just learning how to apply it in novel, interesting ways and that's what I have enjoyed about this course thus far. In a few weeks, we've used classes to create an entire game, thinking about the concept about abstract classes and which classes should draw information from which and how to leave room for further addition of games.
While it's not wildly more advanced than what we did at the end of 108, it has really helped me realize exactly how these tools are implemented in more practical, large scale projects (not that our assignment was large, but the concepts of creating abstract classes for example). Luckily, I've been keeping up with the material and felt very comfortable with the assignment (although the jury's still out, I don't have my mark back yet haha). I guess what I'm saying is: I realized that 148 teaches you, in some ways, how to think using the tools we've already learned and by the time, the test came around, I already felt confident with most of the material we've discussed until that point.
Wednesday, 21 January 2015
Why Should Geeks Write?
I'm a Physiology student taking computer courses out of curiosity. I just finished my first programming course, CSC108, so I must know what I'm talking about. Regardless, I tend to consider myself a geek, being fascinated with learning as much as possible about how things work in a technical boring way that ordinary people could not care less about. As a kid I remember using a program called Gamemaker to code and program basic games. Sure I could have just continued playing games like most (and I try not to be pretentious in using that term) kids do but I enjoyed the challenge of reproducing mechanics familiar to me and than seeing if I could do anything new with them. I always remember coding seeming like an indecipherable, alien language and it was only through explanations online of various basic functions that allowed me to understand how I could use specific pieces of coding to accomplish basic tasks.
I think that everyone approaches programming with their own distinct style of problem-solving, sometimes yielding effective, ineffective, or even novel ways of tackling a problem. During the first assignment of CSC108, I remember discussing the results of the assignment with someone else and comparing how we tackled our problems. Even for very basic functions, this other person's approach seemed almost nonsensical or confusing when compared to my own clearly self-intuitive approach. Even for basic data structure representations, it can be very difficult to read someone else's code since it represents not only their solution but their own unique way of organizing and dealing with problems. Even the comments can be unhelpful since people tend to overestimate the clarity of their own thought processes.
I guess I'm trying to arrive at the point (somewhat verbosely, I am not used to blogging about myself or opinions and feel particularly out of my element) is that language is an important tool in communicating with others. In my own experience, this has been either useful or frustrating when trying to learn new programming methods or trying to understand someone else's code. Especially since programmers tend to be very focused or internally involved, I think they are particularly vulnerable in forgetting about how others perceive their logical processes. Communication is an important tool, especially since programming is often a collaborative effort where people use complex, abstract languages to represent their own problem-solving. No matter how thoroughly ingrained one is in the sciences, maths, programming, or other rational/logical subjects, it is always important to keep reading and writing to ensure that your own solutions and contributions can be communicated effectively and that you can effectively understand what advice/solutions others have for you.
I'm a Physiology student taking computer courses out of curiosity. I just finished my first programming course, CSC108, so I must know what I'm talking about. Regardless, I tend to consider myself a geek, being fascinated with learning as much as possible about how things work in a technical boring way that ordinary people could not care less about. As a kid I remember using a program called Gamemaker to code and program basic games. Sure I could have just continued playing games like most (and I try not to be pretentious in using that term) kids do but I enjoyed the challenge of reproducing mechanics familiar to me and than seeing if I could do anything new with them. I always remember coding seeming like an indecipherable, alien language and it was only through explanations online of various basic functions that allowed me to understand how I could use specific pieces of coding to accomplish basic tasks.
I think that everyone approaches programming with their own distinct style of problem-solving, sometimes yielding effective, ineffective, or even novel ways of tackling a problem. During the first assignment of CSC108, I remember discussing the results of the assignment with someone else and comparing how we tackled our problems. Even for very basic functions, this other person's approach seemed almost nonsensical or confusing when compared to my own clearly self-intuitive approach. Even for basic data structure representations, it can be very difficult to read someone else's code since it represents not only their solution but their own unique way of organizing and dealing with problems. Even the comments can be unhelpful since people tend to overestimate the clarity of their own thought processes.
I guess I'm trying to arrive at the point (somewhat verbosely, I am not used to blogging about myself or opinions and feel particularly out of my element) is that language is an important tool in communicating with others. In my own experience, this has been either useful or frustrating when trying to learn new programming methods or trying to understand someone else's code. Especially since programmers tend to be very focused or internally involved, I think they are particularly vulnerable in forgetting about how others perceive their logical processes. Communication is an important tool, especially since programming is often a collaborative effort where people use complex, abstract languages to represent their own problem-solving. No matter how thoroughly ingrained one is in the sciences, maths, programming, or other rational/logical subjects, it is always important to keep reading and writing to ensure that your own solutions and contributions can be communicated effectively and that you can effectively understand what advice/solutions others have for you.
Subscribe to:
Posts (Atom)