The first task for my project was to generate the world. I was aiming for a mostly flat desert world with some hills, grasslands and lakes for variation. This post details my progress with this task and gives an outline of the work that still needs to be done.

The Terrain

I created a SurfaceProvider which handles surface height. A completely flat world would be pretty boring, so some variation was necessary. I used noise to generate those variations but restricted them to 3 blocks in height. The result looks something like this.

Hills were added using the PerlinHillsAndMountainsProvider from Core and lakes were added using the Lakes module.

Trouble with Biomes

After some digging around I found that we had the all the tools required for this world already implemented in the Core module. We had facet providers for mountains, trees, flora and also rasterizers which could handle whatever you throw at them. But at the centre of these all were biomes. The default BiomeProvider uses humidity and temperature values to define biomes and the given rasterizers/providers handle the rest. So all I had to do now was to manipulate humidity and temperature in a way that most of my map becomes a desert biome and the remaining is plains or mountains.

Getting these features right is where I reached a wall. The default humidity and temperatures based on perlin noise work really well, but mine didn't. I tried implementing simple weighted random number generators, but without subsampling the result was... interesting.

So then I tried it with subsampled noise. If biomes change from desert to plains at a humidity of 0.3, then having noise uniformly between 0 and 0.32f should mean I have more values below 0.3, which means more desert. That would be something like this:

float[] humidityNoise = noise.noise(facet.getWorldRegion());
for (int i = 0; i < humidityNoise.length; i++) {
    humidityNoise[i] = TeraMath.fastAbs(humidityNoise[i] * 0.4f);

But this still didn't work. I had only one biome over the entire map and that was desert.

Placing Cities

We now come to one of the most essential parts of the project: cities. As of now I have imported all assets from the TutorialDynamicCities module and have made appropriate modifications to my world generator. I still couldn't get the city placed and will work on that in the coming week.

Work to be done

The following tasks need to be finished till the next meeting:

  • Add more biomes to the world
  • Place a city
  • Inspect the marketplace UI bug that the tutorial module has
  • Make the minimap modifications