Drainage Basins

I managed to use a bit of free time during the week to add some extra event conditions and complete the discovery modding feature for the next release. So this weekend I started working on the last feature for 0.3.3 in earnest and implement drainage basins. My principal goal the last two days was to implement an algorithm that looked realistic enough without having to do any kind of deep or complex hydrologic simulation. After several false starts and a lot of tweaking, I came up with a decent algorithm that is pretty quick (delays terrain generation for no more than 2 seconds on regular maps) and appears natural enough. 

The algorithm is pretty standard, it first looks for the highest points on the map that receive any kind of rainfall and then propagates the rainfall downward through any adjacent cells, accumulating more rainfall water along the way. The biggest deal was optimizing the algorithm to properly calculate and assign water distribution on each cell in the least amount of steps as possible (most cells just get visited once, but a few might get visited between 5 to 10 times to recalculate water influx). To help visualize this initial implementation, I tweaked biome distribution to be influenced by the amount of water on the soil:

I also added a new overlay to visualize drainage:

The brighter spots represent the points where water drains into and, as you can see by the black spots on the map, the biome generation algorithm needs some work because it doesn't know what to do with places where water exceeds the maximum amount tolerated by biomes. I have to work on a proper solution by possibly assigning rivers or lakes to these over-saturated water spots. 

Next week I'm going to focus on tweaking the biome generation algorithm to add rivers, lakes, and ways to visualize them. Also, the biome mods and layers need to be tweaked to distribute more realistically on the new irrigated maps. After that, I need to work on the map editor tools to be able to work with water drainage and also make sure that once the simulation starts running, human groups can interact and make use of rivers. I'm not sure yet how much time it's going to take to do all this work of this but its going to be quite the ride for sure!

Get Worlds: History Simulator

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.