Welcome back everyone! Or should I say welcome back to myself considering I have been away from sometime. I apologize to those who were patiently anticipating another post of mine. The school semester seems to have this magical phenomenon that time suddenly moves twice -- NO FOUR TIMES AS FAST-- as it did in the begin of the semester. And with that being said I apologize for not attending to my audience!
I will discuss linked lists today. This is a common data structure that does use recursion. A linked list is made up of 'nodes'. Each 'node' contains a reference to the next node in the list; furthermore, it contains a unit of data called the 'cargo'. The reason why a linked list is considered recursive is because a linked list either contains an empty list, represented by NONE, or by yet again(COUGH COUGH RECURSION ALERT) a node that contains a cargo object and a reference to a linked list.
First we would need to create a node class that will have these two attributes (cargo, and next).
If we just made three nodes with three different cargos and kept next parameter NONE then we have a set of nodes that are not linked in any manner. To link one node to the next we have to specify that particular object instance's next parameter to refer to the next node we are wanting to refer.
I will leave it at this note, as it sets the stage for the recursion part of linked lists. I will review those parts later tonight. I promise this time hahaha :)
Stay lazy!
SLOG
Wednesday, 1 April 2015
Monday, 9 March 2015
Week 7: MINI - MAX
Hey everyone,
Like I said in my lasts Slog, I will discuss minimax!
"Wow"... That is the expression I would use to describe minimax. The purpose of minimax is to find the best possible move for the computer to choose from when confronted with a certain game instance. The idea is that minimax will be called recursively till the game is over. At that point, one would be able to see who won and who lose and let that information be carried out of the recursive function. Depending on which move would produce a winning path, and which would produce a losing path, the computer would pick accordingly.
When I started working with Minimax, I believed that the recursive idea should be implemented not within the same definition function, but two that are constantly called upon one another till the base case (which is the game is over) is present. The first function is max which will determine that if the player at this certain gameinstance can make a move that will lead them to a gameinstance where the game is over. If the game is over who won. depending on who one +1 will be brought back if it is a winning score, a -1 if it is a losing store, and a zero if it is a draw. HOWEVER, if the new gameinstance does not produce a gamestate that is over, the mini function will be called. Likewise to max function this function will determine the exact same thing, but if the game instance that is produced is not a game over game state it will call on max function.
This recursive idea actually uses two functions that call each other recursively. I did have issues of keeping score because its so difficult to this that far ahead. However, some pen and paper does always help.
Overall, I do believe starter codes provided encourage the right ideas to be generated when working on these projects. Rather than diverting from the main ideas, the starter code provides an insight on how the problem should be approached.
Thank you again everyone!
Will make a few more slog's later tonight.
Hope for positive feedback,
Boris
Like I said in my lasts Slog, I will discuss minimax!
"Wow"... That is the expression I would use to describe minimax. The purpose of minimax is to find the best possible move for the computer to choose from when confronted with a certain game instance. The idea is that minimax will be called recursively till the game is over. At that point, one would be able to see who won and who lose and let that information be carried out of the recursive function. Depending on which move would produce a winning path, and which would produce a losing path, the computer would pick accordingly.
When I started working with Minimax, I believed that the recursive idea should be implemented not within the same definition function, but two that are constantly called upon one another till the base case (which is the game is over) is present. The first function is max which will determine that if the player at this certain gameinstance can make a move that will lead them to a gameinstance where the game is over. If the game is over who won. depending on who one +1 will be brought back if it is a winning score, a -1 if it is a losing store, and a zero if it is a draw. HOWEVER, if the new gameinstance does not produce a gamestate that is over, the mini function will be called. Likewise to max function this function will determine the exact same thing, but if the game instance that is produced is not a game over game state it will call on max function.
This recursive idea actually uses two functions that call each other recursively. I did have issues of keeping score because its so difficult to this that far ahead. However, some pen and paper does always help.
Overall, I do believe starter codes provided encourage the right ideas to be generated when working on these projects. Rather than diverting from the main ideas, the starter code provides an insight on how the problem should be approached.
Thank you again everyone!
Will make a few more slog's later tonight.
Hope for positive feedback,
Boris
Make up Slog for my Slacking
Hey everyone,
I want to start by apologizing for my absence. I know we computer scientist are lazy, but that is no excuse to not be posting! (We are lazy because we try to find the easiest way to do the hardest task) So here I am :)
I will talk about objects today. The recent why I want to talk about objects is because of my recent assignment. We worked with this "tippy" based game where the winner is whoever makes a "tippy" pattern in an n x n grid. How do objects intertwine with all of this? We had to do an object for a game instance where the status of that game is constantly being updated as the object it is. However, the interesting part was when I created a separate class for making moves within the game. I created a whole additional class that took a game instance as a parameter. I think I lacked this idea in my first assignment. With the help of the starter code provided in this assignment, I realized this idea of being able to manipulate these objects (gameinstances) using objects that take gameinstances as parameters.
But here is where I failed with the second assignment. I took the idea of making a class for making moves which takes a game instance, but I failed to do that for our minimax strategy. I should have better followed the instructions to see that this is what they were truly demanding when trying to apply minimax strategy. I will talk about my minimax experience in the following slog because that is a whole other ordeal.
If I was able to better understand that objects can easily take other objects as parameters, I would have been able to better fit the strategy into my game. That way I can just constantly update new gameinstance without accidentally creating a new game instance. The object at hand will be the only object that I will be working with.
Thank you,
your lazy computer scientist -- Boris :)
I want to start by apologizing for my absence. I know we computer scientist are lazy, but that is no excuse to not be posting! (We are lazy because we try to find the easiest way to do the hardest task) So here I am :)
I will talk about objects today. The recent why I want to talk about objects is because of my recent assignment. We worked with this "tippy" based game where the winner is whoever makes a "tippy" pattern in an n x n grid. How do objects intertwine with all of this? We had to do an object for a game instance where the status of that game is constantly being updated as the object it is. However, the interesting part was when I created a separate class for making moves within the game. I created a whole additional class that took a game instance as a parameter. I think I lacked this idea in my first assignment. With the help of the starter code provided in this assignment, I realized this idea of being able to manipulate these objects (gameinstances) using objects that take gameinstances as parameters.
But here is where I failed with the second assignment. I took the idea of making a class for making moves which takes a game instance, but I failed to do that for our minimax strategy. I should have better followed the instructions to see that this is what they were truly demanding when trying to apply minimax strategy. I will talk about my minimax experience in the following slog because that is a whole other ordeal.
If I was able to better understand that objects can easily take other objects as parameters, I would have been able to better fit the strategy into my game. That way I can just constantly update new gameinstance without accidentally creating a new game instance. The object at hand will be the only object that I will be working with.
Thank you,
your lazy computer scientist -- Boris :)
Sunday, 8 February 2015
Week 5 Recursion Continued
I think I mistakenly covered the wrong topic last week. I was suppose to write my impression of the first few weeks doing SLOGs but instead I spoke about recursion, which is technically this week's topic. So I will do what I had to do last week in this week, and I hope that what I did last week would suffice for this week's requirements.
If your refer to my first post, you will see that I stressed many times how this is my first attempt at anything close to blog. I realized I haven't gotten any feedback from other people. This may be because my writing is not interesting enough or no one is clicking on my url slog that is posted in the CSCA148 course website. Regardless, I feel that doing these SLOG's is helping me in many ways. First of all, it is allowing me to show my understanding, both to myself and to my TAs. Second of all, throughout the week, this course is a priority to me but other courses do take up my time. Having to do these SLOGs reminds my brain of all the work that I have done up to that point. This is kind of like a refresher. Lastly, I believe that these SLOGs allow me to see what my peers think, and if they experience similar concerns as I do. I sometimes look at their SLOGs to see how they overcame those issues.
With that being said , I would really like to give out a shoot out to: http://sarcasticgradientdescent.blogspot.ca/
This individual has some excellent work, and I usually look into his SLOG when I am having troubles understanding a certain topic. I highly encourage for whoever that is reading my blog to also check out his!
If your refer to my first post, you will see that I stressed many times how this is my first attempt at anything close to blog. I realized I haven't gotten any feedback from other people. This may be because my writing is not interesting enough or no one is clicking on my url slog that is posted in the CSCA148 course website. Regardless, I feel that doing these SLOG's is helping me in many ways. First of all, it is allowing me to show my understanding, both to myself and to my TAs. Second of all, throughout the week, this course is a priority to me but other courses do take up my time. Having to do these SLOGs reminds my brain of all the work that I have done up to that point. This is kind of like a refresher. Lastly, I believe that these SLOGs allow me to see what my peers think, and if they experience similar concerns as I do. I sometimes look at their SLOGs to see how they overcame those issues.
With that being said , I would really like to give out a shoot out to: http://sarcasticgradientdescent.blogspot.ca/
This individual has some excellent work, and I usually look into his SLOG when I am having troubles understanding a certain topic. I highly encourage for whoever that is reading my blog to also check out his!
Monday, 2 February 2015
Week 4: Recursion
This week's topic is going to be a continuation to lasts week's topic: Recursion. Last time I spoke about it I felt I was rushing the topic too much, but hopefully today I can elaborate on this matter. In the previous slog of mine, I tried to illustrate recursion through the an example where we had to gather all possible blood types for individuals across Canada. I will start by reexplaining the example and mentioning key terminology that I may have missed last time. Then I will talk about some things we covered in Week 4's lecture.
In the blood type example I tried to show a possible method, recursion, as a solution to a problem of determining what blood type everyone in Canada has. The idea is that we are dealt with a vast number of people, but each of these people are split into sub amounts of people in each province. Furthermore, we can yet again separate people by regions they live in within each single province in Canada. The pattern of taking the current problem and separating into similar problems, but smaller in size, is the idea of recursion. This circular method has to has a limit, or else we would go on forever. This limit is what we call a base case. In the previous example, I don't recall saying a base case. I think the base case in reality would be till we hit certain postal codes where we can send people to a near by school to register their blood type. It would be ideal that our base case would be the actual person, but there would be no affordable way to execute that in real life. Being that we are on a budget, as seen in the real world, I would determine that the base case would be the community surrounding the schools. From there the method would be forced to exit from its current recursive stage as it has hit the predetermined base case we placed in the function.
The preceding paragraph raised a couple concerns for me when I was writing, but I feel I should discuss them now. The professor also illustrated this concern which was what would happen if we never hit the base case. The answer seems pretty straight forward because it just implies the function will never exit itself. It will keep trying to keep converting the bigger problem into a smaller problem. An infinite loop that is missing a base case. I found the example Danny used with the turtles were very helpful.
I will write sooner next time, probably after the midterm. I will need to vent all my thoughts :P.
Have a goodnight everyone!
In the blood type example I tried to show a possible method, recursion, as a solution to a problem of determining what blood type everyone in Canada has. The idea is that we are dealt with a vast number of people, but each of these people are split into sub amounts of people in each province. Furthermore, we can yet again separate people by regions they live in within each single province in Canada. The pattern of taking the current problem and separating into similar problems, but smaller in size, is the idea of recursion. This circular method has to has a limit, or else we would go on forever. This limit is what we call a base case. In the previous example, I don't recall saying a base case. I think the base case in reality would be till we hit certain postal codes where we can send people to a near by school to register their blood type. It would be ideal that our base case would be the actual person, but there would be no affordable way to execute that in real life. Being that we are on a budget, as seen in the real world, I would determine that the base case would be the community surrounding the schools. From there the method would be forced to exit from its current recursive stage as it has hit the predetermined base case we placed in the function.
The preceding paragraph raised a couple concerns for me when I was writing, but I feel I should discuss them now. The professor also illustrated this concern which was what would happen if we never hit the base case. The answer seems pretty straight forward because it just implies the function will never exit itself. It will keep trying to keep converting the bigger problem into a smaller problem. An infinite loop that is missing a base case. I found the example Danny used with the turtles were very helpful.
I will write sooner next time, probably after the midterm. I will need to vent all my thoughts :P.
Have a goodnight everyone!
Thursday, 22 January 2015
SLOG WEEK 3: Why Geeks Should Write
I have never written any type of Blogs before,
yet alone Slogs, but I will attempt to my best ability. I will start with a few
stipulations for the reader. Firstly, criticize me all you want. Please ensure
the criticism is constructive to enable me to further improve any future Slogs.
Secondly, feel free to give me feedback on ideas or concepts I mention. Lastly,
I will attempt to tackle any concerns or questions you may have immediately or
on the following scheduled Slog. Thank you in advance.
I will begin by being honest. I
haven’t been enrolled in any computer science course since last winter. That is
almost a year with no computer science! Consequently, I had a lot of reviewing
to do. Unfortunately, I did not attend the ‘ramp-up’ sessions provided by my
TAs and professors. I knew that if I was to attend, I would be able to recall
many of the findings I already discovered in previous computer science courses.
However, life always get in your way of planned events, my absence from the
ramp-up session was one of those cases. Although I did not attend this helpful
session, I did manage to dedicate my own time to remembering and relearning the
fundamentals that I have had in the past. How am I doing so far? Good or Bad?
You will notice that I will take this Slog very seriously. When I attempt
things, I always try to attempt them to my fullest ability. So let’s begin
attempting this slog to the fullest ability by describing some issues I have
discovered right away with the direction of this course.
I find the professor, Danny
Heap, a very informative individual. However, I always find a particular
frustration, one that I have found in past computer science classes, which is
the material in class, lab, and most importantly assignments almost don’t line
up. I understand that in class we get the foundation. The lab we try to
elaborate on it. And finally, in the assignment we try to go above and beyond.
But my problem is that I do not see the follow chart from point A to point B to
point C. I understand that we are supposed
to build our own intuition of what to do next based on the resources we have.
But a little nudge in the right direction would not hurt, because it will
assist the understanding of the actual material. To elaborate, it will help
with the understanding of the key question “why” is it that we do this. Why do
we do that rather than this?
Anyways, that was maybe a little
venting done by me, but now let’s gets to the actual computer science part!
Objects are the main concern for the last two weeks. I did have a few
confusions initially regarding objects; however, it seems that now I have a
better understanding of them. I will try to explain those understandings. The
first confusion I had with objects is why do we define certain methods that
raise exceptions? Please refer to week 2 materials, more specifically the
shape.py, square.py, and triangle.py. If you refer to shape.py you see that it
has a draw function that raises an exception. This shape.py is a parent class
of a sub class of square and triangle. Furthermore, square and triangle class
have their own draw method. So my initial confusion was ‘why is it that we need
to even include a draw method in the parent class if we:
a) don’t inherit it in the sub-class, and
b) we override it using a new draw method in the sub-class
a) don’t inherit it in the sub-class, and
b) we override it using a new draw method in the sub-class
The short
but confusing answer is as follows:
The shape
class, which is our parent class, captures all possible methods that one would
like to do execute if they had a shape. For example, area would be a method
that is applicable to all types of shapes. However, the shape class, yet again
which is a parent class, does not capture which shape goes into it. It says
that yes all shapes can have an area calculate upon them; however, by raising
an exception we force the user to go to a sub-class, such as square or triangle,
to actually calculate the according area formula. Because imagine that we had a
shape class that does calculate area, then every time a new instance is created
the area method would also have to capture which shape its dealing and then
apply a different area calculation, BECAUSE NOT ALL SHAPES HAVE THE SAME AREA
FORMULA. Therefore, we force the user to go through a sub-class to calculate
area because the sub-class would have the right associated formula for that
shape. In conclusion, parent class tells
us what is possible; however, the child-class helps us to differentiate how to
execute this possibility depending on the child-class.
Not to brag, but a pretty good epiphany if you
ask me. Now I want to talk about a new idea that professor Heap barely
scratched the surface too – recursion. I think I get the idea of recursion, but
in order to demonstrate it I will write you an example of exactly when it
should be used and why. For starters recursion is used to take a big problem, separate
it into similar but smaller problems, repeat these steps till we have a the
most basic problem and execute that. While doing all that, we are literally
calling the function on itself to keep breaking it to smaller problems. Now for
my example, let’s assume that we want to know the bloodtype of everyone in the
Canada. Writing a function that would go through each individual and record it
is time consuming and most likely prone to error. So ah! Recursion must be able
to assist us! So we start with what our first problem is which is Canada. We
call a formula on it which sees if the inputted parameter is the most basic
one, record the blood type, if it is not the case that it is the most basic one
then call the same formula on it again. So Canada is the entered parameter, but
Canada is a list of provinces. So we call the formula again on each province.
Let us work with Ontario. The formula is called on Ontario, which is now our
entered parameter, and yet again we see that Ontario is a list of regions. The
same thing happens till we see that regions are a list of cities. We do this
till the very basic problem. I think that is the hardest part: identifying the
most basic problem. In our case it would be each person’s blood type. So getting
back to recursion we would be calling the function over and over again till it
hits our functions initial if statement which is if the unit is the most basic
record the blood type. So we would be going from countryà provincesà regionsà cities à…. à individuals. As soon as we hit
individual the function fulfills its purpose and exists that recursion formula
and goes to the outer one. So for example if the function keeps going till it
hits individuals and those individuals were in the city of Toronto for the
region gta, then it will go to missauga in the region of gta. Then it will
finish all the recursion problems in the GTA, and then it will exist central Ontario
region and go to another region to it has literarly finished everything and
recorded everything and existed to the point of Canada.
I know it is very confusing, it
is even more confusing to explain, but if you have a better way to word it
please feel to reply!
I think this it for me today. Need to focus on
something other than computer science… o how about philosophy courses – more specifically
logic courses…. O wait.. that is not much different from what I have been doing
so far! I want to mention this paper should display a perfect example of why
Geeks like me should code J Have an awesome day guys!
Subscribe to:
Posts (Atom)