skulkrinbait@googlemail.com 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:

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

<?php
if (rand(1,2)==1)
    $h -= log(rand(1,1000000));
else		
    $h += log(rand(1,1000000));
if (rand(1,20)==1) $h *= 3;
1?>

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.

  1. You're on a particular grid square.
  2. Are you at the sea yet? If so, stop.
  3. Look at the 8 adjacent squares. Which has the lowest altitude?
  4. 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:


<?php if (rand(1,20)==1) $h *= 3; 1?>

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.