Hello and welcome back to another installment of Coding the Matrix! Today we’re going to be talking about procedural generation in video games! As the name implies, procedural generation in video games involves generating content dynamically from an algorithm as opposed to having all the content created beforehand. Early in gaming’s history this was how everything was created due to the small amount of memory you had on those old game cartridges. These days though, we have enough space on discs, and hard drives to be able to have a significant amount of unique content made beforehand. Even so, most games these days mix in procedural generation regardless whether it would be for placement of their game assets or A.I. decisions.
A very well-known example of this sort of content generation occurs in the game Minecraft. Much like a random number generator, Minecraft’s worlds are generated based upon an initial seed given to the game. This makes every play through a different experience due to everything being different if you change a seed. This is partially why Minecraft has had such a huge success in the game world, no two people have the exact same experience. This same procedurally generated content system exists within other larger games such as The Elder Scrolls V: Skyrim, and Far Cry 3. These two games are free roaming, and allow the player to follow their own path through the world put in front of them. Both of these games use procedural generation to throw encounters at you while you make your way through the world. Specifically in Far Cry 3, the game was designed to throw a few enemies and encounters if you went directly from objective to objective.
A really basic implementation of this is to have in your code a random number generator that generates a number from 1-10. If it hits a certain number a certain event happens. Say you have a list of ten different animals all represented with the numbers 1 – 10. Based on the number you get, you could have your algorithm pick one of the ten animals out of the list. If you stack this with more random number generators and create what effectively becomes a flowchart, you could have something as complex as Minecraft. That is, you have a number you input initially that feeds into a random number generator that feeds into more of these random number generators that set off other algorithms to generate the entirety of what you’re attempting to procedurally generate.
Well, that’s all in this week’s entry of Coding in the Matrix! Stay tuned for next week