2009-04-02

April Fool's Day

I love all manner of games and jokes. This makes April Fool's Day significant for me. I have never pulled a huge prank like filling a friend's dresser drawers with packing peanuts or rotating all the furniture in room by 90 degrees. However, subtle pranks can be just as fun if executed well.

Last year was my first April Fool's Day as a professional programmer in an office environment. I hoped to make an impression by "infecting" some of my coworkers computers with a little joke program. A quick Google search lead me to a list of free possibilities, but my Anti-Virus software wouldn't even let me try them. I then decided to replicate my top choice by hand. I picked a few people around the office and found images that they would hate, such as an MSU Spartans logo for the die-hard U of M fan and a Green Bay helmet for the Lions fan. The program briefly flashed the selected image periodically, after the idea of subliminal advertising. It worked well to annoy the targeted individuals, but it felt like a rush job.

I realized about a month ago that I hadn't put any thought into a joke program for this year. As I was pouring over the possibilities, two memories collided in my head. The first was a programming term that I must have read somewhere: "Trapping the mouse." The term means restricting the movement of the mouse cursor to a particular range, such as the canvas of a photo editor or to the window of a game. The second memory was of a TV show I watched on PBS as a kid, Ghostwriter. The show featured a ghost that could only communicate by manipulating written words, but had free range to create text in a computer. The collision of the these memories sparked the idea of having a ghost randomly appear and drag the mouse cursor around the computer screen.

I started by mocking up quick version with a stick figure graphic and simple angular movement. Once I got the mouse trapping to my liking, I upgraded the graphics to the little ghost you see to the left. I then set about making the movement based on the rotation of a simple vector. I started experiencing some "rotational loss," meaning the vector would shorten each time it was rotated, which lead to the ghost eventually coming to a standstill while still trapping the mouse. After I solved that problem, I added some bounds checking to keep the ghost on the available screens at all times. My first pass at the bounds checking would occasionally lead to an infinite loop of corrective action, so I added a loop counter that would bailout of the corrective loop and allow the suspect move, assuming the next move would also need bounds correction, but would be easier to calculate. As a "finished product," I settled on each trap event lasting only 3 seconds. I had the program compile to the innocuous "afd9.exe" and stored it on my shared folder, so I could launch it from any computer on the network.

I started the program secretly on 6 coworkers computers. I also demonstrated it to 5 other coworkers. All responses were positive, from "That's cute, now get it off my computer" to "Very clever, well done." One of the secretly started instances was never trigger, but I showed him how it triggered when he said he felt left out. I am very pleased with the final product and the response. I think it was a good pick me up for the office morale. Now, what should I do next year?