The 6 Days of Creation

If I want to simulate a full autonomous system of cities, including economy and transportation, I first need a world in where everything will take place. Climate, cultures, natural resources, population flows... everything has to be defined. For creating this world (or any variation of it) I have defined 6 steps to follow to reach the final goal. I call them The 6 Days of Creation:

  1. The board: The geometrical properties of the space where everything takes place need to be defined. The only external constrain: it should be a regular grid (for future convenience).
  2. Land and seas: Continents, mountains, valleys... The elevation should be procedurally defined, deterministic, and the process should work in any scale.
  3. Climates and seasons: For a given configuration of land, climates are deterministic. Winds, temperatures, pressures, yearly cycles... all these are needed to define the local climate.
  4. Soil: Do we find a desert or a rainforest? A salt pan or a lake? arable land or limestone? And which animals do live there? Which vegetation will grow? Knowing the climate and the seasons cycle it is easier to proceed with what we can find there.
  5. Subsoil: Under the soil there is still a full world of possibilities: oil, iron, rare metals, coal, groundwater, uranium ore, gold... The evolution of the culture developing on the top will be strongly modulated by its access (or no access) to these minerals.
  6. Humanity: Cities, industries, roads... The natural resources and the climate will determine the main characteristics of the cultures around this world, and the particular distribution of the population and wealth.

1. The Board

I will use a regular grid in a rectangular box. The horizontal axis 'x' (or longitude) runs from -1 to 1, which is twice the length of the vertical axis 'y' (or latitude) which runs from -1/2 to 1/2. Longitude is periodic, however latitude is not. The world is then represented by a cylinder. (Let's imaging that it is taking place in a Dyson's Cylinder).

This world can be represented in any scale by powers of 2: the highest, less accurate representation of it are 2x1x1 = 2 pixels; the next level are 2x2x2 = 2^3 = 8 pixels; next, 2x4x4 = 2^5 = 32 pixels; the n-th level, 2x(2^n)x(2^n) = 2^(2n+1) pixels. In every of these pixels (or grid point) we have a third value 'z' representing elevation.

 
 

2. Land and Seas

In the second day I have to define the elevation in all the domain inside the board. To simulate the effect of tectonics in emerged lands I randomly select the position of the tectonic centers inside the domain of the board. The elevation of the continental plate is represented by a saturated Gaussian (see below) with random width and centered in the continental center (this very simple model of continent shape can be optimized in sooo many ways!).

 
 

I'm showing below an example with 9 continental plates centered at the black dots. Black lines are defined from the Voronoi polygon and along these line is where I will place volcanoes and mountain chains. The elevation created by a volcano is here defined by a standard Gaussian centered in a point close to the fault line.

Next, I add to the elevation a type of Perlin noise at several scales (or frequencies). In this example the grid is n = 8 (131,072 grid points). Perlin noise is modified in such a way that the final distribution of elevation of this world mimics the empirical elevation histogram of the Earth's crust.

When adding these three contributions I define the sea level: anything under that level will be submerged. Additionally, for future convenience I discretize the elevation in integer numbers from 0 (sea level) to 256 (maximum elevation). If I change to a color palette that mimics Earth colors I obtain what you see below. It is quite interesting to observe that the mountain chains created along the fault lines become islands when they are out of the continental platform!

3. Climates

This is my favorite part. I have chosen a simple segmentation for the climates where I need the average annual temperature and its seasonal oscillation (cold/warm/hot), and the distance to the coast line (oceanic/continental). There are many sources of information and the model can be as complex as hell, but I found this link in particular quite useful for simple answers. My model is based in two simple elements:

  • Average temperature depends on latitude (maximum at y=0 with around 30ºC, minimum at y=1/2 and -1/2 with -30ºC) and elevation (linear dependence with z with a lapse rate of 6.5ºC per kilometer).
  • Annual temperature range depends on latitude and also on the distance from the sea. However, this distance from the sea has to be measured as distance downwind of the ocean. Yeah, we need a model for the wind!

A realistic model for the wind could be a nightmare of (beautiful) fluid equations, thus I have reduced it in a very simple way: the average total wind in a point is composed by the contribution of the prevailing winds plus the contribution of the pressure gradient. I assume that (i) prevailing winds depend only in latitude; and (ii) pressure gradient depend only in that due to elevation: as higher, lower the pressures. Since what I need is the distance following the wind vector, I will not worry about the intensity but just the direction.

I'm showing below the wind map for n=6 (for seeing clearly the direction for every cell). Because of the prevailing component, winds converge at y=0, diverge at y=1/6 and -1/6 (the tropics) and converge again at y=2/6 and -2/6 (you may note a contradiction here: this pattern for prevailing winds is due to the rotation of Earth and because it is spherical :P ). On the other hand, the pressure gradient disturbs the regular pattern following the geography (I'm only using straight lines and diagonals for simplifying it and computing the distance in units of pixels). Now I can obtain the distance downwind of the ocean which may look quite different to the distance to the closest shore:

This is how the average temperature and seasonal variation look for this example: cold at the poles and high altitude and hot at equator; large variations of temperature at the poles and interior, none at equator.

After all this procedure, I can define average temperature, seasonal change, and distance downwind of the ocean for every point of the board. This information is more than enough for a complex segmentation. An potential optimization would be to use these metrics for defining humidity and rain for defining a more exhaustive classification, as that of Köppen. In addition, rain would be really useful for creating rivers and defining the size of their flow, and modify the terrain at the lower level due to erosion. Anyway, this is my segmentation:

  1. I use average temperature for a first classification in hot (red), warm (green), and cold (blue) climates.
  2. I use annual temperature range and distance downwind of the ocean for segmenting:
  • hot climates into tropical (dark green) and desert (yellow)
  • warm climates into oceanic/mediterranean (green) and continental (purple)

And latitude and elevation for segmenting:

  • cold climates into tundra/polar (blue) and alpine (white)
Segmentation of climates in hot (red), warm (green) and cold (blue).

Segmentation of climates in hot (red), warm (green) and cold (blue).

Segmentation of climates in tropical (dark green), desert (yellow), oceanic/mediterranean (green), continental (purple), tundra/polar (blue) and alpine (white).

Segmentation of climates in tropical (dark green), desert (yellow), oceanic/mediterranean (green), continental (purple), tundra/polar (blue) and alpine (white).

For the sake of comparison, this is how it looks on Earth (with real data taken from here):

 
 

Ok, I'm not meteorologist but it looks cool enough. But still not as cool as the goal: something like THIS (but procedurally generated for any continental configuration).

4. Soil

The fourth day is for defining what to find in the surface. This becomes quite easy when we know the climates: desert, rainforest, cold rocky mountains, etc. Perlin noise can be used again for delimiting these spaces inside climate regions. The only limit is the imagination! My imagination this time limits it to vegetation, forest, desert, snow and ice. This is how the world looks now:

And this is how it looks in January and in July:

This is the equivalent on Earth. I still have room for improving the graphics and colors, but the underlying data looks fair enough.

It can be done at the small scale as well. Let's zoom close to the point (x,y) = (0,0) which falls in tropical climate. Using three functions of Perlin noise I define forest (green), arable land (yellow) and nothing really special, just rocks or low vegetation (brown). For the economy of the area, forest would be relevant for wood and arable land for farms.

Probably I'm missing many other correlations or empirical rules that define where to find forest or grass, or any other landscape. If you are reading this and you have a clear idea, write me!

5. Subsoil

Now is time for placing minerals under the ground. The full economic system will depend in the distribution of these resources. I'm not a geologist neither, so I use again Perlin noise for that. I'm not using any special correlation, I just fix the relative abundance (gold is definitely not as common as coal). In this example I have defined where to find coal (black), iron (red), gold (yellow) and nothing useful (gray). Again, if you are geologist and you are reading this and have some ideas or know references where to find inspiration for the model, please feel free to write!

6. Humanity

And for the 6th day, it's time to place cities, towns, industries, roads...

The model for urban growth and sprawl is already explained here. What is missed there is the layer of resources that will modify the probability of urbanizing a pixel. I still need to put some pieces together, but the idea is clear. I proceed as follows:

1. I distribute the seeds for the cities (white dots in the map) following some deterministic pseudo-random method (it should reproduce the same system no matter scale, by fixing the seed of the random sequence using the coordinates x and y is enough).

2. I use Voronoi cells for defining the area covered by each municipality (in colors in the map).

3. I locate industries according to the resources. For this example: farms, mines, fishing ports, and sawmills, in addition to factories (which receive iron and wood to produce goods), food factories (receiving grain and fish), power plants (receiving coal for energy) and jewelers (for the gold). Below you can see the economic tree I'm using now where I have also added oil as resource. For a more complete economic map (including climate-dependent resources, military facilities, or even nuclear power and narcotics), please check this.

 
 

4. We count the available resources per municipality according to the soil, subsoil, and access to the sea for defining the economic potential of the municipality. We use wealth for modifying the probability of urbanization of the sprawl model: wealthier regions will growth more.

5. I create the road network as explained in Road Trees (black lines below). A well-connected city will also grow faster, increasing the probability of urbanization. The transportation network will be used for trading resources and goods, thus well connected municipalities can be wealthy even if they don't have direct access to the resources.

6. I run the evolution, letting the cities to grow and sprawl using the available resources. These resources can dried up, and the dynamics would drastically change. Geographical limits can block the sprawl of a city, and satellite cities can grow instead. Some municipalities can block the trade for political reasons and destabilize the economy of their opponents. Temperature can grow two extra degrees and the climate changes. How the system would evolve under these circumstances? As more variables we introduce, more realistic and complex will be the outcome.

The ultimate goal is a full autonomous system where a player can join and take the control of a city, an industry or the transportation network to see the effects in the system of arbitrary acts. How to promote a city? How to transport the resources in the most effective way? How much time a city can survive if the main resource disappears? Imagine a simulation tool where anyone can test the effects of economical or political decisions before it really happen. Engineers use software for testing their models before sending the design to the production line, and architects test physics before building to ensure it will not fall. Politicians and city planners could do the same!

BTW some other worlds created below! :) In the first one, the continents are the same as in our example but the Perlin noise pattern is different, just to see how relevant it is.

This other world is a Pangea-like one with an inland sea (probably where the continents are breaking apart):

And in this other world there is a clear abundance of water: