### Author Topic: Perlin-Free world generation  (Read 2415 times)

#### Scott_AW

• Mr. Polyvector
• Posts: 214
##### Perlin-Free world generation
« on: 2010-Oct-15 »
I was somehow interested in world generation, while playing Dune 2000(its free now) and wasting time.  Then I had a bunch of thoughts that eventually led me to world generation.

I'll save you from the chain-like tangent that brought me to this....

Anyway I first started looking it, checking out perlin noise.  Now I kind of get it, but then not enough to feel comfortable using.  So I started looking for, then found a nice alternative.  Unfortunatly I can't recall the link, but it had a nice few sentences that described how you can generate semi-realistic worlds with a simple alogorithm.

You start out with a world array and a stack array for storing positions.

Fill in a few random places with land and water tiles, saving those locations in the stack.

Then scan through the stack, checking 8 direction around of tile and then setting them up either land or water.  If the home tile is water, all adjacent tiles turn to water.

Code attached at the bottom, references to images in the demo above.

Its not perfect perfect, but I'm sure with a little toying around you can get it to do what you want.

Oh, and add this line after //set grassy areas in sand
Code: GLBasic [Select]

// Remove sand from grass
IF world[sx][sy] = 2 AND (range[0] > 1 AND range[1] > 1 AND range[2] > 1 AND range[3] > 1) ; world[sx][sy] = 3 ; CONTINUE ; ENDIF

*10/17/10
Heres a more recent screenshot/demo, I plan on uploading the updated code sometime soon.

Photoshopped the mini map into that.

« Last Edit: 2010-Oct-17 by Scott_AW »
Current Project, Orbital Contract Defense

#### Hatonastick

• Dr. Type
• Posts: 474
##### Re: Perlin-Free world generation
« Reply #1 on: 2010-Oct-18 »
What would be interesting is to use a Perlin-like algorithm with a very low noise level as a first pass, then have this algorithm clean it all up.  Looking at your screen shot there are obvious patterns so it currently isn't really as random as it should be -- assuming that's due to the random number generator and not a fault in the algorithm.

Another possibility is to see whether the Mersenne Twister PRNG (http://www.glbasic.com/forum/index.php?topic=2821.0) as a replacement RNG makes any difference to the output.

Pretty cool though what you've got there.  Generated content has long been an interest of mine.
Mat. 5: 14 - 16

Android: Toshiba Thrive Tablet (3.2), Samsung Galaxy Tab 2 (4.1.2).
Netbook: Samsung N150+ Netbook (Win 7 32-bit + Ubuntu 11.10).
Desktop: Intel i5 Desktop with NVIDIA GeForce GTX 460 (Win 8.1 64-bit).

#### erico

• Community Developer
• Prof. Inline
• Posts: 4240
##### Re: Perlin-Free world generation
« Reply #2 on: 2010-Oct-18 »
that loooooks reaaaaly interesting! congrats!

#### Scott_AW

• Mr. Polyvector
• Posts: 214
##### Re: Perlin-Free world generation
« Reply #3 on: 2010-Oct-19 »
Still needs some touching up, I'll wait til it produces a little better.

Might try it with other map generation types.
Current Project, Orbital Contract Defense