Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Basic water algorithm when dealing with flat terrain?  (Read 1260 times)

rucksackjack

  • Bay Watcher
    • View Profile
Basic water algorithm when dealing with flat terrain?
« on: December 11, 2009, 11:44:28 pm »

Hello,

I'm in the midst of developing a (vaguely) Roguelike game and, mostly just for kicks, decided that it would be nice to implement water into the game which would hopefully behave roughly like the water in DF. I am, however, extremely terrible at figuring out even remotely efficient algorithms for things like this, so this is where you folks come in.

As my game is entirely 2D, can someone knowledgeable about this subject explain approximately how the water in DF works, or might work, when ignoring any Z-level-related complications? I.e., if in one frame I have a bunch of variously-leveled water lying around on a flat surface, what's the basic algorithm that should be applied to it between that frame and the next in order to create reasonably DF-like flow of the water?

I'm sure that the answer will be extremely simple and obvious, but, as I said, I freely admit that this isn't my forte. Nonetheless, I'd really like to get something working so that I can mess around with it. Any help would be greatly appreciated. =)
Logged

Sixteen

  • Bay Watcher
    • View Profile
Re: Basic water algorithm when dealing with flat terrain?
« Reply #1 on: December 11, 2009, 11:58:25 pm »

You might find Kanddak's explanation helpful.
http://www.bay12games.com/forum/index.php?topic=32453.0
Logged

HideousBeing

  • Bay Watcher
    • View Profile
Re: Basic water algorithm when dealing with flat terrain?
« Reply #2 on: December 12, 2009, 12:09:03 am »

Basically DF checks if there is less water in adjacent tiles to a current water tile and if there is, it moves water into the adjacent tile. How often it does so and if there is any type of priority for where to flow, I'm not sure.
Logged

Footkerchief

  • Bay Watcher
  • The Juffo-Wup is strong in this place.
    • View Profile
Logged