Wednesday, March 09, 2005

Yesterday the internet died but it's back again today. I did a little work last night on trying to detect continents that the map generates ... but it doesn't give the correct answer and it's gridingly slow.


The Continents are too "splodgy" (it's important to give formal defintions :D)
The sea is too empty - boring to explore!

Possible Solutions

1. Alter border check

Instead of throwing dirt out to the 8 square border around a grid point, now and again throw the dirt randomly further. Therefore generating mini-islands.

2. Temporal Seeding

The intial seeding is given a third dimension time. If you put a seed in towards the start it grows to full continent size. If you put it in grownAmount-1, it's going to be a small island. So if you increase the number of seeds and space them over time, then there'll be more diversity.

3. Limit Seeds Proximity

Do a check the prevent the seeds being seeded within a certain distance from each other. Though this won't really create many islands.

4. Recursive Application

Grab areas of empty ocean and apply a short run with fewer seeds to that subsection of the map.

I Chose Solution Number 1

Why? Because it's the easiest to implement.

To the top of GetRandomOffset I addec the following.

int odd = random.Next(0,50);
if(odd == 1)
return random.Next(0,100);

So when grabbing a random border there's no a 1 in 50 chance that you'll be given a random number 0-99. So this means the border can throw out random islands.

I ran this and it caused far too much "decay-iness" (back to those formal terms. There weren't enough whole continents, and hardly and continent seperation.

So I changes 50 to 100 but the problem remained.

Well I thought - this isn't good! What's the problem?

And the problem was that these seeds where being put down too early. Therefore I was getting large continents rather than the small islands I was after! So what's the solution to this?

Well I only allowed the borders to go crazy after half the map was generated - that way the seeds are never going to grow into massive continents instead they'll stay as exciting islands - which is what we all want.

So I had an extra argument passed into GetRandomOffset saying how far we were through the growth. Once we were over half way through I'll allowed the borders to now and again be thrown out in a random way.


Are minor and would not effect my final game. The previous system we did not have to known the Growths half way point - therefore we didn't need to have a pre-ordained growth amount. We could grow a bit, have look, if it needs a bit more growing we could grow it more.

We cannot do that with this system (we kind of can but the results are bad) because we need to know the full growth rate ahead of time. At the half-way point through the growth we can start seeding the islands.

Continent Detection

After generating the world I'd actually like to identify the independant land masse. My current algorimth is broken but it's what I'm thinking about currently.

Final Notes

I also modified the code so that it allows "wrapping". That is a continent will not be confined to the edge of the map. It's spread will merely wrap around to the other side.

I also generalized the code in such a way that it would be easily portable to my game. (Though it does look a little arkward for just fooling around with a bitmap.)

After continents are put down I may added some rivers.

Also coast. I'd imagine an actual coast "cell" would be 75% land.
Post a Comment