Using Prefabs in Cogmind’s Map Generation
Josh Ge, the developer of the roguelike Cogmind (and X@Com) posted a writeup about the use of prefabs in Cogmind’s map generator, and I thought it would be a great springboard to talk about the use of prefabs in general.
I’ve mentioned them before in Dungeon Crawl, but ADOM, Angband, Spelunky, and other roguelikes also make heavy use of vaults/prefab elements. It’s one way to make stuff stand out from the oatmeal and introduce statistical spikes to break things up.
Josh gives us an in-depth look at how you can implement a generator that incorporates prefabs. It includes big level-defining anchors added at the start and room-defining presets applied after the basic layout is in place for more interesting encounters. Note that the prefab templates allow for a lot of variation (like Spelunky’s rooms) including rotating and mirroring.
Cogmind uses the prefabs to implement encounters and tactical challenges, which is a smart application of the technique. Using prefabs in this way can be thought of as a generalization of action set-pieces in more conventional level design. Rather than laying out the specifics of one unique encounter, you can describe the general parameters of the challenge and let the player encounter many variations. (Spelunky uses this to great effect.)
Prefabs are also a way to add landmarks. It’s difficult to make a map generator that has unique content that stands out enough to avoid being lost in the mush, but otherwise bland content makes for excellent connective tissue between the more unique landmarks that grab attention.
Another way to get unique landmarks is to have multiple generators, with a few being rarely invoked, as with biome generator. But prefabs are cheaper and can be combined with other techniques. Particularly if your prefabs can have other generators nested inside them.
The encounter system also touches on something else I’ve been thinking about lately: generating abstract systems. Games and simulations usually have a lot of invisible systems that aren’t directly reflected in the visible map space: tech trees, combat rock-paper-scissors relationships, economic systems, and so on. But, with a few exceptions, these are not things that procedural generation is commonly used to make.
But there’s no reason not to use procedural generation to make them. Indeed, many of the biggest procedural generation games have precisely the weakness that their generation is visible and physical, but that the gameplay systems aren’t subject to the same variation. Procedurally-generated gameplay is an under-explored area.
http://www.gridsagegames.com/blog/2017/01/map-prefabs-in-depth/