
Show HN: The Deadlock Empire – Slay dragons, master concurrency - prvak
https://deadlockempire.github.io
======
nbaksalyar
This is awesome! I love this kind of games - they are very fun and educational
at the same time.

If you're like me, you might enjoy these as well:

1\. Microcorruption -
[https://microcorruption.com/](https://microcorruption.com/) (a game that
teaches about embedded systems and security basics)

2\. Over the Wire - [http://overthewire.org](http://overthewire.org) (several
games based on Web security)

3\. WeChall - [http://www.wechall.net/](http://www.wechall.net/) (a big list
of games with progress tracking)

~~~
WillAbides
Ruby Warrior is another great one. I had a lot of fun with it when I needed to
learn Ruby for work. [https://www.bloc.io/ruby-
warrior](https://www.bloc.io/ruby-warrior)

~~~
hobs
Is there any way past the first level besides logging in with facebook?

A friend of mine just started (yesterday) looking at Ruby stuff and this looks
awesome, but I wouldnt recommend any service that has an impassable FB login
after level 1.

~~~
WillAbides
You can use the original without logging in to anything. It doesn't have the
graphical elements, but in my recollection, the game is the same otherwise.

[https://github.com/ryanb/ruby-warrior](https://github.com/ryanb/ruby-warrior)

------
ziedaniel1
This is really cool! However, I was somewhat disappointed that it only models
a linearizable memory (each low-level operation atomically acts on the same
global state). It would be great to teach people that they _can 't_ actually
think about memory this way, since various reorderings are possible. The UI
design gets a lot trickier, but this could become a great way to teach people
how to deal with things like atomic instructions, memory fences, and the
differences between the x86 and ARM memory models.

~~~
prvak
Thanks! We agree, memory models/instruction reordering is where it gets really
fun and educational. The complexity scared us and we wanted to make the game
usable as soon as we could, so we rather left it on the TODO list for now.
Maybe one day in V2 :)

~~~
JoshTriplett
You could add a CPU write buffer or cache lines as an intermediate step
between the code and memory, and allow the player to choose when those get
flushed to memory, constrained by memory barrier operations.

This kind of problem comes up very often in the context of the Linux kernel.
And the ability to deal with it is as even rarer among programmers experienced
with concurrency than experience with concurrency is among programmers in
general. A tutorial of this form for memory ordering issues would be
_invaluable_.

I'd be happy to help with problems and game-element design for a memory-
ordering version of this tutorial.

------
agentgt
This game would actually make for a great assessment test[1] for hiring. I
might be interesting to retrofit it to keep score or maybe perma death ala
roguelike.

[1]:
[https://en.wikipedia.org/wiki/Test_(assessment)](https://en.wikipedia.org/wiki/Test_\(assessment\))

~~~
Chlorus
Whoa[0] there[1], slow[2] down[3] son! You don't have footnotes for the rest
of the common words in that sentence! What is a 'game'? Or 'score'? Or 'rogue'
'like'?

[0] [https://en.wiktionary.org/wiki/whoa](https://en.wiktionary.org/wiki/whoa)
[1] [http://www.merriam-webster.com/dictionary/there](http://www.merriam-
webster.com/dictionary/there) [2]
[http://dictionary.reference.com/browse/slow](http://dictionary.reference.com/browse/slow)
[3] You get the idea

~~~
agentgt
Assessment testing is not a common phrase. In the recruiting industry it means
something very specific and I wanted to make sure it was explicit that I am
talking about that type of testing and not just testing for whatever other
reasons you might test someone.

Years of programming I guess have made me an explicit cross referencing kind
of guy. I find it far worse when your not explicit at times. Misunderstood
communication can lead to bad things...

------
kasbah
That's the Welsh Dragon!

[https://en.wikipedia.org/wiki/Welsh_Dragon](https://en.wikipedia.org/wiki/Welsh_Dragon)

~~~
prvak
Yep. My creative process: "Need quick & nice fantasy-styled logo" => "Hey, I
remember Wales has a dragon on its flag" => "Ooh, and Wiki Commons even has a
CC0 SVG! Done."

------
jader201
This is pretty nice, well done!

One suggestion: it would be nice if you somehow integrated the fix for each
bug into the game somehow. At the very least, in the congratulations screen,
you could show a version of the code updated to fix the concurrency bug.

In other words, this helps you learn what _not_ to do, but not so much on what
you _should_ do.

------
TimFogarty
Hey! This was built at HackCambridge (and it won first prize)! Great to see it
here - it's such a cool project.

~~~
refrigerator
Pretty funny that one of the judges said that this would definitely be on the
front page of HN soon

------
geonnave
Wow, how cool is that! Congrats to the authors :)

Btw, I bet Edward Lee¹ would like this game.

¹
[http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1....](http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf)

------
rajangdavis
What language is this in? Never really tried anything like this before, but
just went through the entire game and beat it. Seems like you have to trick
the threads in the correct sequence in order to introduce deadlocks, but what
is the overall context of the game? (It was fun, but I didn't know what I was
doing half the time; I just tried to get the threads to hit the critical code
functions)

~~~
brobinson
>Seems like you have to trick the threads in the correct sequence in order to
introduce deadlocks

This manually "trickery" you are introducing is you intentionally replicating
potential control flows that can (and will) happen in real life. You should
come out of this game with a new/renewed paranoia about multithreaded
programming and how seemingly safe code may not necessarily be so.

------
BackwardSpy
Took me about an hour to beat it, I'm still fairly new to concurrent
programming so this was pretty great for showing me the pitfalls you can come
across.

------
WillAbides
I think I may learn some C# just so I can play this game.

~~~
pc86
I've only done the first few levels but it might as well be pseudo-code. I
haven't hit anything language specific yet.

~~~
WillAbides
Thanks. I'll give it a try after work then.

------
Zekio
quite the fun game EDIT: can't figure the last one out, but was fun :D

~~~
th0br0
1\. Move Thread 0 to end.

2\. do a few iterations through thread 1 (e.g. n=5)

3\. step darkness++ concurrently (via expand), so that darkness=1

4\. step thread 0 to Monitor.Wait(sanctum)

5\. the rest is straightforward.

~~~
JustSomeNobody
Whoa! Spoiler alert!

;)

------
alex_g
This is really gonna help me study for my OS midterm tomorrow- thanks!

