The Hunger Games is an action/adventure film set in a dystopia.

It’s premise is fairly straightforward: a boy and a girl are chosen from each of the twelve districts participate in a fight to the death. The lone survivor is handsomely rewarded and allowed to return to their home district. Katniss Everdeen is a strong self-reliant girl from a coal-mining district with an eye for the arrow. In a moment that reveals much of her character, she volunteers to go in place of her little sister, who happens to be picked at the lottery. What follows is her brief training and the actual Games.

One thing to look for in any dystopia is social and political commentary. It’s hard to ascertain how much the creators intended to put in the movie, but I could see tons. The contrast between the squalid lives of the worker distict of Katniss and the magestic, clean, rich, and advanced capital is stark. While Katniss hunts squirrels, the denizens of the capital consume lavish feasts. They resemble eighteenth-century French courtesans in their flamboyant costume and deference to social norms. Opposingly, the people of the districts wear Puritanically plain dresses. The rich spectate and bet on the games. The poor root for the survival of their own. A game versus survival. The contrast is stark and obvious and an starkly obvious commentary of inequity of all forms. The reaction of the characters in the movie to this contrast is not explored, however.

A fight to the death is an apt way to explore the human condition. But, I found the film largely side-stepped the opportunities it had. An us-versus-them survival story is just Hollywood dribble. Much more interesting is how a normal person changes in visceral fight for survival. There weren’t any changes in the character to note. A pure-hearted girl unchanged by a fight to the death? A tad banal. And none of the decisions made by the protagonist were tough and so, they carried no weight. Where is the internal struggle? What choices she does make fall flat. There was just a little bit of the movie when I felt the terror that must surely visit a movie where teens are slaughtering each other. But, most of the movie felt like a typical good-guy-bad-guy movie.  Characters are largely colored black and white. Where’s the nuance?

My objections aside, it is a thoroughly enjoyable film. The costume and set design are visually splendid. The camera’s capture is especially well done. I found the pace just right; others may find it too slow.

Though it’s potential isn’t fully realized, The Hunger Games is a must-watch.

The Friday before last, I had my wisdom teeth removed. Let me document the trials that I had to go through.

A few years ago, the dentist mentioned that I might have to get my wisdom teeth removed sometime in the future. So when I went to India two years ago, I was taken to the dentist. It’s a lot cheaper there, of course. The old guy almost went into a coma. My dad asked him to see if he could extract my teeth, but  to his professional horror, he found no signs of my teeth even emerging from their slumber.

I went to get my teeth examined at the beginning of the summer and my dentist voiced his opinion. My teeth were trolling me. The bottom two were almost horizontal, somewhat like battering rams waiting to break down the enamel of my molars. The top two looked benign, but they would supposedly graze against my gums and cause problems later. A friend of mine is having trouble with a similar prophecy about the grazing coming to fruition.

I had an initial checkup a few weeks ago and originally had the surgery scheduled for that Friday. However, it conflicted with Intern Day at my internship. No way I was going to miss that. I rescheduled for two weeks later.

They prescribe a three types of medicine, including a voluntary-use painkiller, and some non-Listerine mouth wash. I had to start the regimen the night before. I think I missed taking a pill for reducing anxiety or something. No biggie though. I was excited about the surgery.

They laid me on one of those long chairs and IVed me some electrolytes. Then, they switched to the anesthetic. I wondered how long it would take for it to act. That’s the last thing I remember. Next thing, I’m in the recovery room, dazed and confused. I felt a certain puffiness in my mouth but couldn’t feel anything. The nurse kept asking me if I needed to stay for a few more minutes. When I finally felt the courtesy to leave, I walked to the car. I was helped by the nurse, of course. Falling down and breaking my teeth would be counterproductive. The whole procedure took a little more than an hour. I had no clue what happened during that time. Others say they were awake while their teeth were being pulled out. That would be one of the weirdest hours of your life.

I came home and lay on the bed for four hours. Every half an hour, I changed the gauze that was stuck in the raw sockets. For the first hour or two, I couldn’t feel anything in my mouth. Then the pain rose and fell like a perverse sine wave. Blood was just waiting to gush out. I finally got fed up with gauze, went downstairs, and played video games for the rest of the night. I surely deserved it.

I ate soft stuff like bananas for the next day or two. Then, I started eating regular food. I wasn’t obeying the diet restrictions strictly. Even after a week, it is still sore. Chewing with my molars has become more tolerable. I’d say I’ll be back to normal in a few weeks.

I wouldn’t recommend the experience, to be honest. There is a lot of pain and blood. I would have thought the bleeding would have been less with modern medicine. At least my gums will thank me.

I’ve been keeping a diary since the first day of 2006. I don’t quite remember what urged me to do so, but I can guess it must be something along the lines of wanting to preserve the events of my life. You look back into the past and see a fog. You do remember some events, but they are faded images in a haze. Keeping a diary is a way to put down a shadow of each day’s experience for future reflection.

I find it difficult to fully capture a day in an entry.  I often forget what exactly I did at a certain time during the day. I’m often too tired to want to write lengthy, detailed entries when I’m about to go to sleep so many of my entries don’t fully reflect my thoughts at the moment.

My diary is mostly a chronology. I write down what I did that day, with some pithy remarks expressing my opinion of them. For a while, I wrote as if the whole world was one day going to read my entries. Eventually, I started writing more personal things; I certainly wouldn’t want someone reading it now. Still, most entries are unremarkable. Once in a while, I go on an introspective tirade, usually after a significant event. I usually don’t pay attention to writing in complete sentences. I just put down what comes to my mind.

Until a year ago, I wrote on physical diaries. The shapes varied: I had a small fat one, a decently sized one, and a long thin one. The first two diaries had sections for each date of the year. This is a bad idea. You waste space when you write a short entry and are cramped for space when you have something long to put down. The third diary I had was essentially a hardbound notebook. I could take as much or as little space as I needed. I ended up keeping that diary past its one year, actually up until July of the next year.

Last July, I got a laptop for college and decided to move my entries to the digital world. It has been almost exactly one year since I’ve started writing in a Word file named Diary.docx. Every day, I just append the date, the entry itself, and the time at which I’ve finished writing. (I’ve put down the time of completion for several years. One day I’d like to compile them to see my sleep trends over time. A digital diary makes this easier, of course.) A digital diary makes is simple to search for when you started interacting with a certain person or to go back to a certain entry. Just make sure to back up the file.

Over the course of the past 365 days, I’ve written 60,251 words spanning 86 pages, single-spaced. That’s an average of just 165 words an entry. That’s probably because there were several weeks last semester when I neglected the endeavor. I’ve gone only a few long stretches without keeping up, the biggest one being a summer trip to India. It would have been great to keep those memories, but it was just hard to write when traveling. Each missed day makes it harder to write following entries.

I admit, it was hard to keep the habit in the beginning. You feel like you lose some freedom – the freedom to fall on the bed whenever you feel like it. But you gain a record of your past. It helps you hold on to your memories.

Sometimes when I’m bored, I go to TED. It’s as good of a way to pass time as there ever was. Each video offers you a chance to hear someone accomplished say something insightful. I came upon this video one day.

Each TED video can be distilled into a central insight. This video gave me the idea that you don’t have to be fully vegetarian or fully omnivorous. The speaker in the video, Graham Hill, suggests that we can be vegetarian part of the time: on the weekdays to be specific. I decided to try it out when I got to college. I’ve been wanting to have a healthier diet for a while, but I didn’t really have much choice in high school. Now, when people get to college, it usually goes the other way: they gain the freshman fifteen. I wanted to do the opposite: become healthier than ever. (A side note: studies show that freshmen usually gain no more than three or four pounds.)

Why exactly did I want to do this? At home, I didn’t eat meat very often. However, I knew that I’d have access to it all day, everyday in the college cafeterias. Eating grilled, fried, or baked meat every meal is not as healthy as eating it at a more moderate level; this fact is common knowledge. Reducing meat intake by 5/7ths means that you reduce your the bad stuff that comes along with it by that much. You even (indirectly) reduce your contribution to environmental problems caused by the production of meat.

And why am I not going full vegetarian? Because I don’t want to. I do enjoy the occasional plate of hot chicken wings and Chicken 65. Plus, meat is a great source of essential proteins. I don’t want to have to chug down bean cocktails.

Weekday Veg has a nice ring to it. But, I didn’t want wait until the weekend. In my version, I am allowed to eat meat on Wednesdays and Saturdays. This spreads the carnivorous gorging evenly throughout the week. So, I’m following the Five Day Veg plan.

I also added some exceptions. Eggs are always allowed. They offer a daily source of protein. And I love scrambled eggs. A lot. Fish is always allowed because it is good for you. In practice, I dislike fish, so I never use this exception. Eating meat is allowed if you’re eating out with friends. I’d like to be able to eat anything I want if I’m chillin’ with my peeps. If I have to spend more to eat outside, I’d like to eat whatever I please. You can move the meals around if I like. If there’s something especially nice on Monday, you can make that the meat day, as long as you skip Wednesday. Finally, if you really feel like it, do whatever you want.

Now, these exceptions sound like they defeat the purpose of the plan. But they don’t. The idea is to consume less meat. After a few weeks on the plan, I defaulted to picking vegetarian options for all of my meals. I had to remind myself that I was allowed to eat whatever I wanted on meat days. Even then, I picked the vegetarian option much of the time. The idea is to make it attractive for you to go through with the plan, not to get a certification.

For some, using exceptions might be the rule. You might take advantage of them too much. It all depends on who you are, of course. But, for me this works. I’d say I eat a lot less meat that I would have. And that was what I was trying to achieve.

Make your own plan. The key is to make it fit your desires. You might want to start with a Meatless Monday, and then add on a Tuesday, and so forth. I’d be interested in hearing if/how you implemented your own part-time veg plan. Comment away!

On the morning of April Fool’s Day 2011, I was the victim of a prank. I was on my merry business enjoying what seemed like an uneventful day. At 10:23 am, I got a text declaring “Its FRIDAY FRIDAY.” This is an obvious reference to the godawful Rebecca Black Friday video that was a viral sensation a few weeks ago. Following that initial text, I got a barrage of similar texts. Over the next few hours, I must have gotten upwards of a hundred texts, many from friends of mine, but also many from people not in my contacts list.

My first reaction was that this prank must have been some kind of sensation that I hadn’t heard about. After all, I can’t be the only one experiencing this, right? I was completely wrong. Later that day, the joker mastermind confessed. Apparently, I was the sole victim. I was not the original victim, however. He had sent a text to about 35 friends, telling them to send me “Friday” texts and to pass it on. One zealous helper sent the text to 37 of his friends, telling them to prank me and continue the process.

Now, this raises some interesting questions. It would be really cool to have the data of who sent the text to whom and who decided to prank me. We could then overlay that data with their social proximity to me to determine the likelihood of someone passing the message on or sending the message to me. We could further subdivide all of that data with regard to age, gender, and the like. But, I’d say it would be hard to obtain the data without actually contacting everyone who was involved. Doable, but not as simple as scraping a website, for example.

Of course, there’s one question remaining. How do I get back at them? I decided to write Pradbot.

Pradbot is an email spambot that sends spam to people via text via email-SMS gateways. It spams people so I don’t have to. I had an email-sender program from a while ago. It was quite simple, using the JavaMail library to connect to an SMTP server, authenticating, constructing, and sending the message.  All I had to do was figure out how to send text messages via email gateways, which is also a simple process.

Almost every carrier has an email that you can send to that will forward the message to the phone number. That email is the SMS gateway. You just need to append the number to the front of the email. (“15554443333@txt.att.net” to send to an AT&T number, for example.) Wikipedia conveniently has a list of these gateways. And since there is no easy way of determining a phone number’s carrier, I decided to send to the gateways of all four major carriers (AT&T, Verizon, T-Mobile, Sprint).

I just put in a list of many of the numbers that had messaged me and let the bot loose. It used one of my new Pradbot gmail addresses to send the email. I knew from the beginning that this bot could only do limited damage though. SMS gateways limit the number of messages you can send. My bot, with the express intention of sending as many texts as possible, got to that limit pretty quickly. I used other email accounts, but they hit the limits pretty quickly too.

I think I sent around a dozen texts to the people that the texts actually got to. Ironically, the chief prankster didn’t receive any. AT&T handles their gateways differently from others, I suspect. Here’s the Eclipse project if you want to run it yourself.

At the end of the day, it was fun being the victim. Although they ate up about a third of my month’s supply of texts, it was good fun. Though my bot didn’t devastate their inboxes, some people did get annoyed. I also broke several TOS’s, but hey, it was April Fool’s Day. Remember kids, don’t go all techno-prankster on CS majors. Mildly annoying things might happen to you.

I spent the last two days wallowing in sorrow, trying to get my computer to run again.

Two days ago, I decided to install ArchLinux. I was attracted by its minimalist design. All I wanted was a terminal, so that I could build it up however I liked. Plus, it’d be useful to be able to use Linux natively. Currently, I use Putty to connect to the CS Linux machines to do homework. Its fine and all, but I can’t do as much as I like that way. For example, its nigh impossible to work on GUI applications this way. Plus, Arch is what the cool kids use.

The Arch installation process is a far cry from Ubuntu’s. It’s not pretty and involves a lot of low-level wrangling with partitions and configuration files. First off, I had to search for an hour online to find the correct kernel flags that allowed me to even start the installation process. Setting up the clock was the only simple part about the process. Then came the partition selection step. Since I didn’t know the Linux names for the partitions on my system, I had to use the  Ubuntu LiveCD’s gparted utility to find out. I also used it to create a partition for the Linux install. It was much easier using the LiveCD’s  lovely colorful interface than having to endure the process of doing it on the command line.

Then, I had to configure the mount points. I had never heard of a mount point in my life. At this point, I probably should have called it quits, but I kept going. I did as Lifehacker’s guide suggested and set the swap and root partitions. Choosing and installing the packages was a breeze after I discovered how to select the ones I wanted. Then, I had to go through a bunch of config files and make minor changes. No biggie.

The final part was installing Grub, which lets you choose which OS to boot into, and that failed spectacularly. By spectacular, I mean without any cause and an inexplicable error message. I tried for another hour or two to find the golden solution on the internet to no avail. Arch had conquered me for I was not worthy.

At this point, I could still boot into Windows as if Arch didn’t even exist on the drive. Since GRUB wasn’t installed, it went straight into booting Windows.

Since I was defeated by Arch, I decided to install Ubuntu. I wanted to run some Linux distro. Besides, installing Ubuntu would partially redeem me, I thought. The installation process was a million times simpler than Arch’s for sure. It took care of most of the details for me.

But alas, I fire up the system and I can’t get into Windows! It gave me a blue screen. Isn’t it ironic that the supposedly beginner-friendly distro was the one to mangle my computer? Ubuntu, on the other hand ran fine and dandy. I proceeded to spent the next day feeling depressed at the situation.

The first thing that came to my mind was recovering it with the Windows 7 installation disk. I go through the maneuvers and try to do startup repair, but it doesn’t recognize that I have Windows installed on the disk. What? Ludicrous! Unfortunate…

I used Ubuntu to mount my Windows partition and was glad to see that everything was there. If worse came to worse, I could just backup my files and nuke the drive, or so I thought. It became obvious that it was a problem with booting up. All of the Windows files were fine as they hadn’t been modified in any way. The bootup information was messed up. Somehow.

I just cared about making Windows boot up again at this point. Linux was nice to have but definitely not as essential as Windows. So, I proceeded to recreate the boot information for Windows via the command prompt on the recovery console. Or tried to, at least. That process pretty gave me a bunch of error messages. But, hey! It made me lose access to Ubuntu and fated me to bluescreen when loading Windows over and over. What a productive effort!

Then, I backed up my files, realizing that repairing the master boot record was probably not going to happen. I deleted the Windows partition and tried to install Windows using the CD. But it wouldn’t recognize my partitions! Essentially, I couldn’t tell it where to install! I tried for a while to find drivers to get it to recognize, but to no avail. Then, I tried to change the BIOS settings to change the hard drive controllers. Nope. The setting couldn’t be found at all!

Let me take a second to explain my disk’s structure at this point. The first partition was about 100 kb and gparted didn’t recognize it. I have and never will have any clue about why it was there. Next, comes the 200 mb boot partition that Windows made for some reason. Then, the 450 gb main Windows partition. The 25 gb Ubuntu partition and the 1 gb swap came after.

So there was a bunch of weirdness going on with the drive. I read on some Windows forum that in an attempt to make the disk play nice with the installer, wiping the entire thing with zeroes would be a good idea. I decided to try the next best thing; I deleted all of the partitions and created one NTFS gigantor. I was ecstatic when the installer recognized the partition. Can’t argue with Gigantor staring you in the face, eh Windows?

I proceeded to install Windows 7. I was so fearful that it wouldn’t work after everything else going wrong, but it worked perfectly. Then, I realized that I installed the 32-bit version, so I had to redo the install again. I spent more than five hours after that loading my files back and installing the software I needed. The only good thing that came out of this debacle was that all of the tens of gigabytes of random stuff I had accumulated over the past eight months. On the other hand, I spent one day messing up my computer, another day fixing it, and a third day getting it back to how it used to be. Three days in spring break gone down the drain.

What lessons did you learn, children? Don’t mess with a computer that you can’t afford to lose. Install Arch only if you know what you’re doing. Even Ubuntu can mess up your computer. Whose fault is it for not being careful? Mine, all mine. I admit that as a I shed a torrent of tears.

This post is part two of a multipart series journaling the game writing process. You can find the first post here.

The engine of a game consists of all of the components that help you create the game. It includes the graphics renderer, physics, sound, networking, and artificial intelligence, among others. For the simple game that I’m writing, the engine will be correspondingly simple. The key point is that all of the subsystems should be as separated as possible. Since Java is object-oriented, this means separating the components into classes. This facilitates easy modification in the future. I have all of the code in an Eclipse project here, and an executable Jar of the result here. Referencing the code as you read this post will make a lot more sense. I hope you will be able to bring your knowledge of Java to making a game after reading this post. It’s quite long, but I think I’ve put in a ton of detail that might be valuable to somebody out there.

The entry point of the game is the main class named Glade. I usually name my main classes Main, but that’s horrible choice: it’s not descriptive and I already have 10 of them in my workspace. This time, I named it Glade, the code name I have for this project. This class creates the Renderer, the Controller, the Stage, the Display, and the Player. These objects are accessible as static fields of the Glade class. This way, they are easily accessible to every object in the game. I could have passed them in through constructors, but that would have been cumbersome and without any benefit.

Then, Glade starts a timer that fires at a frequency determined by the frame rate. At first, I set the frame rate to be 25 FPS, but that was very sluggish, so I pumped it up to the standard 60 FPS. There is no guarantee that the game will hit his frame rate. It only acts as a maximum. If you don’t cap the frame rate, your game is going to run extremely fast on fast computers, which will make it unplayable. I didn’t do this for my first game that I made several years ago on old school computers. On my modern laptop, it is so fast that I my character dies within seconds.

The Renderer class is responsible for the graphics component of the engine. It extends JFrame which has the paint method. The method gives us a Graphics object that we can draw to in order to display things on the screen. This paint method is called each time the timer hits. The Renderer puts the window into full screen mode if it’s available. Otherwise, it just uses a regular window. The full screen mode is significantly faster because it can bypass the windowing system and draw directly to the screen. Plus, it looks much nicer; people usually don’t want to play games in windowed mode. Renderer implements a double-buffering strategy. If you directly draw to the screen, it is slower and gives you weird flickering. So, we first do all of our drawing onto an off-screen buffer and then draw it to the screen after we’re done.

All of the objects implementing the Drawable interface are stored in a HashSet in Renderer. Drawable requires the object to implement a draw method. Each object is passed in the graphics object to draw to. This way, every game object is responsible for drawing itself. The Renderer clears the screen by drawing the background onto the buffer, and then iterates through all of the Drawable objects, calling their draw methods. Every Drawable gets drawn each time paint is called. However, you are not allowed to add to or remove from a HashSet that you are iterating over. This is because the iterator won’t be able to keep track of where it is and where it’s supposed to go next if we randomly change the HashSet that we are iterating over. But, we need to be able to add and remove Drawables, because enemies and bullets need to be removed all the time. To facilitate this, two other HashSets are maintained. One contains the Drawables that need to be added to the main HashSet, and the other contains the Drawables the need to be removed. So, adding a Drawable to the Renderer doesn’t mean adding to the main HashSet, but adding to the add HashSet. This way, we never add or remove while iterating. All of the objects in the add and remove HashSets are added and removed from the HashSet storing the Drawables before iteration begins.

The Environment object is created by the Renderer. For now, all it does is draw a transparent cyan background. The transparency makes it so that objects leave a smooth shadow in their wake. Although drawing such a huge transparent rectangle each frame is somewhat expensive, it leaves a lovely effect. In the future, this class can be used for all sorts of background effects.
The Controller is responsible for the game logic. Its main job is to iterate through all of the Actables, calling their act methods, when the timer hits. (So, every object’s act and draw methods are called each frame.) The act method is where the main logic for each object is placed. Since it is called each frame, anything that must be done as the game is running must be placed there. This includes moving the object around, checking for collisions, dealing with input, among many other functions. Eventually, the controller will also deal with bigger picture aspects such as level progression, creating enemies, spawning power-ups, managing high scores and the like.

The Stage is what holds and manages the Actables. I usually include this functionality in Controller, but I decided to split it off this time. The Stage is also responsible for facilitating collision detection. Bullets can ask the Stage if its colliding with an enemy. If they are, they would do damage to the enemies and be destroyed. For now, the Stage will naively just run through all of the enemies, asking each one if they collide with the bullet in question. In the future, it can be rewritten to be much more efficient if performance is an issue.

The Display object stores stats like the score and remaining lives and displays them on the screen. It can be extended to create a snazzy display in the future.

The Player class processes keyboard and mouse inputs to manipulate the state of the player’s little ship. In addition to implementing Actable and Drawable, it also implements KeyListener, MouseListener, and MouseMotionListener. Whenever the mouse buttons or the movement keys are pressed, the corresponding boolean variables are flipped. Whenever the mouse is moved, the coordinates are stored. These variables are tested in the Player’s act method and the corresponding action is taken. If the mouse is pressed, a Photon is created at the location of the Player in the direction of the mouse cursor. In the future, the Player will also be responsible for checking if it is colliding with an enemy and reducing the health accordingly. It draws a square at the location specified by its x and y coordinates in its draw method.

A Photon is a subclass of the Bullet class which encompasses all of the projectile weapons the Player has at his disposal. Bullet is given its origin and target at construction and some trig calculates its x and y velocities. It then updates its location each step and kills itself if it is outside the boundaries of the stage. For now, all Bullets follow the same trajectory. I can move that functionality to the subclasses if need be. All sorts of funky bullets can be created this way.

Play with the code. Try changing the colors or the constants. Create new bullet types. That’s how I learned to program games. I took an existing one and changed the graphics and added bullets and power-ups. Leave me any questions or comments!

Follow

Get every new post delivered to your Inbox.