Because the way down is rolled first.
Derek Yu made Spelunky in 2008 and released its code on 25 December 2009. Every normal level is 16 rooms in a 4 by 4 grid. Before a single block is placed, the game picks a random room on the top row and rolls a number from 1 to 5: 1 or 2 steps left, 3 or 4 steps right, 5 drops down. It never steps back into a room it has used, and once it walks into a wall it can only drop. When it drops out of the bottom row, that room holds the exit. Every room on the path gets a job: walk through, drop or land. Only then is each room filled from a hand-drawn template of 10 by 8 tiles, with 5 by 3 chunks and chance tiles inside: a block that appears half the time, a spike one time in three, a push block one time in four.
Yu's own comment in the code calls the path "the no-bombs/no-rope (in theory) route to the exit". In our own run of the released rules, about 1 level in 240 still came out with the way down walled off by unlucky chunks, which is what bombs and ropes are for. Picking every room's job at random instead, our own test found no way to the exit in 2 levels out of 3 (our test spreads from the start through every open gap and ignores gravity, so it is generous).
The numbers are from Spelunky 1.1's code, the Mines. In 2018 Yu said Spelunky 2 uses the same approach: a safe path to the exit made of room templates. The levels in this film are our own simplified version, built in code from the released rules and templates, without idols, snake pits or shops.
Which game's level generator should we cut open next?
Sources: Derek Yu, Spelunky 1.1 source code and readme (2009). Derek Yu interviewed by Gillen McAllister, Gamereactor (2011). Derek Yu interviewed by Sid Shuman, PlayStation Blog (2018). Further reading: Darius Kazemi, Spelunky Generator Lessons.
Unofficial. Not affiliated with or endorsed by Mossmouth.
