Using perlin noise to create a procedural island for a tile-based game. My map is stored in a 2d array, with each tile having a type (deep water, shallow water, beach, grass, forest, hill, mountain).

What would be the most efficient way to go through my map, after it's generated, and smooth out the edges of the terrain? Using a tileset, we run into issues with a 1x1 tile that sticks out by itself.



3 Answers 3


I see 2 possibility :

  • work on noise function , use less octaves.

  • after noise generazion , process your map , if a tile A is surraunded by 80% of tile B, transform tile A in B.


As your map information is basically only height, you can simply convolve the map with a blur filter. There are several, computationally easiest might be a mean filter which assigns to each tile the average of all surrounding tiles:

height(x,y) = ROUND( (
    height(x-1,y-1) + height(x-1,y) + height(x-1,y+1) +
    height(x,y-1) + height(x,y) + height(x,y+1) +
    height(x+1,y-1) + height(x+1,y) + height(x+1,y+1) 
    ) / 9)

You say that you have problems with 1x1 tiles. Why not simply remove them, say by turning them into the same tile as one of its four immediate neighbours?

for tile in map:
    if tile != tileAbove and tile != tileBelow and tile != tileLeft and tile != tileRight:
        tile = tileLeft

On that note, the practice of transforming tiles based on their neighbours, as a general technique, is known as cellular automata, the most famous example being Conway's Game of Life:

conway's game of life

But is also a popular technique for procedurally generating "cave-like" maps:

cellular automata cave

I would have suggested an iteration or two of cellular automata, certainly if your requirements change, but as it is your requirement is very simple, so only a simple algorithm is required.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .