Procedural Island Generator

I made a little Windows app to test out some code for randomly generating simple islands to be used as the basis for a tile map in a 2D game. Essentially it’s just recolouring some fractal noise generated with a standard midpoint displacement algorithm with a few added tweaks.

Download: islands.zip

In this instance a 128×128 array is seeded with a random value every 16 rows and colums then each 16×16 square is filled in using the midpoint displacement method.

Seeding the border with zeroes before filling in the 16×16 squares guarantees that the result is always an island completely surrounded by water.

Setting the central point to the maximum value makes the generated islands a little more consistent. To ensure that every part of the generated terrain is accessible to the player I remove any isolated sections by performing a simple flood fill from the center in order to identify any disconnected points above the water level.

Finally a boundary of shallow water is added around the coastline to make things look a bit nicer.