Monday, April 6, 2009

Rivers


Added river generation. The technique works by taking the perturbed sphere cross-section that is used to generate the base continent shape, and applying an erosion algorithm to it to erode it and create draws and valleys in a watershed pattern. Then a similar algorithm goes over the eroded terrain, modeling water flow and tracking the amount of water flow each cell receives. By taking all cells above an arbitrary cutoff value and setting them to water, I create a pattern of rivers across the land.

There are a few things wrong with this approach. First, it doesn't really model the accumulation of lakes in areas of local minima. Water flowing downhill will fill basins and spill over to continue toward the ocean in real life; but in this algorithm, water flows until it can't flow any further and then just disappears. Another problem this results in is the existence of many watershed patterns that do not empty into the ocean at all.

At some point I plan to switch river generation to a cellular automata approach, that can handle accumulation and spill-over to more accurately model true water flow.

At this point, I'm beginning work on a first version of a savefile format for the world, as it is getting clunky to re-generate the world each time the application runs. I envision a system somewhat like that used by Dwarf Fortress for generated worlds. Players can either go through the somewhat lengthy process of generating a new world, or download one of several existing pre-generated worlds.

2 comments:

Josh J said...

This is cool, I wish I'd clicked through to here from your gamedev journal before now!

Are all of your tiles procedurally done? I've been messing around with procedural generation (as seen at my blog: http://drilian.com/), but you're getting great tileset results, with a great old-school style.

I'm definitely going to have to follow this blog from now on, I love the style of game that this is looking to be :)

Joshua said...

Yeah, the tiles are all procedural. I'll probably do a write-up on what I'm doing there in the near future. I've got a few other terrain types in the works (rocky terrain, snowy terrain, lava, lava rock, etc) to add some variety.

And thanks for your comment :D I love the old school top-down RPGs myself. The first Dragon Warrior was one of the first Nintendo games I ever played, and it, as well as various others like Final Fantasy, had a profound effect on my life.