10/23/07

Assembly and The "Remote"-Controlled Car

During the second semester at DigiPen, I, along with every other Freshman, took CS105. Professor Duba was a great teacher and he would always write in big letters and sometimes use smiley faces and evil bananas for variables. That trend of odd humor in lectures or homework would not end with just Duba. In this class we learned a bit more about basic circuitry, processors, analog to digital converters, memory, how to operate a basic PIC micro controller with assembly, etc. The final goal of this class was to transform an RC car into a self-driving unit.

We were each randomly assigned to five-person groups and had to complete weekly exercises that would expand our cars. At first, there were some basic steps like setting a port to be output and change the value on it to light up an LED. In later weeks we would be messing around with the speed controller for the motor and even the servo for turning the wheels. Each car came equipped with four sensors. Two long-range sensors pointed at 45 degrees to the left or right, and the other two were short-ranged and aimed directly in front of and behind the car. We had a lab to measure the voltage output of the sensors for different distances from them to an object. The next week we would try to convert the analog voltage to a digital value that would be stored in memory.

All of this was done by programming in Assembly and uploading the program to the PIC. If you do not know, Assembly is sort of an aggravating language to use. The programmer has to explicitly say line by line exactly how the PIC should operate. For instance, in C we have this code:

int a = 0;

In Assembly, it would be more like:

a EQU 0x20 ; establish that "a" is at address 0x20
MOVLW d'0' ; move the decimal value of 0 into the working register
MOVWF a ; move the value of the working register into the address of "a"

Even though this is a minor example of what goes on in assembly, just imagine all of normal C code expanded into multiple lines that just does simple things. We also had to deal with odd proprietary Assembly code for interrupts, mostly for waiting for the analog to digital conversions of the voltages of the sensors to be done.

The worst part about this class was that we could not choose our teammates. We could but it would reduce our final grade of the car by 10%. I was unfortunately stuck with a team with members that seemed to be unwilling to work on the project, other than myself. In fact, two of my other teammates on The Pirate-Ninja faced the same dilemma. For our car, the only other work that was actually done on the car was by the person who just discovered the amount of time for the acquisition of the analog voltage for the conversion and randomly placed certain function calls based on what I told him to do. Other than that, the rest of them just sat down next to me looking at the code while rarely saying anything. The problem was that they sat down with me at the last minute, and because they failed to learn ahead of time, they were not even able to help then. Multiple times I was face with explaining the code in great detail, but they did not use it to the team's advantage.

I had a hard time with false promises of being in the lab at the time stated or even at all. It was either 3 hours late due to a game team meeting or forgetting about it 45 minutes later and staying in the same room for 4 more hours (multiple times). We had a milestone due where the car was supposed to travel through a course on its own. I got the team my score of 90 out of 100. Starting a week before, I came in every day at 7:30 in the morning and usually left at 10:30-11:00 at night, working on it every minute I did not have class. Remember, at this time I did not live nearby and did not have a parking pass. I slept for about 5 hours a day, and I never felt like leaving DigiPen to go to my car and drive somewhere for dinner because that wasted time. I did this routine for a week. When classes were held in the lab I would be in the outside room right by the door. One of my teammates had promised to be there after classes on a Tuesday. He did not show up until about 6pm and did not see me earlier, even though I sat in front of that door with the car where he walked passed twice to go in and out of the room to take a math test.

On the Thursday before the milestone was due, all of them came into the room to work. I do not use the term bastards lightly. This was the one point in my life where I think I actually went a bit crazy. I started doing my usual meowing that I do before performing in a play. It has sort of become my way to express anxiety. I kept on doing it over and over, for over half an hour. Because I had been coding so much in Assembly, I started to think like Assembly. I had thoughts and ideas that I could not quite grasp in my head, so I brought up multiple windows of Notepad and started typing yes-or-no questions and answers, step by step. I used this to communicate to my teammates, whom I did not want to talk to but was sure were reading the screen somewhat intentively. I told them I was going on a 10 minute break to the 7/11 across the parking lot. I got the usual snacks, except I accidentally got peppered beef jerky. I hate the stuff. At certain points I had to plug my ears just to be able to think without all of the noises of the other groups of students huddled in small areas trying to accomplish the same thing. When taking out the car for testing in the halls, I was unable to remember anything. I told each of my teammates something to remember for the time it took to get back to the lab. Yet my efforts were useless; I had remembered everything.

A week later they promised to do the rest of the work on the car. They did not want me to touch the code anymore. I was fine with that. I e-mailed all of them the code and told them to study it. It was not until a week later when one of them actually wanted to look at it where I realized that I had failed to send it a week earlier. No one had told me of this mistake. I kept to their promise and did not touch a thing. I even outlined a list of tasks and what I thought was a reasonable schedule to complete our car. Just for the sake of helping them out in case they needed it, I spent many hours after my classes in the lab during the week that it was due. I did not do anything on the car, just worked on other classes. No one showed up until Thursday. The car was due Saturday. At this point the car had the basic functionality of moving around on its own, but so did every other car. Duba wanted each car to do something special.

Finally one of them, followed by another, came in and tried to work on the car. Unfortunately they had not studied the code and required me to walk them through it again. They were not able to do anything productive and ended up on the wrong track. Barely anything got accomplished. So I broke their promise and started programming the timer and got certain driving routines to be performed. While I worked, one of the teammates that showed up apparently decided that he was probably screwed on this project and started going through practice finals for CS105 and CS230. I would see him get up in the lab and walk around to various people asking them the answers to certain questions. My other teammates were working on their individual CS230 assignments in Pascal as I saw as I walked by from the snack machines. I worked all of Friday and even got to the school at 7:30am on Saturday. My other teammates could not do that early, reasonable reasons, church or sleep or something. Maybe a multitude of car accidents. Yet one of them was able to purchase Barbie dolls to place on the car because they were not able to do anything else. We had our final run graded by Duba, and it did not seem to do terribly great. The battery was fresh and it started banging into walls somewhat violently. One of my teammates seemed slightly frustrated. Did he have a basis for his anger? Probably not.

So I did not have such a hot time with my teammates. What did I learn? I am not going to take crap anymore. I was patient and tried to be helpful, but they did not seem to care too much. They did barely nothing while reaping most of the benefit and made me go crazy to a point where I had not gone before.

10/20/07

The Pirate-Ninja

During the first semester at DigiPen, we were told to form a group and start designing a game which we would create during our second semester. The only limitation: it had to be text-based and run from the Windows console. Erhardt had specifically stated no graphics. Unfortunately we took whatever he said way too literally and decided on making a text-based RPG like Zork. Later we realized that we could have made a side-scrolling shooter if we wanted too, we would have just needed to create all of the "graphics" from colorized cells and characters.

I nominated myself as the game designer. You see, we had to each pick a separate role (designer, producer, technical director, and product manager) and do certain things throughout the year. DigiPen's goal is to make each student shift through each of them throughout their years at the school. So I chose the role which I thought would be the easiest and least interesting. After finishing the design, none of the people I worked with want to ever create any game that has anything to deal with pirates, ninjas, robots, or zombies. The basic premise of our game was that there was a Pirate vs Ninja War and in the midst of it, a female ninja and male pirate mated to create a half-breed. This child was ridiculed all of his life, born with a peg leg and wearing clothes from both pirates and ninjas, and after turning 18 he would set out for vengeance against all of them. There also happened to be zombies and robots in the game just for the sake of hilarity.

We really should have thought of a different idea, because typing out the descriptions for every single cell that the player could possibly travel to was long and boring. I also disregarded the notion of creating a game that I would think would be fun to play; I am not that big of a fan of text RPGs. Along with the amount of work needed to be done, I procrastinated until about the first week of December to work on the maps (which needed to be fully planned out for the submission of the Game Design Document, a few weeks from then). It wasn't a pleasant combination.

The process of making the game was much more fun to do. I worked on the sound and battle system. It was basic and poorly structured, and overall our game had really ugly code. In my battle code, there was text formatting and display functions, and we called everything and performed certain tasks from within the parser. We didn't spend much time before programming to plan any decent layout of the "engine". Although we really weren't too sure about coding nice engines and game loops at that point. At least it worked in the end.