So called “procedurally generated content” is currently a hot topic in game development. Again (or still), because it’s not a new thing – a lot of games (partially) used randomly generated content to increase user experience. For example, the world in the text-based game Dwarf Fortress is entirely generated randomly. Also, Diablo makes use of random dungeon generators to make every round a unique experience. When we talk about randomly generated content, we miss the point a little, because no game is really random. If it would be, you wouldn’t be able to play it, it would most probably not even start. That’s because every computer (and every game especially) has to follow a certain set of rules to work. In Diablo for example this means, that a player is able to reach all parts of the dungeon and not being locked in a single room without any exits.
In the game “No Man’s Sky” (yeah, I already hear the moaning of the disappointed people) the entire universe is basically generated randomly: Mountains, valleys, plants, animals, nothing was created by the developers per se, instead they’ve created the AI to create the world for them. Also in Minecraft, the world a player can move in is more or less infinite and created procedurally.
There are different approaches how worlds like in Minecraft or No Man’s Sky can be created. One I want to present shortly are modular worlds based on Markov Chains. A Markov Chain is system of states with transition probabilities. With a Markov Chain you can basically define that when you’re in state A, with a likelihood of 10% you’ll get to state B, 50% to state C and 40% state D. A game that makes use of Markov Chains to create random worlds is Who Dies?
In the physics puzzle game Who Dies? the player must guess which monster will get hit by a stone or falls off when gravity is turned on. It’s a 2D platformer like Spelunky and uses combination of tiles to create the worlds. So here is in short how it’s done:
- Randomly select starting coordinates in the grid (e.g. x=12, y=5)
- Define a rectangle (set width and height)
- Pick one object in a group of predefined tile combinations (they look like Tetris blocks) and place them within the rectangle
- Use a predefined Markov Chain to select, which object should follow next
- Select the starting coordinated for the new object close to the old rectangle
- Continue with 2. until you reach the world boundaries.
You can also check this article on MSPoweruser.com for more information
The app is free available on the Google Play Store and for Windows Phone. Give it a try!