Land Ho! Generating a Procedural Map

Hi all! On the last week of September I worked on finalizing the map generation. I’m really happy to hit this milestone as I move towards creating a playable prototype of the game. Currently there are three land types: Forest, Grassland, and Rocky Desert. My challenge was to create a map that would feature all these land types and distribute them in a way that looks reasonably natural.

Leaving Tilemaps

My first decision to in generating maps was to abandon Unity’s tilemap creator. While Unity’s native map creation is very flexible, one thing was missing – in Arbolands, the land itself is changeable. Trees will grow, fertility levels will change and characters will interact with the land. Unity’s tilemaps seemed to be geared more towards designing the terrain for pre-build levels. If I were to keep this system, I would still have to create the interactable land objects on top of the Unity Tilemap, which seemed redundant and over complicated.

Cartesian coordinates and Seed Forests

So, over the past month I created my own system. It is based on a cartesian grid with X and Y coordinates identifying where each land tile is. After this was completed I had to come up with a placement algorithm for forests. In Arbrolands, most of a player’s strength depends on how many forests the player has inhabited. As such, I wanted forests to be somewhat scarce and well distributed. I created an algorithm that can place any number of forests tiles down on the map. This algorithm had to make sure that forests aren’t placed in the same tile, and that their distance is not too great or too small from each other. I used similar logic to the algorithm I developed last month for plant placement and the result seems nice and organic.

Filling in the blanks

After the first forest tiles are placed, another method kicks-in to fill the land tiles between the forests. The algorithm rotates clockwise around each forest, filling in new land tiles where there is none. This process continues until the bounds of the map are reached.

The bounds of the map are defined by a margin around the seed forests. If this margin is set to zero, the most far-flung forests will be on the edge of th map. If the margin is set to a non-zero value, lets say 2, the most far-flung forests will have two more tiles between them and the edge of the map. Beyond the map edge, the game will create no further lands, creating a nice, rectangular map region.

So that’s how it’s done. In the coming weeks I’ll be starting to create interactions between the troops and the land. Growers, you’re up!

Leave a Comment