top of page
  • justincragg

Hex-Based Map Generation

Updated: Nov 27, 2019

Continuing my new found fascination for map generation after the King Chaser game, I had a go at making a civ-style hexagon map generator. The generator takes into consideration the distance from the equator, rainfall, temperature and erosion. It generates rivers and biomes including; mountains, forests, swamps, tundra and more. The generator is heavily based on a breakdown of Civilization 1's map generation by darkpanda.

At its core the generator is relatively simple, consisting of multiple passes which determine different factors.

First, the generation of the land masses, which is created by drawing a line in random directions, then 'filling in' the land in between the starting location and the new point, then repeating as required. Where tiles are covered multiple times, their elevation is increased. In retrospection, while very simple this method of generation results tends to results in a great deal of long thin land masses. Ideally I would modify this to create thicker, rounder land masses.

The next step is to assign temperature climates, based on their elevation and latitude. This results in four climates; desert, plains, tundra and arctic. After that, the overall moisture level of the tiles are determined. Moving from left to right, then back, a wetness values begins at zero at the edge of the map and increases on ocean tiles then decreases - raining on the tile - depending on that tile's climate. The amount of rainfall can make a tile's climate change from plains, tundra, hills, and desert to grassland, arctic, forest or plains correspondingly. While this is a really interesting step based on real-life processes, it does not work as well for tiles which are close to the edge of the map, as there is less water being picked up from the ocean tiles. In an attempt to combat this, after generating the land masses I shuffled the land across in an attempt to centre them as much as possible.


The next step is the erosion of land which is a very simplistic method - very basically - picks a random number of tiles, determined by the 'age' of the map, and erodes that tile. While there is slightly more to it than that, it mostly just consists of what to do and how to erode in different cases.


Generating the rivers was the next step and it begins by randomly selecting a hill then picking a nearby tile with lower elevation. This is repeated for a random set length or until the river reaches a tile which is adjacent to an ocean, in which case it succeeds and the river is applied. If the river fails to find an ocean, then it is discarded. Forest tiles along the river are then converted into jungles. This process is then repeated the desired number of times. While inefficient this method of generating rivers mirrors real-life relatively closely.

The final step is the creation of the north and south pole land masses, which converts the very top and bottom and a drastically decreasing number of tiles around them, into arctic and tundra tiles.

I had a lot of fun putting this generator together and researching different methods of generating maps and how land is formed in real-life.

 
415 views1 comment

Recent Posts

See All
bottom of page