Death on the While
Probably my most tortuous title pun yet, put it down to tiredness. I’ve been working on the rivers some more and managed to set up non-exiting while loops about half a dozen times yesterday and today. The debugger in Boa is not the most robust of items, and the process of getting to the problem can be pretty long-winded and is also prone to frustrating failures where the debugger will just get “lost” and refuse to stop at a breakpoint or step back up to the level you want if paused in a low-level call. The bugs are my fault, of course, but tracking them down sucks more than it needs to.
So where has it got me? Well here is a first pass water-flow with the new method for calculating runoff on all cell neighbours:

Which produces this set of stream/river cells (you’ll have to use your imagination, I’m not intending to flood entire cells with violet for the actual visualisation).

Notice how some of them just end. This is because the river has nowhere to flow, it has hit a local minimum. So here’s where I do some fudged erosion. I search through the cells and find any with reasonable flow and no exit route. Now, I pick off the highest of these cells and blast the lowest cells that is opposite the main entering flow down to a height slightly below the blocked cell. I then re-run the water-flow calculations. This process is repeated until no cells with high flow are blocked. This takes a long time, too long, and I need to work on the performance as well as the visual results but here they are anyway.
First the terrain view.

Not great, but all I’m doing is painting a cell violet if it has a flow greater than a certain threshold. Notice where the three flows end below the mountains near the yellow low land. There should be a lake there as the flows are all converging on a dip in the land and have hit sea-level. I need to add the flooding algorithm to allow this. Given the limitations of my current terrain visualisation, the flow layer shows a much better picture of what’s going on:

There’s a lot that can be gleaned from the data there in terms of the available water in a cell. I’m confident that with some tweaking, I’ll be able to generate freshwater lakes as well as rivers and streams and produce visualisations that look like reasonable landscapes.

