Sign in to follow this  
  • entry
    1
  • comments
    2
  • views
    5138

Procedural Island Tilemap Generation

Sign in to follow this  
wg/funstorm

3021 views

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.

[sharedmedia=gallery:images:2732]


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

1. I start off with a 16x16 grid of water.
[sharedmedia=gallery:images:2733]

2.. I mark half the middle 1/3rd of tiles as land.
[sharedmedia=gallery:images:2734]

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).
[sharedmedia=gallery:images:2735]

4. The tiles get subdivided into 8x8 smaller tiles each.
[sharedmedia=gallery:images:2736]

5. Only the middle 50% of the newly subdivided tiles are kept as land, the rest becomes water again.
[sharedmedia=gallery:images:2737]

6. I connect all the land centers with each other.
[sharedmedia=gallery:images:2738]

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.
[sharedmedia=gallery:images:2739]

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.)
[sharedmedia=gallery:images:2740]

9. With the shape detail added, it's time to start modifying the terrain types. First, every tile touching water is turned into sand.
[sharedmedia=gallery:images:2741]

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.
[sharedmedia=gallery:images:2742]

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.
[sharedmedia=gallery:images:2743]

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.
[sharedmedia=gallery:images:2744]

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.
[sharedmedia=gallery:images:2745]

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.
[sharedmedia=gallery:images:2746]

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.
[sharedmedia=gallery:images:2731]

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!
Sign in to follow this  


2 Comments


Recommended Comments

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:

http://www.gamedev.net/blog/33/entry-2249260-procedural-islands-redux/
http://www.gamedev.net/blog/33/entry-2249282-hooking-into-the-tree-to-build-a-map/
http://www.gamedev.net/blog/33/entry-2249322-procedural-island-demo/

Share this comment


Link to comment
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!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now