As I progress on the data structures and the tests for them, I’m expanding further and further the things the engine will need to be able to handle and how those things will probably happen. This results in a fair bit of thinking and refactoring as I go. The most recent development is with work around the concept of a Feature. These things represent a way I came up with to simplify how generators for the world work.
At its core, the world is randomly generated with noise maps that are all combined to make decisions about how the world looks at a particular spot. These maps include things like coarse height (general massive scale waves in the landscape like mountain ranges), fine height (smaller scale variances that help to define rolling plains or hills or valleys), variance height (turbulence in the landscape), moisture (how wet or dry an area is), temperature (how hot or cold an area is), age (how old or young an area is), vitality (how vitally alive or dead and crumbling an area is), and possibly others I haven’t defined in my head yet.
This pattern works very well for landscapes and biomes, but makes for rather complicated generators for things that aren’t part of a natural landscape. That in turn brought me to the idea of a Feature. In a nutshell, a Feature is something like a castle, mine, dungeon, or village. Something large and non-landscape based that exists in the world that some piece of code will have to generate.
Imagine with me for a moment that the world you are walking around in is being created as you walk a little ways out ahead of you. By extension, if you are walking through totally uncharted areas, the same thing is happening out to the sides of you as well. Now imagine that way off to your left is a castle, but it’s mostly on land that doesn’t exist yet because you weren’t close enough to it. That means there is a little corner of a castle out there in the landscape, but that the rest of the castle doesn’t exist yet because it doesn’t need to. With that scenario nicely gelled in your brain, now try to imagine how you would make a generator that knows how to make just a corner of a castle. It has to be able to do that without the context of the rest of the castle, and when you can see the rest of the castle because you walked over to it, the new parts have to all properly line up with the old parts (walls, doors, rooms, decorative carpet, whatever).
This brings us back to the idea of a Feature. A Feature holds the whole castle and lets you make it all at once. This allows you to write your castle generator in a way that doesn’t need to care about building a small part of a castle at a time. So now we have castles that can be built as one whole thing and the game engine just needs to be able to merge them into the landscape as it needs to. This comes with a bit of complexity for the engine itself, but it should greatly simplify the task of making generators for anything that is man made.