Nathan Hwang

Hunch Punch

Now that I actually have time, I’m going to hop backwards in time from May of 2011 to April, and document the HackNY hack I was involved with (this sort of hack, not this sort of hack), because documentation is good, I spent a non-trivial amount of effort on making this project happen, and I had some small interest in the project (versus, say, either of my advanced programming projects this last semester. It is amazing just how little I can care about pieces of code I have written…).

So first some background: HackNY is a 24-hour student hackathon that happens once a semester, and is pretty much the hackathon to go to if you’re a student hacker in NYC. Usually, a bunch of startups present their APIs, everyone hacks the night away, teams present their hacks, and some projects are chosen as winners. Pretty standard hackathon format.

Hackathon and Development

Going into HackNY I didn’t have any plans to work on a specific hack, nor a team to do a hack with. I decided that if people needed help, then I would help them out: if someone needed a hacker, and their project seemed interesting, I’d join the team: if no one needed help or a hacker, then I’d just work on Notesoble. Simple and gracefully degrading.

Then Chris Wiggins mentioned my previous HackNY effort in the introductory talk, appealing to whoever that made it to put it up again. “Welp”, I thought. “Gonna have to spin up a Rackspace instance again”. So I spent some 4 odd hours making Hacker Mapper work (again), and by that time most of the teams were going at full speed and deep into hacking. Recalling lessons from the Mythical Man Month (I’ll admit I haven’t read it yet) I decided that I wouldn’t try and insert myself into a team.

At that point (9PM) Mark Liu came up to me and pitched an idea: a game based off of Fluidinfo, which was one of the startups that presented, and was attempting to serve as metadata for the internet. He hadn’t actually started work on it yet, so I wouldn’t be disrupting an already established team hierarchy, and it’d be a lot like doing a hack from scratch, but just 4 hours offset from when everyone else started. After realizing I would only be marginally productive working on my own projects, I decided that I’d work with Mark on what would become Hunch Punch.

Somehow, we also picked up 2 more people: Grant Kot is a cellist at Julliard that somehow also kicks ass with Windows Phone 7 and physics/game development, and Willie Neiswanger, who wasn’t able to contribute technically but came up with the name of the game.

We decided pretty quickly that we’d screw around with developing the game on Canvas with the javascript library gee, and soon left behind the idea that we would somehow shoehorn Fluidinfo into the game, as most of our ideas revolved around implementing game mechanics with Fluidinfo in inefficient ways, and not leveraging Fluidinfo in some cool way. We eventually had something like this conversation:


Mark: I just want to shoot things!
Me: But how are we going to tie this into the APIs?
Mark: What about asteroids?
Me: But how are we going to tie this into the APIs?
Mark: Hm, what if we pulled things from Hunch, and shot at those things?
Me: ...

(we weren’t that disconnected, I just don’t remember what actually happened. Beware of hindsight bias)

And hence we settled on using Hunch to populate an asteroids-like game, and got to hacking.

One of the only major problems we ran into was the fact that Hunch eventually rate limited everyone at the hackathon, since they limit the number of API calls by IP address and the entire hackathon was sharing only one public address, and no one at Hunch had forseen a giant deadlock from the student hackathon. Eventually, people from Hunch woke up and removed the rate limits on the hackathon address, but that was pretty late in the game, so we didn’t have API access from 4-9AM. However, we offset this setback by luckily storing the result of the last call we made to Hunch, and used that to test our game. Highly imperfect, since we had only a single data set with which to develop, but it worked out in the end.

Implementation-wise, we did it entirely in javascript: originally, we fetched information from the Hunch API through a python script, and planned on serving up a customized HTML page with the Hunch data inserted into it. However, we realized that we could just skip the server side processing entirely and just serve up javascript that fetches from the Hunch API itself, mostly by actually reading the Hunch API documentation. However, creating the python script first meant that we had “backup data” when the Hunch API started rate-limiting, so the python code played a major role in development even though none of it actually ended up in the end product.

We eventually turned out a complete game (playable here) and had barely enough time to ready it for presentation. Present we did, though, and we held our collective breaths until we learned we didn’t win anything, after which point we stumbled home and I took a nap. Good use of a weekend.

Media

Since we presented this at HackNY, this means that there’s video of us presenting it! Check it out: we’re the first group that presented (around 5 minutes in), so you could conceivably just sit tight and watch the intro, too.

Download

There’s a link to the (now) current source code on the play page, but at Grant’s behest, I threw up the code on github too. I’d recommend using the code on github, just in case bugfixes get released, although I have no plans for improving/extending the game beyond it’s current state. It was fun while it lasted, but it was just a weekend fling.

Leave a Reply