Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3 4 5

Author Topic: Hydrodynamics Education  (Read 53399 times)

Sysice

  • Bay Watcher
  • Beware!
    • View Profile
Re: Hydrodynamics Education
« Reply #15 on: November 20, 2009, 06:40:30 pm »

Nobody loves necromancy, though.
Logged
I managed to make a dog that bled bees.
Quote from: Threetoe
Imagine evil grass that looks like a mass of wriggling worms. Happy holidays!

Limul Thak

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #16 on: November 20, 2009, 09:04:00 pm »

Well, I'm certain some goblinoid necrophiliacs would disagree with you. >:(
Logged
This game is so strange.
The horses have TEEN ANGST.

Innominate

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #17 on: November 20, 2009, 09:56:37 pm »

To test the magma/water pump, I suggest this as a setup:
Code: [Select]
╔════════╕
║~~~~~~~~≡
║÷O÷╔════╛
║÷║÷║
║≈║~║
╚═╩═╝
Pump magma to fill the hallway (should perhaps be significantly longer, say 15 tiles). Once it is full, shut off the magma pump. Pull another lever to turn on the water pump and open the floodgate.

To be comprehensive two scenarios should be tested:
1. Does pumping water with the floodgate closed (i.e. no non-7/7 or wall spaces) do anything?
2. Does pumping water with the floodgate open and at least one 7/7 magma space in front of the water pump cause teleportation?

Personally I think that Toady's liquid code probably iterates separately for water and magma, treating the two as essentially different. There's a flag which defines whether a tile's liquid is magma or not, and I suspect it is trying to add one to the other that will cause obsidian to form, not a separate function.
Logged

MrLobster

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #18 on: November 20, 2009, 10:34:16 pm »

2. If water is in open space above a tile which is full of water to 7/7, it finds a path through tiles of 7/7 water to the nearest non-full space on a lower z-level, and then teleports there until the space is full or there is no water left to teleport. It only pathfinds north, east, south, west, up, and down; not diagonally. It does not move creatures or objects. This one rule is "pressure".

Except for pump pressure...

Here's how I think about it: pressure-creating a fluid means simply trying to put the fluid in a certain space, with special rules. If there's room, it just goes there. If there's not room because of solid stuff like rock walls or floodgates, creation fails.

However, if a 7/7 stack of the fluid is sitting there, it does an orthogonal flood-fill through connected 7/7 fluid stacks looking for a place to create the fluid. This can go down and up z-levels, but NOT ABOVE the z-level we're originally trying to create fluid at. Notably, the flood fill does not go diagonally, and looks all the way through one z-level before going vertical. Anyway, if a space is found, the fluid is created there instantly (and possibly, quite far away from where we were originally trying to pressure-create). If not, the creation fails.

The previous paragraph is the mechanism for 'pressure' in the game; it starts with the attempt to pressure-create a fluid at a certain z-level, and is the act of looking around through the 7/7 spaces to find where to put it.

So when does pressure-creation occur?

1. Water tries to fall by pressure-creating water down 1 z-level. Think of water not as ever falling, but being destroyed on level X and pressure-created on level X-1.
2. Notably, magma falls simply and does NOT pressure-create down. Magma in pipes is also created in a weird way that's not pressure-creation.
3. Pumps pressure-create whatever they pump into the destination square (which can be water or magma.)
4. Water coming in from the edge of the map is being "pressure created" at that z-level. Note that streams and rivers have drainage off the end of them, so pressure-creation can find a spot way down near the end of the river to create water, and will not rise back up to its own level.

That's it, one mechanism that explains pressure and final z-levels. At least, so far as I understand :D
Logged

Doomshifter

  • Bay Watcher
  • Deal with it.
    • View Profile
Re: Hydrodynamics Education
« Reply #19 on: November 20, 2009, 10:51:11 pm »

The water in your picture is cute.

I wholeheartedly agree. Adorablewater FTW.
Logged
Add me on PesterChum! My chumhandle is doomedHermit.
Right now Rampages seem to be Godzilla quietly walking into Tokyo, biting the leg off of one reporter... then creeping off again without a sound.

eerr

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #20 on: December 12, 2009, 12:41:51 am »

Nobody loves necromancy, though.
This thread shouldn't _need_ necromancy!

It is a staple unto itself, requiring no new content to fascinate people who have already read the thread.
Logged

RAM

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #21 on: December 12, 2009, 12:52:59 am »

I just want to voice my support for necromancy in all its forms.
Logged
Vote (1) for the Urist scale!
I shall be eternally happy. I shall be able to construct elf hunting giant mecha. Which can pour magma.
Urist has been forced to use a friend as fertilizer lately.
Read the First Post!

Kinoko_Otoko

  • Bay Watcher
  • Behold the saccharine visage of a fluffy wambler.
    • View Profile
Re: Hydrodynamics Education
« Reply #22 on: December 13, 2009, 06:41:46 pm »

And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...
Logged

RAM

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #23 on: December 13, 2009, 07:25:57 pm »

Oooooh, I have never tried to carve the edge of the world, should be eay enough to test though, just walk up to the edge, dig a ramp, and then carve. Still no guarantee the water will leave though.
Logged
Vote (1) for the Urist scale!
I shall be eternally happy. I shall be able to construct elf hunting giant mecha. Which can pour magma.
Urist has been forced to use a friend as fertilizer lately.
Read the First Post!

SenorOcho

  • Bay Watcher
  • Strategy Gamer
    • View Profile
Re: Hydrodynamics Education
« Reply #24 on: December 13, 2009, 07:35:38 pm »

I just want to voice my support for necromancy in all its forms.

As the Professor of Creative Necromancy, I must agree with this sentiment.
Logged

Jim Groovester

  • Bay Watcher
  • 1P
    • View Profile
Re: Hydrodynamics Education
« Reply #25 on: December 13, 2009, 08:22:40 pm »

And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...

Digging out to the edge of the map and carving fortifications usually works as a drain, so yes. There are some cases where the fortifications will actually let water flow in, but that only seems to happen when there are aquifers.
Logged
I understood nothing, contributed nothing, but still got to win, so good game everybody else.

Vanguard Warden

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #26 on: December 13, 2009, 11:21:00 pm »

Oddly enough, you can't seem to drain magma off the edge of the map as you can water.
Logged

Kanddak

  • Bay Watcher
    • View Profile
Re: Hydrodynamics Education
« Reply #27 on: December 13, 2009, 11:32:26 pm »

I'm going to take this opportunity to tack on a few miscellaneous pieces of information about water behavior that have been studied since I made this thread.

And to show my support for necromancy, since it occurred yesterday, I have a question: If I want to make a waterfall out of an existing brook without using a pump, can I channel it off the map? One person said you could dig up to the map edge and then carve a fortification...

Water can leave from a map edge using rule 1; that is, if it's next to a map edge, and happens to flow in that direction, it falls off the edge and disappears. Magma doesn't do this, and pressure-pathfinding can't just find a path off an edge and make water vanish. You can get water to the map edge at low elevations by carving fortifications.
If you are on an ocean site, any map edge tile below sea level is an ocean source and water will come in through it. I haven't experimented with lakes but I suspect they'd be likely to work the same way. I keep hearing about aquifers too, but if you have an aquifer you have water shooting out of so many places I'm going to maintain a healthy skepticism about what's coming from the map edge until I see a good demonstration. Map edge ocean sources appear to only create water in adjacent tiles, without pressure pathfinding.

Speaking of aquifers, here's basically how they work: Any unsmoothed aquifer wall tile will periodically create water in an orthogonally adjacent space or a space below it. Aquifers don't create water diagonally, and they don't appear to use any pressure pathfinding; only adjacent spaces. Water can pressure pathfind into aquifer walls to disappear; the mechanics of this aren't precisely understood, but essentially you need to drop the water into the aquifer, you can't pump it in from the side.

River sources work like pump outputs and will pressure-pathfind to find a place to put water. Normally there is empty space near the downstream map edge created by water falling off said edge. Sometimes river flow can exceed drainage (especially but not exclusively if you dam it), and the river will then (and only then) be able to push water through a U-bend to the original height of the river (which can be how people get their wells flooded); pressure pathfinding only goes up as an absolute last resort, and will take any down/horizontal path available, no matter its length, before going up. (studied here)

Magma vents: The magma flow tiles at the bottom of vents periodically pathfind in a vertical line to find a place to create 7/7 magma, no higher than the top level of the vent. Speaking of magma, it has been confirmed by experiment that the horizontal diffusion rates of water and magma are the same, and the idea that "magma moves very slowly compared to water" is a myth stemming from magma's lack of natural pressure.

Order of evaluation, FPS issues: (gleaned from my walrus trapping adventures)
The water movement algorithm appears to break the map up into 16x16 blocks, and then evaluate water movement in each of these blocks starting from the top left corner, moving down in a column first before going right to the next row. You can observe this by dropping a fire bin into an ocean. (see here, here)
It turns out that not every water tile is evaluated on every single frame. The algorithm goes through a specific pattern, which you can observe by draining an ocean into an aquifer; on the first frame, only certain tiles will disappear into the aquifer, and so on.
It appears that long-distance pressure pathfinding is a major drain on FPS, compared to static fluids or local diffusion. When a drained ocean refills, each level begins filling quickly; as the level fills up and the remaining empty spaces become farther from the map edge, I have observed FPS deteriorating, only to improve dramatically as soon as the level fills and the ocean sources begin to fill the next level starting from spaces near the edges.

Open areas of fluids research:
There is a bug where a closed hatch can break pressure pathing such that when the hatch is opened, the game doesn't recognize that there is now a clear path, and water doesn't rise up through the hole when it should.
There is another bug where water on ocean and lake sites can be vanished as if in an aquifer by dropping it into a hole.
The exact flow rates of different water sources have never been quantified. Stream & river sources seem to create water more quickly than brooks.
The behavior of underground waterfalls (river sources) has not been studied. http://www.bay12games.com/forum/index.php?topic=37861.0 (Thanks Vanguard Warden)
The rules governing when waterwheels turn are still shrouded in mystery and certain power plant designs seem to work some times and not others. I've had some luck starting a power plant by throwing a bucket of water in from a couple levels up.
« Last Edit: December 13, 2009, 11:47:24 pm by Kanddak »
Logged
Hydrodynamics Education - read this before being confused about fluid behaviors

The wiki is notoriously inaccurate on subjects at the cutting edge, frequently reflecting passing memes, folklore, or the word on the street instead of true dwarven science.

Jim Groovester

  • Bay Watcher
  • 1P
    • View Profile
Re: Hydrodynamics Education
« Reply #28 on: December 13, 2009, 11:42:08 pm »

Open areas of fluids research:
...
The behavior of underground waterfalls (river sources) has not been studied.
...

Here's a little test study done by Maw. To summarize it, the waterfall tile creates a 7/7 tile of water on top of it, and it fluid paths just like a pump. Further, it can be collapsed and its water creating potential will be preserved.
Logged
I understood nothing, contributed nothing, but still got to win, so good game everybody else.

Kinoko_Otoko

  • Bay Watcher
  • Behold the saccharine visage of a fluffy wambler.
    • View Profile
Re: Hydrodynamics Education
« Reply #29 on: December 14, 2009, 02:02:28 am »

Alright, so apparently trying to drain the water off-map is dangerous because pressure doesn't affect it, so it's kind of random. So here's anther idea. In order to keep the highest water tiles from 'backtracking' I could have a channel (one or more tiles wide; probably more) that drops a Z-level for every tile it travels toward the edge of the map.

Am I correct in thinking this will cause it to drain faster than letting it flow straight and level to the edge?

Or better yet, should I just make a big reservoir with one side pressed against the edge, with as many tiles pressing as possible?
Logged
Pages: 1 [2] 3 4 5