Search code examples
algorithm2dtileprocedural-generation

2D tile map generation


For a 2D tile engine I'm working on map generation algorithms. I tried heightmap generation :

  • hill generation
  • Perlin noise
  • Diamond-square

Suitable for tile maps that have a height component but I have sprites like grass, sea, desert and they should be placed like :

  • everything starts from ocean
  • islands are placed in the middle of the map (this is where algorithms that I tried failed mostly)
  • deserts are generated (they should be like random spots around)
  • mountain and hill chains are spawned (they should be like snakes)

What approach should I try?

I solved deserts, hills and mountains (for example mountain starts from a point then follows a direction with a chance of turning) but I'm failing with the generation of islands (which should be customizable to be just a pangea or many degrees of size).

I'm looking for something like the Civilization algorithm:

alt text


Solution

  • [hill generation, perlin, diamond square] ... this kind of algorithms seems suitable when dealing with tile maps that also have a height component but this is not my case.

    But it is your case. Mountains are higher than plains, and plains are higher than water.

                            ___/
                        ___/ ___ Mountain cutoff
                    ___/
             ______/
        ____/ ___ Water cutoff
    __/
    

    You can quantize your data so that if it is between one set of levels, it is counted as one type of tile, whereas when it is in a different range, it is a different type of tile. You'll be throwing out some detail, but you'll still get outlines that match the type of noise that you're generating.

    It'll probably take a good amount of tweaking, and will require you to generate other land features (besides impassible mountains) yourself, but you'll have to tweak a lot with any content generation solution.