Before Spelunky arrived on the scene four years ago to kick all my free time down a dark, black pit, I have to admit I’d always kinda turned my nose up at games that used random level generation.
The concept of levels that rearrange their layouts dynamically on each playthrough is nothing new. The earliest example I can find is a 1978 Apple II dungeon-crawler called Beneath Apple Manor, but the practice is more commonly associated with the similar 1980 title Rogue. This gave rise to a sub-genre of hack-and-slashers called ‘roguelikes’. The term has since been expanded to include any game that features random-level layouts and, crucially, ‘permanent’ death – if you die, you never get another crack at the level that killed you.
Spelunky, which began life as a free-to-download PC title in 2008 before being retouched for Xbox 360 in 2012, is a 2D platforming twist on the formula. As the titular spelunker (or Inuit/robot/ogre – there are a lot of character skins), you are tasked with working through 16 randomly generated stages. You’re armed with a strictly rationed supply of bombs (to blow through walls or kill enemies too lethal to risk using your whip) and ropes (for making impromptu ladders). You can buy extra items from the shopkeepers you meet during your travels (ground rent must be cheap down there) to make your descent a little smoother. These range from shotguns to blast the cave’s yet-to-be-documented-by-science wildlife, compasses that alert you to the general direction of the exit and, more rarely, teleporters and jet packs.
All the items cost money (unless you thieve from a trigger-happy salesman – suicide for all but the most skilled players). Money must be sourced on site, which means going out of your way to mine treasure from the caves around you. And that means weighing up whether to exhaust vital supplies of bombs and rope – plus the risk of death if you fall from a great height.
Since the hook of Spelunky is one of venturing off and risking life and limb for unknown reward, we can begin to see why designer Derek Yu made the call to randomise the level layouts. If stages were fixed, players would soon clock the way to the exit.
That is why, despite hearing my fellow game journalist colleagues rave about it for years, I was one of the last to don my miner’s helmet and take the plunge. You see, I was raised on a diet of platform challenges that were painstakingly built by design experts; I couldn’t see how on-the-hop designs could ever compare with the work of visionaries such as Shigeru Miyamoto.
Take Super Mario Bros’ iconic level 1-1 as an example. It doesn’t look like anything special at first, just a straightforward dash from left to right with a few obstacles scattered in between. Watch speedruns on YouTube, however, and you’ll see the layouts in a new light. Every pipe, coin and enemy has been meticulously placed and spaced so expert players can burn through without breaking momentum. Check out the speedruns of later Mario games, such as the Wii U edition, and it’s even easier to appreciate the craft that goes into designing a level so it’s equally engaging for first-timers and experts.
Sign up to the 12DOVE Newsletter
Weekly digests, tales from the communities you love, and more
Against that backdrop, how could Spelunky’s randomly generated challenges hope to offer the same drama and challenge as purpose-built levels that have been tweaked until they’re piano-wire tight?
The answer to that is – like Spelunky itself – seemingly simple yet deceptively complex. The game’s levels aren’t randomly generated at all, you see; they are procedurally generated. The end effect might appear to be the same – constantly refreshing layouts – but in formulating levels, Spelunky’s engine follows a few simple, but strict, rules that prevent them from descending into farce.
Each level is built out of 16 rooms, with the entrance at the top and the exit at the bottom. First the game ensures there’s a clear and accessible path from the entrance to the exit that doesn’t need bombs or ropes. Then it devises a set number of dead ends that won’t lead to the exit but which you might want to explore for treasure.
Then the game populates each room with treasure and obstacles, and it’s here that Yu sprinkles on the magic extra thick. Each room is made up of a preset number of templates – although you could play for hours (and if you let the game sink its hooks into you, you will play for hours) without noticing. That’s because the templates use what Yu calls ‘probabilistic tiles’ to ensure they look and play differently each time, without being impossible or illogical.
For example, the game might determine there’s a 33% chance of a spike pit lurking at the bottom of a long drop, or a 25% chance there’s a push block waiting for you at the top of a ladder. All these little rules and regulations intermingle to create consistently brilliant levels. Sure, some are much, much harder than others – but then, the luck of the draw is all part of the fun. Sometimes you’ll coast through an entire world without much aggro. Another time you’ll find a level cast in perpetual darkness and full of wasps.
Spelunky’s randomly (sorry, procedurally) generated worlds might not scale the difficulty upwards in the way we’re used to in conventional platformers, but within the game’s universe, it works. Even if a fiendish early design wipes out your supplies, there’s always hope the algorithm gods will smile upon you and conjure up generous layouts so you can restock. Whether a challenge is difficult or not, it’s impressive how organic the platforming can seem. In years of playing, I have generated thousands of configurations and not one was noticeably chiselled by machine rather than man.
But Spelunky’s most impressive trick is to make you feel fond of layouts you’ve never seen before and will never see again. Every four levels, the worlds’ make-up changes; caves packed with bats and spiders make way for junglescapes filled with piranha ponds and spike-spewing totem poles. Survive that and you find yourself in an ice world where space is at a premium and careless heroes swiftly tumble into the abyss.
Each time you’ll find an ecosystem of moving parts that significantly changes the way you approach your descent, even if the base mechanics remain the same. Mastery of each world requires a drastically different tempo and mindset. It’s possible to bypass earlier worlds by fulfilling increasingly convoluted criteria for a tunnel digger. Yet you’ll find yourself deliberately revisiting conquered worlds to plunder them of items and riches, just as players used to revisit 1-1 or Sonic the Hedgehog’s Green Hill Zone to grow fat on extra lives.
A toast, then, to Spelunky, a game I initially thought would prove shallow. Instead, it became an obsession that has me delving deeper and deeper to unravel the intricacies of ever-shifting caverns. Four years on, there’s still no light at the end of the tunnel.
This article originally appeared in Xbox: The Official Magazine. For more great Xbox coverage, you can subscribe here.
The official source for everything Xbox One, Xbox 360, and Xbox Series X. We're also a magazine, covering all things Xbox in the UK and the US. Originally established in 2001, the magazine was discontinued in April 2020.