0%

Some improvements to the tilemap generator

I made a simple tilemap generator, but it was obviously too simple and not enough for my game, so I made some improvements to the tilemap generator. I strongly recommend you to review my last post first.

Decorations

At first, I found the most appropriate value for the Height Noise Map Parameters is the default value, i.e, the Octaves set to 1, the Zoom Out set to 1 and the Curve set to linear. Tweaking these values would give more randomness to the map, but the randomness would get the map messy! What we want is a natural map, not a random mess, but I’ll keep it here for now and I’ll remove it in the future.

So, how to make a natural map if we can’t tweak these values? The answer is the Biomes Diagram. TukanHan uses the biomes diagram to diversify the map in the following way:

1
2
3
4
5
6
7

for(int y=0; y<mapHeight; y++)
for(int x=0; x<mapWidth; x++)
int height = heightMap[x,y]
int temp = tempMap[x,y]
Biom biom = biomes[height, temp]
tilemap.SetTile(x,y,biom.tile)

Obviously, this method can’t make the best use of the height noise map and the temperature noise map.

Let’s start at the beginning. What is the noise map? A noise map looks like

1
2
3
4
5
6
7
11111
12221
12321
11211
12111
23211
22111

Yes, the noise map consists of mountains and plains. So, a height noise map consists of mountains and plains, and a temperature noise map also consists of mountains and plains. So, at first, we can simply divide the whole map into different areas by a height noise map - that’s why we don’t tweak Height Noise Map Parameters - and then we can diversify different height areas by means of the same temperature noise map!

I mean that we can regard the temerature noise map as decorations, i.e. the different height values in the temperature noise map represent different decorations in the final map. So after populating the biomes diagram, I finally got a good map!

biom data

Falloff Map

You might realise, that water and land always appear randomly, with water taking up one half and land taking up the other, like in the picture below. That seems a little weird. Most of the time what we want is an island surrounded by water, or a patch of grass covering the land.

I learned a trick to deal with the problem from Sebastian Lague.

A falloff map looks like

falloff map

The key point is to substract a falloff map from a noise map. For example, if we have a noise map, like

nosie map

After applying the falloff map to it, we get

nosie map1

How to generate a falloff map? Sebastian Lague gives a function

falloff function

The feature of this function is that it starts at the diagonal of the square and decreases from 1 to 0, and the closer you get to the centre, the faster the value decreases to 0. This is good. But sometimes it consumes too many values on the edges. If we use the terminology of a css, that means that its padding is sometimes very large, so I would recommend setting A and B as controllable parameters to control its padding.