Question

I'm making a game with a procedural map, and I'd like to apply this way of doing :

Procedural Island Generation

It's easy to implement and the results are what I'm looking for.

The only part I'm stuck with is the part 3, when I have to go around in circles and randomly change water to land, with a higher chance for the water to change into land when it touches a lot of land.

I've tried to do like this :

if (rand() % 10 < 3 + countAdjacentTile(x, y, LAND))

the countAdjacentTile function just counts the number of tiles marked as the third parameter around the tile specified with the x and y coordinates.

So there's still a chance for a water tile to change into a land tile if there's no land around it, and the chances are upper if there is land around.

But it gives me this :

enter image description here

while it gives this on the link I gave earlier :

enter image description here

I'd like to have the same kind of branches. Do you know the name of an algorithm for this ? I've read this : Exponential Distribution But that's not really talkative for me...

Thanks for reading so far.

Était-ce utile?

La solution

How countAdjacentTile() works? Does it count tiles on diagonal, or just 4 neighbours? If you count diagonals try don't doing this. Also try tune constants - that 10 and 3, it's hard to say which values will be good without this code, just check some combinations and choose best result.

Autres conseils

You might want to write a function giving the density based on the distance to the centre of the island. Then use this density value to weight the threshold defining if an element is land or water.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top