This the level generation algorithm of a game that started as a project for the 2014 AICASF game jam (link to that project coming soon) and ended up as an Oculus DK2 project I presented at the Stereoscopic Displays and Applications convention in San Francisco.
This project was done in Unity, programmed in C#. Levels are passed a list of parameters from which they are generated, changing things like the complexity, size, hallway narrowness, and amount of dead ends. These levels are generated on-the-fly when the game starts.
The way the generation algorithm works is based on how the game itself plays. The game is in first-person and starts the player in the middle of the level. Players then run around and find scrolls that they must return to the center with. In order to generate a level that made sense for the gameplay, the algorithm first generates a rectangular shape. More rectangles are then added in random positions with random sizes that overlap the original, resulting in a main central area I called the “plaza”. From there, “hallways” are extruded outwards and will randomly turn left or right and continue along. You can see the results in the animated image above, which are all generated from the same parameters. This results in levels that require the player to explore in all directions and still be able to find their way back to the middle.
Click the animated image to see a larger version, and the project download link is below. Download is compatible with an Oculus DK2. You can also check out the source code on GitHub. \Assets\Generate.cs is the level generation system.