Re: Random Map Generation

This is a very old article. It has been imported from older blogging software, and the formatting, images, etc may have been lost. Some links may be broken. Some of the information may no longer be correct. Opinions expressed in this article may no longer be held. wrote:

My first prototype for doing this doesn’t give good results, the map being far too random, can someone help me out or point me to a good resource please?

Real geography is not random.

First, take a grid, say 1001×1001 is size. Now find the middle square of it and set it to have a height of 1m above sea level. Now spiral out from that square, creating a height for each square using an algorithm like this:

Look at the adjacent squares, but only the ones that you’ve already assigned a height to!
Find the average (mean) of height those and call it $h.
Now here’s where we add a bit of randomness:

There is a note way down below about step 3. Don’t read it yet. Wait until you get there.

OK. Now you have a 1001×1001 grid of various heights. Anything below 0m in sea level should be water.

Find the two highest grid squares. Make them and the adjacent 16 squares into ice.

Find the four next highest which aren’t already covered with ice. Add rivers flowing from them. Here’s how you chart a river’s course from its origin.

You’re on a particular grid square.
Are you at the sea yet? If so, stop.
Look at the 8 adjacent squares. Which has the lowest altitude?
The river should flow to that square. Go to step 1.

Now you know where all the water is, find the ten squares furthest from any rivers, ice and ocean. Make them into desert.

Find areas that are between 12m and 25m above sea level and are not either ice, river or desert. Make them into forest.

Select a random two of the four rivers. Place a city where they meet the sea.

Select a random two of the four rivers. Place a city half-way between the origin and the sea.

Place two cities at any random part of the geography that is not under water.

You get the idea. For any other geographic feature, you should be able to think of a method of placing it randomly, but realistically.

Having done all this, you might realise that your map is now either too boring, or too unrealistic. So here comes my note about step 3. Most of the randomness that is introduced into the map is introduced here:

If you want to make it more random, then either decrease ’20’ or increase ‘3’ (or both!). If you want to make it more boring, then do the reverse.