Geometry Of Death: Spelunky’s Level Generation Explained

You've procedurally generated... my love for you.

If you’re anything like me, you’ve played so much Spelunky that you can close your eyes and generate new levels for Derek Yu’s roguelike platformer inside your own head. Here, look, I’m doing it now – bet on what’s going to kill me…

It was a frog. Sigh.

For a more technical understanding of Spelunky’s procedural level generation, take a look at Darius Kazemi’s browser-based Spelunky level generator and associated guide.

Part one details how Spelunky generates rooms while guaranteeing there’s always a route to the exit, while part two goes into more detail about the positioning of probabilistic and obstacle blocks. It’s not the kind of information that’s likely to make you any better at overcoming the gamut of obstacles the level generation spits up in a typical life, but it’s a neat glimpse of how those challenges are created, and sure to be useful to anyone thinking of making a similar system in their own game.

I’m just new enough to this whole internet-writing thing that this feels to me like a magazine boxout come to life. I look forward to reading the real-time letters pages that will appear under this post later.


  1. Doghaus says:

    Very interesting to see how the randomisation was done, Derek Yu is a clever sausage.

  2. Premium User Badge

    Bluerps says:


  3. Llewyn says:

    Dear Auntie Graham,

    I have a problem. I seem to hold an unnatural attraction for frogs. And ants. And bats. They just can’t resist me! But I wish they would – I’m trying to save myself for the spike trap of my dreams.

    How can I deter their unwelcome advances without hurting their feelings?

    Llewyn (age 13 1/2)

  4. Haphaz77 says:

    That’s a nice find article. Reminds me that games are just lots and lots (and lots) of numbers ultimately. (the player on that screenshot looks a bit doomed, but then I haven’t played this game yet)

  5. ruthj240 says:

    My Uncle got black Mercedes-Benz CLA-Class Sedan just by parttime work from a laptop… ………. http://WWW.JOBS60.COM

  6. Ergates_Antius says:

    I forget. Is the updated version of this on PC?

    EDIT: Ignore me. Quick search reveals answer.

  7. Steed says:

    Hey, PC Gamer?

  8. Gonefornow says:

    The first part is pretty obvious just by looking at the level layout, but the smaller probabilistic grids inside the bigger ones is quite clever. No need for expensive clear path checking and such.

    Just goes on to show how few random generator algorithms you really need if you have enough well thought-out pieces of data.

  9. Baines says:

    Sigh. I miss the days when articles were written with words that you could read and pictures that you could see without jumping through extra hoops.

    Instead now we seem to be going back to the days of browser wars, with articles that can only be viewed properly if you happen to be using a particular browser. In this case, Chrome, because I’m guessing the Spelunky stuff is done in HTML5. You still get the text in Firefox (after the page loads), but the rest is just a giant black box with a notice that it probably only works in Chrome.

    • DariusK says:

      Hi. I made this tool/article. It’s based on a port that I did of Spelunky to HTML5. I did it at the request of Google, for their Chrome Web Store, so I was not attempting to target Firefox in any way. Since I started from that code base, these tools do not work on Firefox. I could have spent effort getting it to work in FF, but something I’ve learned is: if I’m doing something in my spare time out of love, I’m not going to put in extra work that is not strictly necessary, and I’m not going to beat myself up over it. If I do either of those things, I get discouraged and never finish the thing I’m working on. What I’m saying is: I’m lazy, and I think that’s okay if the result is stuff like this.

      THAT SAID: I’m going to spend three hours this weekend trying to get it working in Firefox. If it takes more than three hours, Firefox users are out of luck. If it takes less than three hours, then it will work in Firefox.

      The alternative to all of this is: someone could pay me money to do it. Then I would happily spend the hours to do it right.

      • Baines says:

        A few more example images would work almost as well, for less work.

        It isn’t just this article. I’ve run into multiple things lately that only run in Chrome because they depend on HTML5. It’s kind of annoying, because I remember when sites wouldn’t work properly if you used IE instead of Netscape, or Netscape instead of IE. (Heck, some people intentionally made their sites fail for IE users.)