Random_genesis

- Scientific worldbuilding

Constructing fictional places has always been one of the main goals in the general field of procedural generation.
However, in most cases, even the generation of entire worlds has just been a necessary step in the creation of some other product. The generation tends therefore to focus on a few aspects that are core to the final product, while many variables are left aside.

The idea is to try and create large territories, where many different variables are scientifcally taken into account: geology, geography, climate, ecology...
Possibly, through the application of some "Guns, Germs and Steel-like" mechanics it will be possible to simulate large scale interactions between humans and the environment, and among humans on a large scale.

"Noise" (Feb 2018)

There are many of known ways to generate good terrain heightmaps, and none of them really works well on its own. The plan is to create multiple layers of height values and stack them on top of each other in a weight-blended pile.
The simplest way to generate a layer layers of height values is using noise to populate a matrix. Different types of noises generated with different parameters give a sufficient combinatorial differentiation in the layers that can be produced.


White noise is of course the simplest approach. Its frequency can be varied to generate matrices with different resolution.
Generating this is trivial: every position gets a random float in (0,1].

Perlin noise is generated using a complex algorithm. Luckily enough, it's built-in in Unity in a way that makes it very simple to use.
Basically you sample an infinite matrix of float values. Tweaking the distance between samples changes the appearance of the result.

What I call "voronoi noise" is generated by picking K random points, assigning them random Perlin values (to ensure a certain smoothness), and then running a 1-NN algorithm on the entire matrix.
The result is a Voronoi Tessellation, where each partition represents a flat area with constant height.

These three types of noise generate values with different distributions: Perlin noise (and therefore voronoi noise) generates values with a distribution that is very similar to a normal distribution (actually Unity's Perlin noise appears to be slightly different, but not enough to be relevant). White noise is by definition uniform.
These distributions make it so that the final values tend to be squashed towards the mean (0.5), producing a map with no deep seas, and no high mountains.
This is exasperated even more by the fact that the map needs to be smoothed to correct the unnatural bumpiness caused by random noise. A simple smoothing algorithm is employed, that sets the height of a point to the average of its 9 neighbour points.
It is possible to make the smoothing more pronounced by increasing the radius in which neighbours are used to calculate the average. Also the smoothing can be applied selectively only to points belonging to a specific height interval.
The smoothing obviously tends to compress even more the heightmap towards the mean value (sea level: 0.5).

In order to correct this, the map is "stretched", pulling every point away from the mean artificially:

stretched_value = (old_value-0.5)*K, where K>1

Using these mechanics, a first iteration of the map generation algorithm uses a strong-weighted layer of "Voronoi noise" as a base, then 3 layers of white noise with decreasing amplitude and weight.
Between layers the map is smoothed repeatedly and stretched twice.

The results are... not terrible, considering how simple the algorithm is. The Voronoi layer proved to be quite effective in defining landmasses, and the fact that its values are sampled from Perlin Noise ensures a certain integrity: mountains appear where they should and not in the middle of the ocean.
At the same time, coastlines are definitely too straight. Perhaps an other level of strong, early, Voronoi noise would break them up in an organic way, but it would need to have a much higher frequency and that would have a heavy impact on the generation time.
An other problem comes from random white noise at low frequency: it induces a bias towards straight vertical and horizontal lines. I might try displacing rows and columns at random, hopefully it will break up those ugly square outlines.
Ill just play with this for a while...

>Next update