# Random Map Generators...Again!!!!

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm talking about tile based games like civilization. I know map generators have been talked about before....but i have a specific question. I know all about doing height maps to generate the land etc. But the part i'm stuck at is specifying a percentage to be land, once the height map is generated with a min and max height i then pick a level at which i place land....so maxheight * (100 - land_percentage) / 100 this would give me a value to place the land at. But what i don't seem to be able to cater for is that fact that the height map could have generated most of the heights below my land percentage height value. Is there another way to generate height values based on a land percentage...or even another method to generate a random map. Cheers.

##### Share on other sites
you could always generate your land 100% above your water threshold and then "poke" holes in your land for lakes and use a cicular or linear interpolation around the edges if you wanted it to be and island. Working it in reverse this way as opposed to generating in one fail swoop would probably be easier.

##### Share on other sites
another way could be to simply generate athe heightmap with greater precision, and then alter clip height after that (and then rounding to low precision), which would give you much greater, or add some equation to it.

however, this can prove to be troublesome in some implementations as you could want certain areas to have different properties.

##### Share on other sites
The way I did it was to create the land as flat, just land and ocean. Then raise the land. We don't really care what the heights are below sea level, unless you are going to have sea level change during the game.

The solution to the problem as you have it now as I understand it would be to have a loop:

sealevel=0
landperc=100
while(landperc>desired_landperc)
{
sealevel++
calculate landperc
}

A little testing should show you a safe level to start sealevel at to reduce the number of iterations.

##### Share on other sites
The better thing to do would be to generate the hieght values, and then use a binary partition [more later] to 'pick' a sea level which generates the amount of land you want.

The binary partition generally goes like:

test (max+min)/2 :if land > land_wanted    raise min to (max+min)/2;else if land < land_wanted    lower max to (max+min)/2;else    break [solution is (max+min)/2]...repeat until solution or max-min < some_limit

This way the hieght generation can be done the same way, no matter how much land you want. The sea level just varies to produce the closest result to what you want possible.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633317
• Total Posts
3011336
• ### Who's Online (See full list)

There are no registered users currently online

×