No problem, that is fairly easily explained. At first you have to understand that I'm a Java coder, I can't live without my objects, interfaces, hard defined dependencies and well separated structures. ;)
The system behind it is the worldgen
mod, which is so far not documented because I am not sure if I will change the API or not in the near future. The core idea is that you register "modules" at a central entity which does all the heavy lifting and management for you, so that modules contain as little logic as possible, and only what they are really doing. So this entity, in our case WorldGen, holds a list of modules which will be invoked one after another. Imagine it like a manufacturing line with different stations, every station does a certain job and all together create the product.
I have attached a simple game/mod that uses the worldgen system and is heavily commented, I hope that helps in clearing it up how the basics work. You can extract it into the game directory and create a new world with it (not much to look at, though).
As for how the system in Australopithecus works, there are multiple steps:
- Some setup is done in base.lua. Mostly this is about preparing values for later use.
- After that a heightmap is created in heightmap.lua. This is a pure 2D heightmap and is saved in the metadata (and cached).
- A second map for the temperature is created in temperaturemap.lua.
- A third map for the humidity is created in humiditymap.lua.
- bake.lua combines these three maps to create the landscape, and also carves the 3D transformations.
There is a lot of black magic going in bake.lua...a lot! But the basic principle is that the heightmap is used to determine the basic height of the terrain. Afterwards the temperature and humidity are applied, and appropriate biomes are picked for these locations. Now it gets complicated within bake.lua, for speed and better management the system operates most of the time on a "prototype" of a terrain.
- The terrain is filled with rock to the height that was calculated in the heightmap.
- With 3D noise portions of this newly filled terrain are cut away. This creates overhangs and deep cliffs.
- After that, caves are carved into it.
- Now comes a really tricky part, we know where the surface is because of the heightmap, but the 3D noise has cut parts of it away, so we need to detect the surface a new. Otherwise we would not be able to place grass as upper most layer, because there would be air where we would want to place it.
- The finalization step maps the created prototype into the MapManipulator, together with some voodoo for placing oceans and water.
- The last step places the ramps in the world.
Now that looks complicated, but once you realize that all modules are executed in order and that the "set_*" functions are where everything happens (everything else is fluff to make it easier manageable and readable) it's quite easy to look at.