Sunday, 8 February 2015

SLOG #3: Thoughts about Random

Hey all, back for round three. Nothing especially groudbreaking this week, and a course test that took place a few days ago went along without a hitch for most everyone I've heard.

I have been thinking back to assignment 1 lately, but more specifically the generating random numbers element of the code. For example lets look at this:

>>> game_range = 10
>>> x = int(random.uniform(1, game_range + 1))
>>> x
9

Generating random numbers is an essential computer task, especially for cRPG's and other chance based games, but how does it work in regards to computers? From my basic knowledge of how computer's work deep deep deep down, how does one generate a completely random number?

Apparently they didn't use to. In my curiousity about the history of video games I've learned a tiny bit (no pun intended) about the way older computers worked. The interest in "random"-ness began by watching the video form of a thesis written by a certain Dr. Tom Murphy. He'd written a program, a very simple one, that played Nintendo Entertainment System games. No specific parameters for each game either. It was universal and, in this day and age, not too taxing of a program to run, all based around the potential increase in numbers always going on inside the NES.

Video version of Dr. Murphy's explaination available here: https://www.youtube.com/watch?v=xOCurBYI_gY
The actual paper: http://www.cs.cmu.edu/~tom7/mario/mario.pdf


In one of the uploaded videos of the program in action, it remarkably manipulated games with "random" power-up drops via button presses to make sure the power-up that gave the program the most points was always dropped by certain enemies. Always! The program was able to do this because one of its functions was simulating the future effect of a potential button presses or movements for each and every frame of the game. This doesn't explain how it managed to get the exact power up it wanted every time from a supposedly "random" drop though!

Turns out, to simulate "randomness" the NES actually takes things like player input and button presses into the equation. The users, playing away on the NES controllers, were providing some of the "randomness" for many of these games! To makes sure 1 of 6 power-ups dropped each time though, you'd have to be a computer program like Dr. Murphy's. I found this mind blowing.

I guess I just wanted to share how cool I found that video and computing idea. Still working out how exactly we accomplish "random" in computer and games nowadays though, but cheers and hope I find out in the future!
ES


Sunday, 1 February 2015

SLOG #2: Classes and classes

Hello again!

This still isn't too technical of a post (I'll likely get more technical very soon) but I'd just like to cement what the difference in learning from CSC108 and CSC148 has been like for me so far. As far as Object Oriented Programming goes, the class and subclass expectations are much more in keeping with the world of actual programs and so on. For the most part it's a fairly simple concept making a lot more sense than beginner programming, which involved uber-specific programming implementation.

Assignment 1 is a good example of this change.

Wheras essentially just the final assignment of CSC108 was about multiple class/file design, 148's first assignment has involved ADT (Abstract Data Types) from the get-go and offered vast leniency on how precisely the job was to be completed. This makes the project harder and easier to complete at the same time, because now as a coder there is room for your own personal discretion but also a lack of hand-holding that the simplicity and specificity previous code projects had to make themselves less challenging. Both of these changes are good. It makes the work more satisfying.
Here's an example of what I mean:

Let's say you have a scrambled Rubik's cube, and a guide for unscrambling Rubik's cubes.

Scenario 1: The guide has the exact movements for each possible scrambling (it's a stupidly big book) and following the steps for the scrambled cube results in your Rubik's cube being solved.
Scenario 2: The guide explains the methods by which a Rubik's cube is solved, by offering information that applies to all possible or most common issues in solving the cube.

Which scenario is more satisfying? Definitely scenario 2.

Following instructions can be fun, e. g. a Lego instruction booklet, but when faced with a challenge it is more enjoyable to see yourself understanding and actually learning how to approach different parts of the problem to solve it based on knowledge, experience and savvy. e.g. being able to solve a Rubik's cube and so on. I guess what I really wanted to do here is share why I'm enjoying and pursuing Computer Science. Once you learn something in this subject it is execptionally enjoyable to implement and usilise it on other problems, precisely for the reasons I've stated above.

Cheers,
ES