Terrain Generation

Terrain generation is very, very simple, but simple rules sometimes can result in great complexity. This was the mantra of BIOME, the Maxis-created Spore Prototype.

I spent many an hour tinkering with that toy. Writing rules for terrain generation was only one of the many, many things I did with it, back in the day. And it turns out that terrain generation is easy, when you distill it down a bit.


First, the world is filled with an initial state value, lets call it -1 because that's what it is in Evagents. This state, if rendered, appears black on the reality layer, but otherwise acts like terrain.

Then, several points are selected at random to be "land seeds". These points are generated with values of 1 or 0.7, so that we have either Mountains or Hills as a result. The number of these points generated has to do with the number of Continents and another variable in the config called CONTINENT_ROUGHNESS. The higher either of these numbers are, the more points will be picked.

Next, water needs to be seeded, and the number of points chosen for this is a complicated calculation, but it's related to Ocean Percent, CONTINENT_ROUGHNESS, and the number of Continents.

These points now are processed as Cellular Automata. Each cell has a chance (for water it's higher, to get rounded coasts) to spread to nearby init cells (-1), and replace it with a terrain type based on more simple rules:

  • If Deep Ocean or Shallow Ocean, spread as another Deep Ocean or Shallow Ocean, respectively

  • If any type of land, spread with a chance to reduce the elevation by 0.1. Mountains can turn into Highland, Highland can turn into Steppe, Steppe can turn into Hill, and Hill can turn into Plains. The reduction ends here, and Plains continues to spread, until it meets a type of Ocean

  • Any time a Land cell is touching at least one Ocean, it will probably turn into Beach, with an elevation of 0.5. This terrain type cannot itself spread, but usually does because land must always meet the water.

Before we finish replacing all -1 cells, we do a check of the proportion of the terrain which is Land vs Water. If the ratio is too out of whack, we need to correct it by seeding more of the opposite type as lakes or islands. This is done for a short time however, and the sim returns to spreading cells. The result is sometimes nice island chains or great lakes, and usually helps marginally to balance the terrain. It also offers a unique biome for agents to try and survive in. Setting ISLANDNESS to a higher value means we start the new seeding process earlier, and results in a greater proportion of the world being taken up by islands and lakes.

Once every -1 cell is replaced, we aren't done yet. The terrain resulting from this is rough and jagged. We need to perform a couple of rounds of terrain smoothing. It is during this phase that most of the continental shelves are formed off the coasts, and beaches and islands are expanded. Hills are made rounder, and mountains aren't quite as jagged as they might have been.

Someday, I hope to also include river erosion and generation, but for now this hasn't been implemented and isn't a focus. Rivers will likely be a different terrain elevation, 0.3 perhaps, and might connect to above-ground lakes. Perhaps once we switch to using 0.01 terrain steps, this could also be added.