Bay 12 Games Forum

Please login or register.

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

Author Topic: An easy way to make sand flow.  (Read 5090 times)

King Mir

  • Bay Watcher
    • View Profile
An easy way to make sand flow.
« on: May 04, 2012, 12:14:14 am »

That it should not be possible to dig anything in sand is a well known anomaly. Here's a simple fix that doesn't require turning sand into fluid.

It requires a few changes:
1) Sand does not provide support to any tile except the one directly above it. Digging in to a sand layer from a stone layer under it causes a cave in.
2) Sand does not cause cave-in dust.
3) Mining sand from the side causes a cave in if there are sand wall tiles above. This is harmless to the miner, but he will have to mine the tile out again. Sand floor above would also cave in, but it just disappears -- this can be done using the cave in mechanic, or as a special case.
4) Falling sand triggers tiles orthogonally-above to cause a fill event. during a fill event, if able, a sand wall will become a ramp. Then, an additional sand ramp is created on the tile that was emptied of sand. If it is already a ramp, a wall is created instead. This may trigger another cave in, but only after all fill events happen. The order of fill events can be random or based on the coordinates of the event.
5) This does make it possible for one tile of a workshop to suddenly become floor-less. The easiest resolution is to make this make the workshop deconstruct in this case.
6) Disallow staircases carved out of sand. Dwarves must use ramps. Down stair cases are allowed.

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: An easy way to make sand flow.
« Reply #1 on: May 04, 2012, 12:23:32 am »

Modification of the idea:

Sand does not support to any tile except under special circumstances.  It takes a 3x3 tile to support one tile, the one in the middle.

It would lead to sand naturally leaving a pyramid shape when it falls, and would spread out a bit from holes it falls into.
Logged
I like fortresses because they are still underground.

Sadrice

  • Bay Watcher
  • Yertle et al
    • View Profile
Re: An easy way to make sand flow.
« Reply #2 on: May 04, 2012, 01:16:35 am »

I like this a lot, and from my minimal understanding of programming, I don't think this should be difficult or particularly FPS draining (except in the event of a lot of sand pouring at once, no giant hourglass clocks).  This could be also be applied to mining rubble, to make nice conical tailings heaps, or perhaps a nice little anthill around a new fort that hasn't set up a proper tailings disposal system yet.
Logged

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #3 on: May 04, 2012, 01:50:01 am »

Modification of the idea:

Sand does not support to any tile except under special circumstances.  It takes a 3x3 tile to support one tile, the one in the middle.

It would lead to sand naturally leaving a pyramid shape when it falls, and would spread out a bit from holes it falls into.
If you do it that way, I'd use a 3x3 cross as the required support.

You don't say how to handle the case of natural stone falling on top of nonsupporting sand, especially if it's a large structure. And your way does not create ramps on spreading sand.

This could be also be applied to mining rubble, to make nice conical tailings heaps, or perhaps a nice little anthill around a new fort that hasn't set up a proper tailings disposal system yet.
Maybe. You'd have to work out how mining rubble items become rubble walls.

Maklak

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #4 on: May 04, 2012, 04:59:14 am »

The biggest obstacle to this is interaction with other fluids.
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #5 on: May 04, 2012, 09:15:14 am »

Most of that works as is. You could make a special case or two for sand flow into a water or magma tile, so that it will displace them instead of atom smashing, but disappearing water is not absurd with sand around.

NW_Kohaku

  • Bay Watcher
  • [ETHIC:SCIENCE_FOR_FUN: REQUIRED]
    • View Profile
Re: An easy way to make sand flow.
« Reply #6 on: May 04, 2012, 10:40:31 am »

I like this if you include Jeoshua's addition.

Sand in Terraria, especially is just weird - it falls downward, but never to the side, and will fill in areas in worldgen, and as such, you frequently come across sand that has a vertical pillar that drops down hundreds of tiles vertically, but never spills to the side, and has small holes in the areas where stone tiles were generated to stop this cascade of sand. 

Making it actually build "pyramids" would make a great deal of sense. 
Logged
Personally, I like [DF] because after climbing the damned learning cliff, I'm too elitist to consider not liking it.
"And no Frankenstein-esque body part stitching?"
"Not yet"

Improved Farming
Class Warfare

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: An easy way to make sand flow.
« Reply #7 on: May 04, 2012, 03:39:59 pm »

The "plus" shape supporting sand above it would be adequate to create the kind of behavior one would normally see with sand.

A better way to put this, instead of bottom-up is top-down.

When one block of sand is resting on a tile, it will check the surrounding tiles.  One of three things will be true:

- The surrounding tiles are all on the same z-level or lower.  The sand becomes a ramp.
- All of the tiles surrounding the same are on a higher z-level.  The sand becomes a block and forms a flat sandy floor above it.

If sand falls onto a ramp, it will pick a tile to shift down to, instead.  If multiple choices are given, it will pick one at random.

This naturally leads to pyramid shapes and lets sand fill in cracks with flush surfaces.
« Last Edit: May 04, 2012, 03:45:50 pm by Jeoshua »
Logged
I like fortresses because they are still underground.

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #8 on: May 04, 2012, 04:44:26 pm »

I like this if you include Jeoshua's addition.

Sand in Terraria, especially is just weird - it falls downward, but never to the side, and will fill in areas in worldgen, and as such, you frequently come across sand that has a vertical pillar that drops down hundreds of tiles vertically, but never spills to the side, and has small holes in the areas where stone tiles were generated to stop this cascade of sand. 

Making it actually build "pyramids" would make a great deal of sense.
You get pyramids with both methods. fill events (change 4 above) cause 2 tile high walls to become a 2 tile high ramped slope. Pyramids would form naturally from that. Sand cliffs would only be possible on embark or with dfhack, as those don't necessarily trigger fill events.

Of course to actually get pyramids  you would have to build them underground, or create allow squares to filled with sand somehow. They won't occur naturally in worldgen, and sand will only fall, flow, or disappear.

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #9 on: May 04, 2012, 04:59:38 pm »

The "plus" shape supporting sand above it would be adequate to create the kind of behavior one would normally see with sand.

A better way to put this, instead of bottom-up is top-down.

When one block of sand is resting on a tile, it will check the surrounding tiles.  One of three things will be true:

- The surrounding tiles are all on the same z-level or lower.  The sand becomes a ramp.
- All of the tiles surrounding the same are on a higher z-level.  The sand becomes a block and forms a flat sandy floor above it.

If sand falls onto a ramp, it will pick a tile to shift down to, instead.  If multiple choices are given, it will pick one at random.

This naturally leads to pyramid shapes and lets sand fill in cracks with flush surfaces.
You don't want motionless sand to trigger flow, because then you have to periodically check all sand to see if it will flow. So you need a bottom up implementation. That's why I have flow events created by cave-in events.

With that in mind, what happens when you have natural rock supported by 8 (or with a cross, 4) tiles of sand? Will the rock flow? Or do you want to change the way sand supports sand, but not how it supports other rock?

And again, your way doesn't create smooth pyramids, but stepped pyramids. There are no ramps.

Jeoshua

  • Bay Watcher
  • God help me, I think I may be addicted to modding.
    • View Profile
Re: An easy way to make sand flow.
« Reply #10 on: May 04, 2012, 06:13:40 pm »

When the tiles are placed in my imaginary implementation, they are either -

A> Surrounded on all 4 sides, therefore forming a flat area.
B> Sloped.

So yeah, it would form a sloped pyramid shape, if all the sand fell in one spot.

And no matter what implementation you use, you would have to periodically check the flow.  Either that or each and every tile would have to periodically check the tile above it to see if it's sand, water, lava, and could flow.
Logged
I like fortresses because they are still underground.

Starver

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #11 on: May 04, 2012, 07:14:44 pm »

I'd generally support any idea that has 'conservation of sand volume'.  This might include a single side-unsupported block (as might be generated when digging into the side, or by more complex methods) 'spreading out into two ramps (one on original block, one into the one in which it spills), and where two ramps on Z+1 that get 'drawn down' onto the level below might add to the Z=0 ramps in order to create whole blocks again, unless (or until) the blocks below are unsupported to one side and thus 'spill' ramping that way.  However, in whatever way it is done, it conserves sand-volume.

Additionally, spilling under raised atom-smashing bridges should ideally prevent the unraising (because you now have structures that could never have had the unraised bridge built across them), if looking for verisimilitude, but this might be taken as written in any general nerfing of atom-smashing that might yet occur.

Interaction of the pseudofluid sand with actual fluids should probably be a matter of evicting the water/magma from the cell (sending it upwards, if necessary) that is fully-filled with sand...  I'm minded to suggest that ramped-sand should evict half the fluid, but ramped-cells still have 7/7ths fluid content (when full), so maybe ignore it until it becomes solid-sand.

I generally think that if you were to engineer a sand-fall onto a square that overflows (e.g. sand above a ceiling hatch of a room arbitrarily tall, which is opened) should not bias towards overflowing in any particular direction.  We already have in the fluid mechanics a direction randomiser that helps a 6/7ths tile in an otherwise 7/7ths pool be flowed into (and thus 'move' in the opposite direction) from an ever changing direction, each tick, and so this would apply to make the decision as to which way (given a choice) the sand does flow.

I think then that if you were to dump (say) three whole tile-units of sand onto an open space, this would be likely to end up forming a + with a solid centre and ramps on the four peripheries (assuming the "two ramps is a whole unit" conversion).  Add another unit and there'd be a ramp on top of the centre and an additional ramp now either extending an arm of the 'plus' or in one of the inner corners, according to how the second 'ramps-worth' of sand dumps off of the 'arm' that it had temporarily upgraded to a solid block.  Adding even more sand would tend to produce a pyramid (diagonally-aligned), but would have irregularities.

(Imagine, for the most biased irregularity, that the excess on the top of the 'drop zone' tile continually spilling westward, by pure flukey chance, and that westward tile spilling westward whenever it can, although at various points in this cycle the westward tile would be unavailable to flow into and it'd have to flow north and south (because of the PRNG being particularly biased against east, at this point) until it absolutely had to flow east before it had built up a solid-enough base in order to go back to its inexplicable westward tendency.  However, most of the time the randomness would make a vaguely regular pyramid of sand, and all without having to do macro-calculations in order to do a look-ahead assessment of where the next bit of excess sand-pile should spill out onto...)

Soil should be equally capable of slumping, but maybe being capable of a 1.5Z adjacent height differential instead of the nominal 0.5Z height differential of dry sand, and maybe wet sand (or particularly dusty soil) should be given an effective 1.0Z differential, while claggy clay-based soils get even more.  The calculations for the higher values of these do rather depend on 'spilling' happening based on what's happening on different Z-levels (as opposed to the original idea that just works out spilling on the same-Z, but then if that's on open space it falls down), but would mean that a sustainable (non-sand) wall could be kept on a particular level by keeping any (multiple of?) tiles'-worth of material in check with walls on the layers above.

And imagine the value of this situation (even with just sand) in protecting against Sapper attacks (i.e. digging enemies).  They'd burrow into the side of the fort and through a sand-based 'fileld cavity wall', which would then give a something of a continually-renewing obstacle.  However, this also relies upon either convenient surface geology or the ability to treat 'sand units' as haulable and placeable (or at least pond-like deposition).

Logged

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #12 on: May 04, 2012, 07:43:00 pm »

When the tiles are placed in my imaginary implementation, they are either -

A> Surrounded on all 4 sides, therefore forming a flat area.
B> Sloped.

So yeah, it would form a sloped pyramid shape, if all the sand fell in one spot.
What would cause the ramps to appear? What if the player designates an up ramp to be destroyed?
And no matter what implementation you use, you would have to periodically check the flow.  Either that or each and every tile would have to periodically check the tile above it to see if it's sand, water, lava, and could flow.
No, my suggestion will only check the flow after a cave in or adjacent dig event. Only digging can cause sand to flow.

I'd generally support any idea that has 'conservation of sand volume'.  This might include a single side-unsupported block (as might be generated when digging into the side, or by more complex methods) 'spreading out into two ramps (one on original block, one into the one in which it spills), and where two ramps on Z+1 that get 'drawn down' onto the level below might add to the Z=0 ramps in order to create whole blocks again, unless (or until) the blocks below are unsupported to one side and thus 'spill' ramping that way.  However, in whatever way it is done, it conserves sand-volume.
I agree, though to some extent disappearing sand must happen anyway until mining sand is changed. If some extra sand disappears when mining, it's not a big deal.

Quote
Additionally, spilling under raised atom-smashing bridges should ideally prevent the unraising (because you now have structures that could never have had the unraised bridge built across them), if looking for verisimilitude, but this might be taken as written in any general nerfing of atom-smashing that might yet occur.
Ideally yes, but this applies to rock cave ins as much as sand cave ins, and so should be handled in that broad context.

Quote
Soil should be equally capable of slumping, but maybe being capable of a 1.5Z adjacent height differential instead of the nominal 0.5Z height differential of dry sand, and maybe wet sand (or particularly dusty soil) should be given an effective 1.0Z differential, while claggy clay-based soils get even more.  The calculations for the higher values of these do rather depend on 'spilling' happening based on what's happening on different Z-levels (as opposed to the original idea that just works out spilling on the same-Z, but then if that's on open space it falls down), but would mean that a sustainable (non-sand) wall could be kept on a particular level by keeping any (multiple of?) tiles'-worth of material in check with walls on the layers above.
I disagree that this should be extended to all dirt. It is quite possible to build tunnels and housing in dirt. Sapping in real life works best in dirt. Generally you'd brace the walls and ceiling much more than stone, but it is not sand. Dirt also packs, which helps it act like support. It might be extended to some sandy dirt and ooze, but probably not peat.

With the rest of what you said, I agree completely.
« Last Edit: May 04, 2012, 08:33:07 pm by King Mir »
Logged

Starver

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #13 on: May 04, 2012, 09:11:25 pm »

Quote
Soil should be equally capable of slumping, but maybe being capable of a 1.5Z adjacent height differential instead of the nominal 0.5Z height differential of dry sand, and maybe wet sand (or particularly dusty soil) should be given an effective 1.0Z differential, while claggy clay-based soils get even more.  The calculations for the higher values of these do rather depend on 'spilling' happening based on what's happening on different Z-levels (as opposed to the original idea that just works out spilling on the same-Z, but then if that's on open space it falls down), but would mean that a sustainable (non-sand) wall could be kept on a particular level by keeping any (multiple of?) tiles'-worth of material in check with walls on the layers above.
I disagree that this should be extended to all dirt. It is quite possible to build tunnels and housing in dirt. Sapping in real life works best in dirt. Generally you'd brace the walls and ceiling much more than stone, but it is not sand. Dirt also packs, which helps it act like support. It might be extended to some sandy dirt and ooze, but probably not peat.

With the rest of what you said, I agree completely.
Ah, meant to put "Soil should maybe be equally capable of slumping, ".  You're right about the basic structural capabilities (completely lacking in sand... unwetted sand, anyhow), but there's a good argument against not being able to be t be packed tight enough for vertical towers, and the concept of a 1/8th-height of a tile (the hypothetical 'floor' volume in a dug-out area that retains a floor[1] being made of soil packed tight enough to allow someone to walk on it without falling through to a tunnel on Z-1 is a bit... interesting.  As a concept.

But that's just one of the game-mechanics strangenesses.  ;)

Tying 'slumpability' (in terms of Zs-worth of verticality before slumping is considered) to material-type and properties is of course a vertical variation on the whole "how wide can a room be before it needs a support to prevent cave-ins" argument.  And currently there's no limit beyond which any material (whether raw sand or granite-block wall-mass or steel-bar flooring) is unsupported.  But assuming that the sand-flow is implemented there's logically got to be some sort of extension... and, well, I suppose I was riffing on the theme, by that point in my post. :)


[1] Even though you still don't get 8/8ths liquid in a block with no floor...  BYGTI
Logged

King Mir

  • Bay Watcher
    • View Profile
Re: An easy way to make sand flow.
« Reply #14 on: May 04, 2012, 09:59:30 pm »

Yeah, I can see how flowing sand paves the way for better handling of support in dirt. But I don't mean to suggest a complete reworking of cave-in physics. That would be nice, but this suggestion does not require that. When stone and sand support systems are both in, then dirt can be assessed for which qualities of each system apply to it.
Pages: [1] 2