Jump to content

April 2017 »

232425262728 29

Recent Entries

Recent Comments

- - - - -

Procedural Island Tilemap Generation

procedural flash tilemap flixel
4: Adsense

Procedural Island Tilemap Generation I spent the first 8 hours of Ludum Dare 24 creating a random island generator. Unfortunately due to a series of disasters, I wasn't actually able to finish the gameplay in time for the deadline and didn't submit my game, so this is the one good thing that came out of the whole experience!

It was my first ever attempt at something like this... I always shied away from anything procedural in the past because I thought it would be more complicated than it is. But I decided it was time to try and overcome those fears and try to generate islands that:

1. Look natural (= not computer generated)
2. Look unqiue
3. But still similar enough that the gameplay experience is comparable

All things considered I'm reasonably happy with the result. I wish I had more time to add features (lakes, river, mountains, deserts, etc) but most of the time it creates something that looks convincing enough. What do you think? Did I achieve my goals? Here's a couple examples that it generated.

island examples

So how is it done? Here's a quick step by step.

1. I start off with a 16x16 grid of water.
procedural island step 1

2.. I mark half the middle 1/3rd of tiles as land.
procedural island step 2

3. Then I go around in circles for the next 1/3 of tiles, growing the circle each time and marking random tiles as land. The more land a water tile is touching, the higher the random chance of it becoming land. This causes the land to become less as I move away further from the center while still mostly staying connected (but with the occasional island here and there).
procedural island step 3

4. The tiles get subdivided into 8x8 smaller tiles each.
procedural island step 4

5. Only the middle 50% of the newly subdivided tiles are kept as land, the rest becomes water again.
procedural island step 5

6. I connect all the land centers with each other.
procedural island step 6

7. And fill in the between connections. The basic shape of the island is now complete and it is time to make it more detailed.
procedural island step 7

8. To add detail, I use a similar method as before. I just go around in circles on each individual 8x8 tile that has land on it, randomly changing some water to land. Again, the chance of a tile becoming land is proportional to the amount of other land tiles it is touching. (At this point I'm going to stop using the hand-drawn diagram I have been so far because it's getting too tedious and switch to actual generated images, so that's why the island shape suddenly looks different.)
procedural island step 8

9. With the shape detail added, it's time to start modifying the terrain types. First, every tile touching water is turned into sand.
procedural island step 9

10. I go around the entire map twice, randomly changing some grass tiles that are touching sand into sand. As always, the chance of a tile changing is proportional to how many other tiles of the same type it is touching.
procedural island step 10

11. Now for some forest! I go back to the 16x16 grid I was using earlier and count how much grass each 8x8 tile in the grid has. If it is at least 25% grass, it gets marked as a potential forest starting point.
procedural island step 11

12. From the valid tiles, I pick 40% at random. Then I randomly choose a spot on each remaining 8x8 tile as a starting spot.
procedural island step 12

13. To grow the forest, I go in circles between 2 and 8 times around each starting spot, randomly turning tiles into forest. As always, touching more forest = greater chance to become forest.
procedural island step 13

14. For the final step, I pick 15-30 random tiles on the map as rock starting spots, and go in circles 0-5 times to grow them.
procedural island step 14

And that's it! The island is complete.

Bonus: this is what it looks like in-game at gameplay resolution with trees, berry bushes, and bugs.

I think there's a lot of room for improvement here. What you see took me 8 hours, and if I had more time I would:
  • Add a a step between 7 and 8 that curves the angular sections to look more natural.
  • Add features such as lakes, rivers, etc.
  • Add terrain variety: deserts, snow etc.
Anyways, if you're looking for a quick and easy way to generate some okay-looking islands I hope this helps you. I hard a hard time finding good articles on the subject and didn't have time to do a lot of research. The article that probably helped me the most is Procedural Level Generation for Artists. It made me realize that the easiest way to exert some control over what the island would look like, while retaining a good amount of randomness, would be to fix and hand-tweak a couple variables (eg my 16x16 starting grid, filling the center 33% with land, etc). Other 100% randomized methods (for example) don't look or play as well, but I did learn to subdivide a large grid into a smaller one from it. I also decided against fancier algorithms like perlin noise (as Notch famously uses in MineCraft) due to time constraints.

Questions? Suggestions? How would you have done it? Leave me a comment!

Sep 05 2012 10:39 AM
If you're interested, you might want to check out the dev journal of JTippetts here on gamedev.net. He is working on a game that uses procedural island generation, and some time back he wrote some articles explaining his own process, which uses fractal noise:

Sep 05 2012 12:23 PM
That's awesome. Definitely a step up from what I'm doing. This was just my first attempt at something procedural and I hope eventually I can get to his level.

Thanks for linking!

Note: GameDev.net moderates comments.