Home Archive Trilium Notes About
Home Archive Trilium Notes About

HackCambridge 2016

Posted on 2016-02-02

Last weekend, I went to HackCambridge with Petr to hack on things. Some things could be organized a bit better (like the WiFi at the main venue being hilariously broken), but we ended up having a lot of fun. Luckily, a bunch of my homies from Dropbox also happen to study in Cambridge and it was great to catch up with them.

We built a cool game. It’s called The Deadlock Empire and it lets you slay dragons and learn concurrency - what could me more awesome?!?!

Just look at this presentation!

It’s at https://deadlockempire.github.io. You can laugh at our poor coding practices on GitHub (deadlockempire/deadlockempire.github.io).

The Deadlock Empire has a sequence of challenges for practicing concurrent thinking. Each challenge gives you several threads, each running their own source code in C#, and your objective is to play the mischievous Scheduler: take seemingly-innocent parallel code and run it so that it breaks.

You can step each thread line-by-line (and undo your steps), and some non-atomic instructions can be expanded into atomic parts (i.e., i = i + 1 translates to a separate load and store). Sometimes, you have to do this to properly crack the challenges, like in Tutorial 2: Non-Atomic Instructions.

If you feel bored by how simple the first challenges are, scroll down a bit. The Deadlock Empire quest at the bottom should keep you busy for a while :)

I think it took us around 18 hours of actual work to write The Deadlock Empire: both of us had a bit of shut-eye early morning and we didn’t have enough time by the end to start working on the really ambitious features, so the last few hours were just a commit here and there, fixing up a font or an obscure bug.

There aren’t many shiny technologies: it’s plain HTML5 and JavaScript with jQuery, Bootstrap, and a few other things. The game has a simple “internal virtual machine” that executes simple instructions, like “increment this global variable”, “lock this lock and block this thread”, and so on. We used pseudo-C# as the challenge language mostly because of our familiarity with its ideas about concurrency, but it would be straightforward to write in pseudo-Java instead.

In the upcoming days, we’ll add more synchronization primitives and polish the experience. We want this game to be more fun, educational and useful.

I now have a favorite bookstore. Next door from their regular store, Cambridge University Press sells their damaged books. (Even through the only damage I found on them was the red ‘DAMAGED’ stamp at the front page.) Awesome books on advanced mathematics and CS, philosophy, sociology, biology. For 3 pounds a paperback or 7 pounds a hardcover. People grab them by the stack. Note to self: bring big suitcase next time.



We also won the Best Hack in Gaming/VR award (judged by Improbable) and Bloomberg’s Favorite Hack.