Modding: World Map Generation

This article is updated for Update 14.

The world map generator settings are defined in the **WorldMapGen.txt** file.

In this file you can configure the world map creation algorithm.

## Biomes

The world map generator creates a world with several biomes.

Biomes themselves are defined in the Config.txt file, and affect the difficulty of encounters and scavenge within them.

Biomes also determine which scavenge locations spawn in them.

## Spawning Map Locations

In order to define which map locations spawn in every biome, use the following format:

```
worldgen.biomes.game.city.objects.hospital=0.1
worldgen.biomes.game.city.objects.school=0.1
worldgen.biomes.game.city.objects.residential=0.15
worldgen.biomes.game.city.objects.factory=0.1
worldgen.biomes.game.city.objects.supermarket=0.1
worldgen.biomes.game.city.objects.church=0.05

```

In this example, every tile in the rural city has a 10% chance to spawn a "hospital" or "school" location, 15% chance to spawn "residential", location, and so on.

These chances are absolute and not relative to each other. The total values of the biome should never exceed 100%. If no location is selected, the tile remains empty.

In the example above, the total of all values is 60%, so there is a 40% chance that a city tile will be empty.

See Modding: Map Locations for more information on defining the map locations.

## Generating Biomes

Generating biomes is a more advanced topic and is not necessary for adding new scavenge locations. You may simply add new scavenge locations to the existing biomes.

### Generated Perlin Noise Maps

Biomes are generated using several Perlin Noise maps (also Height Maps). In every such map, each tile has a value between 0 and 1. These maps have different "Frequency" values. Higher frequency values create maps that are more "zoomed out", creating a map with more mountains (assuming the value represents height), with steeper slopes, while lower frequency maps are more "zoomed in", creating more hills and flatlands.

The generated maps are defined using the following format:

```
worldgen.perlin.mapsfrequency.noise1=5
worldgen.perlin.mapsfrequency.noise2=7
worldgen.perlin.mapsfrequency.noise3=10

```

The example above creates 3 maps, called "noise1", "noise2" and "noise3", with frequency values of 5, 7 and 10.

### Combined Perlin Noise Maps

The generated maps may then be combined together to create new maps. This allows us to combine maps with different frequencies, to create a more varied map that is less uniform, and contains areas with steep slopes, and others with flatter terrain.

```
worldgen.perlin.combinedmaps.noisecombined.noise1=0.5
worldgen.perlin.combinedmaps.noisecombined.noise2=0.3
worldgen.perlin.combinedmaps.noisecombined.noise3=0.2

```

The example above combines "noise1", "noise2" and "noise3" into a new map, "noisecombined".

In the combined map, "noise1" has a weight of 50%, while "noise2" has 30% and "noise3" 20%.

### Generating the Biomes

We may then use any combination of the maps above, either generated or combined, to generate the biomes:

```
worldgen.biomes.rural.noisemax.noisecombined=0.5
worldgen.biomes.rural.noisemin.noisecombined=0.1

```

In the example above, a tile will be defined as rural, if it has a value of at least 0.1, and no more than 0.5, in the combined map "noisecombined".

A single biome may have conditions in more than one map. For example, if we generated two maps, a "height map" and a "humidity map", we could use the following definition to declare a "forest" biome:

```
worldgen.biomes.forest.noisemin.heightmap=0.3
worldgen.biomes.forest.noisemax.heightmap=0.6
worldgen.biomes.forest.noisemin.humiditymap=0.5

```

In this example, a tile will be defined as "forest", only if it has a height between 0.3 and 0.6, and also has humidity value above 0.5.

If a tile meets the conditions of more than one biome, it will be defined as the first biome that appears in the configuration file.

You can also specify the min/max in percent, that way you can guarantee the number of tiles for the biome.

```
worldgen.biomes.game.city.rules.1.distances.15.noisemin%.cty=0.92

```

In this example the tiles that have a value larger than 92% of the other tiles (noisemin% 0.92) will match the rule, so exactly 8% of the tiles will be city tiles.