Our Random Map Generator


17th December 2017 – Perry

“Tunnels had me pacing for a number of hours. How was I going to make them look natural?”

It was a spur of the moment decision to build a random map generator and generated maps were never going to be a replacement of Martyn’s fine map creations. We had already decided on a hand-crafted campaign (with a few procedural elements) but map generation was always going to be something extra in the main menu.

The idea for a map generator popped into my head, I passed it by Martyn and then I got to work. I had a vague impression of how I was going to do it and Martyn will be proud to hear I used his hand-crafted maps for inspiration. The generator starts by filling the map with dirt as well as underground lakes and rivers. Then it carves out caves for players to spawn in, and then tunnels/paths between caves. Tunnels had me pacing for a number of hours. How was I going to make them look natural? And which caves should be connected to which?


I knew units already made use of a ‘pathfinding algorithm’ (a system I’d built from my days at university), so I decided to adapt that to generating tunnels but that still didn’t help me make them look natural, it just gave me the power to manipulate them. So, I got tinkering, I gave it some slack and random preferences and that seemed to make it weave rather than just draw straight lines. I randomised whether or not the tunnel/path would be blocked in places. I also kept a record of each tile along the path and randomly chose spots to add ‘features’ to, like small collapsed caves, bunny warrens, mushroom patches, etc.. Next was to decide which caves should be connected. I went with 3 different styles: web, ring and chaos! Web picks the central-most cave and connects every other cave to that one. This seems to generate some rather pretty designs but whoever spawns in the middle has a serious disadvantage! Ring connects caves in a single loop, where each cave is connected to precisely 2 other caves. This was a difficult algorithm to get right but I won’t go into details about that now. Last but not least, chaos simply connects random caves together until any cave could (in theory) walk units to any other cave. Thus, the paths were done! Well, until at some point I decide to add new features to it.

Random Generation

After connecting caves, I then had a design choice to make. How fair should the generated maps be? Should every spawn cave contain a spring, a mushroom patch and roots? I still don’t have the answer, but I decided to make it fair for the time being and perhaps we’ll add optional starting conditions later.




The final steps for the map generator is to inject mineral veins, grow roots, carve out a few more random caves and drop in some Dwarves and Goblins and then the map is ready!

Nysko Path Styles

Hope you enjoyed this post. Thanks for reading!



Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.