# Procedural archipelago - Every game has to begin somewhere.

2 favourites
• 10 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
• Since my other major project has become a nightmare of 30+ database tables, I've decided perhaps it's time to take a break and try some lighter fare. As part of that, I've been experimenting with generating procedural islands in C3 using an array and a simple tilemap. Generating a basic set of islands is relatively easy. The hard part, finding the edges and properly applying a beach. And what's an island without a beach?

Here's link where you can see the current results of testing.

Here's a link to a 'zoomed' out view that shows the map generation in semi-real time. You'll barely be able to see the buttons so if you don't know what they are, just click and it'll do the rest.

Here's a link to a zoomed out view that demonstrates both the unpredictable random array generation used in the previous examples and, the 5 random generators used by the Advanced Random plugin. The difference is amazing.

THANK you to everyone who spoon'ed me solutions, ideas and encouragement on this thread:

The journey into the unknown begins.

For those interested, the process for creating these islands is something like this.

2. Fill in Array 3,3 to 197,197 with random numbers.
3. Run through the array 3 times, add up the 8 neighboring cells and set that one to the average.
4. Total all the cells and get an average of all of them.
5. Run through the array and set any cell below the average to the value for the tilemap's water. Anything above the average gets set to the tilemap's square land tile.
6. Run through the array and look for small water 'ponds' that create an issue when placing beaches.
7. Run through the array and look for 'anomalies' that also create issues when creating beaches until all anomalies are gone.
8. Place beaches from one of 12 possible tiles depending on what land and water surrounds it.
9. Plant some random tree sprites, change some random terrain sprites to bushes and rocks.

Finding all of the anomalies that prevented beach placement (and identifying arrangements that caused issues) was the hard part. First, it looks to see if a land tile has at least 4 neighboring land tiles.

If it doesn't, it sets it to water. Then, it looks for and fixes issues like this:

``````X|X|X
0|X|0
X|X|X
``````

or

``````0|X|X
X|X|X
X|X|0
``````

where X is land and 0 is water. In both of those cases, there was no way to properly place a beach on the center tile and have it match the surrounding beaches.

Those above were easy to spot. It looks N/S or E/W or diagonally and see if there was a land tile. If not, put one there to smooth it out. The biggest pain in the ass to find and fix was this one which occasionally popped up.

``````X|X|0|X
X|X|T|X
X|0|X|X
X|0|0|X
``````

It passed by the '4 tile rule' just fine and passed the horizontal and diagonal checks. For that one, I had to create a special rule. For the one labeled T, it checks W and S for land. It then checks SW for water and then, checks N for water. If all those conditions are true, it sets the north tile to land.

So, that's the basics.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• That's incredible! WOW! This is a perfect example of a result one can expect from "C3 + Programming Mind + Creativity" combined!

And I know.. this is only the beginning. So many possibilities ahead! Keep going!

• Might be fun to try that with the Advanced Random plug using perlin with this height=beach , this=land, that=mountain, etc.

• Might be fun to try that with the Advanced Random plug using perlin with this height=beach , this=land, that=mountain, etc.

I looked at Perlin. There's a lot of examples of people using it to generate heightmaps. One look at the wikipedia article on it an I realized I'd need at least a masters degree to translate their gobbledy-gook. I did find a few examples in PHP that I could follow though. Not quite sure where this is gonna go just yet. The plan is a simple but cute survival game. I may throw in a volcano just for giggles. Not sure if I wanna tackle mountains just yet. For now, I'm just goofin off with some free tilemaps and png's I ran across. I'd need to come up with a real tilemap before I tackled elevated terrain.

• This looks good. I can see this as a pc survival game. I think this is a good start and it is always good to just start on something light so you can get the hang of things and learn one bit at a time. Most times we have these huge ideas and want to just jump in right off from the start and then realize we put on too much on our plate. However, it is very good to challenge yourself and set reasonable (not too drastic) goals and plans that you would like to do and make for/in your game. So keep pushing yourself. Your doing fine!

• Came out really well, and it's pretty speedy all in all! I find flying around the little arrow far too satisfying...

You could MAYBE use chunking to make the world gen. real time ( so only generating the visible parts ) but this more trouble than it's worth I think.

One look at the wikipedia article on it an I realized I'd need at least a masters degree to translate their gobbledy-gook.

It's not worth look at wiki for maths stuff, even if the idea is simple the article will be unreadable. Pages for algorithms can be a bit hit and miss. The wiki page on Perlin noise is OK... While the algorithm seems kinda hard it's actually a very obvious solution with a few layers of tricks on top. Also worth noting that you don't actually need to know how it works to use it. It's a magic box you pass co-ordinates into and smooth noise comes out. I wrote a tutorial a while back on the basics of using Perlin noise and the advanced random plugin.

• You could MAYBE use chunking to make the world gen. real time ( so only generating the visible parts ) but this more trouble than it's worth I think.

I got to thinking after I read this that I've already got a way to easily show some of the terrain generation. I have a function that copies the array over to the tilemap. So, I just copied and pasted that function into various parts of the routine and it shows a lot of the map being generated real time. I also set the viewport to show the entire map. There's a link to that version in the OP now.

I'll take a look at your Perlin tutorial today and see if I can make heads or tails of it. While this does work pretty well, it's not exactly what I'm looking for.

Thanks again.

• I wrote a tutorial a while back on the basics of using Perlin noise and the advanced random plugin.

Wow, that was dead easy. I just replaced the starting random array with what the Adv Random spat out.

-> Array: Set value at (LoopIndex("IslandColumns"), LoopIndex("IslandRows")) to round(AdvancedRandom.Ridged2d(LoopIndex("IslandColumns"),LoopIndex("IslandRows"))×100)

The difference was amazing. Added yet another example project using this to the OP.

• Ah awesome! I did some islands experiments when I was creating the plugin, but they were just block colour... they kinda got abandoned. But yours look way better :P

Yeah they are pretty easy to use, they sound way scarier than they actually are. There's plenty of fine tuning you can do to get exactly the style of output you want, if you look at the section where I was creating clouds you can see some things you can try.

Redblobgames did some island generation tutorials ages back using somewhat similar techniques. The technique went something like:

• divide world into zones using voronoi
• use perlin noise to decide the height of each zone ( might want to try scaling based on how close to the center it is as well for a nice island shape )
• zones below a threshold become water
• zones further from the ocean have higher "moisture" levels
• zones "biome" is decided by height and moisture level ( high + wet = snow, high + dry = stone, low + dry = sand )

Incidentally the Voronoi noise expressions return the same value across the whole zone, it's kinda like an ID value. But it isn't guaranteed to be unique. If you do something like `floor(AR.Voronoi2D(x, y) * 256)` you should be able to identify individual zones with that value.

• piranha305 did a plug using Rotjs

Good for dungeons, caves, and mazes.

• 10 posts