In this post I introduced my erosion-based model for building landscapes -- and promised details on how it works. Here's how.
Erosion occurs in every time cycle of the model. When it does, every cell of the map "decides" whether to erode down, based on a simple set of rules. These rules only "know" about the cell itself and its immediate neighbors. All decisions are therefore local (as in all cellular automata models). Elaborate rules are conceivable, but hardly give better results than simple ones; and that's the beauty of this method.
I experimented with various rulesets, to see which would generate landscapes with some amount of realism. The best results actually come from using several methods in sequence. I'll detail these below, with a simple example island -- but in just one dimensions (rather than two) for simplicity.
Our island is made up of five land tiles, each with an altitude between 1 and 3; featuring a high plateau in the East.
This simple method softens the coastal edges of a landmass, eliminating any sharp cliffs. The rule is: check for any sea tiles among your neighbors (sea being a tile with an altitude of zero), and if you have any, erode.
The numbers above each tile are the results of the calculation. A "1" tile will erode while a "0" will not.
Here we get to something more interesting. The rule is to count how many neighboring tiles are not abutting; that is, how many have a lower altitude.
Small peaks of land will erode quickly with this method, while flat areas and depressions will not. As with most methods, I actually use a random element, so even unsupported tiles don't always erode.
The previous rule ignored the heights involved, which this method takes into account: each tile finds the greatest difference in height to a lower neighbor. The greater that drop-off is, the more likely erosion is. If all neighboring tiles are level with, or higher than, the tile in question, there's also no erosion.
The effect is to smooth away sharp features, like weathering from wind and rain. Small features, even small ones, can persist though (unlike with the last method).
Now we come to the most complex of the models, which really warrants a post of its own. This is more than just simple rules looking at neighbors: a separate sub-model is turned on, which tracks the flow of water over the surface of the land. This is also a cellular automata though, and so functions fairly similarly.
In essence, rain falls and water accumulates on each tiles. A ruleset allows each tile to decide in what directions that water will flow.
I experimented with several possibilities, but the best results happen with a basic approach: 100% of the water in each tile flows into the lowest neighboring tile; if all the tiles are at the same level, distribute the water evenly among them. After the flows are calculated, the water levels are changed accordingly, and new flows calculated.
This flow process occurs many times, to let most of the water go to sea, just to calculate one time step in the erosion model.
Actual erosion can then be calculated in several ways, based on what tiles have had the most water flow through them, or the greatest amount of water at any one time. I have found that good results come from establishing a threshold for "high flow" and then tallying how many times a given tile experiences that -- and using that tally to increase the likelihood of erosion.
Like this, rivers and streams are gradually carved out of the land, as water finds a way to the ocean (or sits still in lakes).
All these methods only remove land: their use is in modifying a continent or island that has been generated with some other tool: like Perlin noise, the ramp hills I discussed previously, or something more sophisticated. But they're indispensable for turning those raw, law-scale globs into more refined, and realistic-looking worlds.