Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Simple Cave-In Algorithm  (Read 1373 times)

Forumsdwarf

  • Bay Watcher
    • View Profile
Simple Cave-In Algorithm
« on: January 16, 2008, 02:36:00 pm »

Every support throws a 7-square radius.  Any mined square not within a radius collapses.
It's a little too lenient, but it's simple.
Logged
"Let them eat XXtroutXX!" -Troas

Capntastic

  • Bay Watcher
  • Greetings, mortals!
    • View Profile
    • A review and literature weblog I never update
Re: Simple Cave-In Algorithm
« Reply #1 on: January 16, 2008, 03:29:00 pm »

quote:
Originally posted by Forumsdwarf:
<STRONG>it's simple.</STRONG>

Then what business does it have being in DF?    :p

Logged

Railick Stonemane

  • Bay Watcher
    • View Profile
    • Stonemane Library
Re: Simple Cave-In Algorithm
« Reply #2 on: January 16, 2008, 03:30:00 pm »

Seems like it would be really simple to just highlight walls for supports instead of having them built in the middle of rooms. Any large room without supported walls would fall on itself after a set amount of stress or time. For example if you dig a small tunnel it could be left unsupported because there is very less stress on its walls. However if you build a large room with a two Z level high ceiling and don't support the walls before hand you will get a cave in. (Supporting the walls in this case would abstract away supporting the ceiling since they don't exist yet. Just imagine the dwarves building archs or supports up to the ceiling to hold it up) Maybe in VERY large rooms you could still require supports in the center for no amount of wall supports would hold up the center. Likewise you could put in archs that could go across the ceilings of high Z level rooms to support them without any supports on the ground level.
Logged
"And call a dog a cow-that don't change the way the thing'll taste!" Bruenor Battlehammer

http://railickstonemane.wordpress.com/
http://stonemane.hostei.com/

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: Simple Cave-In Algorithm
« Reply #3 on: January 16, 2008, 03:52:00 pm »

Any option that doesn't allow massive 12x12 open spaces, even with enormous multi-level vaulted ceilings and supports three tiles thick, just plain isn't good enough!

...Actually, now that I think about it, you could still vault ceilings based on that method.  But then you could also support an arbitrary-sized upside down pyramid on a single tile of sandstone.  Hmm.   :(

Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Forumsdwarf

  • Bay Watcher
    • View Profile
Re: Simple Cave-In Algorithm
« Reply #4 on: January 16, 2008, 09:53:00 pm »

Special constructions that allow larger rooms are a great idea.  It would give your architect more to do.
Logged
"Let them eat XXtroutXX!" -Troas

Quintin Stone

  • Bay Watcher
  • Dwarven Bureaucrat
    • View Profile
    • RPS
Re: Simple Cave-In Algorithm
« Reply #5 on: January 17, 2008, 11:08:00 am »

It'd be cool if your ceiling materials affected cave-ins.  For instance, a steel roof can have more unsupported than various types of stone.  Not a big deal though.
Logged

Drahflow

  • Bay Watcher
    • View Profile
Re: Simple Cave-In Algorithm
« Reply #6 on: January 21, 2008, 10:10:00 am »

I have a proposal which reflects both weight and torque. (the latter being
the thing which usually beats you:
code:

WWWWWWWWWWWWWWWWWW
W

This will fail at the lowermost wall, not because of the weight of the stuff
above, but because it's hanging too far right.

So my proposal:
Attach to every voxel a grid of support it can give.

code:

[ 18][ 25][ 30][ 25][ 18]
[ 25][ 35][ 40][ 35][ 25]
[ 30][ 40][inf][ 40][ 30]
[ 25][ 35][ 40][ 35][ 25]
[ 18][ 25][ 30][ 25][ 18]


Every number in this grid specifies how many "Weight" the voxel can support
at a spefied position. The middle is right above the voxel and should usually
be infitiny, unless the material is really bad for building, say wet clay or
something.

When checking the mountain, start from the bottom and assign every voxel just
these values. Then continue checking voxels which have any connection to
neighbours but not yet assigned any values. Continue then in rounds until
no voxel changes values anymore or all voxels are supported.

To get the support values of this voxel, consider every already calculated
neighbour and maximize the results over them. Every entry in the grid of
support values will be the minimum of the associated entry in the neighbour
(reduced by the weight of the voxel itself) and
the maximum support value for the voxel material
For better realism, if the neighbour under
consideration is exactly below the voxel, just substract the weight on
those positions where the support from the neighbour is greater or
equal to the central support (this make higher pillars possible, which
still support roofs).

Additionally save into for support value which voxel was responsible for the
value (i.e. which voxel the minimum was from). If both values are equal,
use the newly considered voxel.

Example:

code:

I
GH
F
BCDE
A

Assume for example purposes these small material support numbers:

code:

[ ][ ][1][ ][ ]
[ ][1][3][1][ ]
[1][3][3][1]
[ ][1][3][1][ ]
[ ][ ][1][ ][ ]

The above construction would get the following support grids:

code:

A:                minimum source
[ ][ ][1][ ][ ]   [A][A][A][A][A]
[ ][1][3][1][ ]   [A][A][A][A][A]
[1][3][3][1]   [A][A][A][A][A]
[ ][1][3][1][ ]   [A][A][A][A][A]
[ ][ ][1][ ][ ]   [A][A][A][A][A]

B:
[ ][ ][1][ ][ ]  
[ ][1][3][1][ ]  
[1][3][3][1]<,
[ ][1][3][1][ ] |
[ ][ ][1][ ][ ] |
         ^-----C located here
   

C:
[ ][ ][ ][ ][ ]   [A][A][A][A][A]
[ ][1][ ][ ][ ]   [A][C][A][A][A]
[1][3][2][ ][ ]<, [C][C][A][A][A]
[ ][1][ ][ ][ ] | [A][C][A][A][A]
[ ][ ][ ][ ][ ] | [A][A][A][A][A]
         ^-----D located here

D will not be supported. Minimum source was A, so A will be failing.

F:
[ ][ ][ ][ ][ ]   [A][A][A][A][A]
[ ][ ][ ][ ][ ]   [A][C][A][A][A]
[ ][2][1][ ][ ]   [C][C][A][A][A]
[ ][ ][ ][ ][ ]   [A][C][A][A][A]
[ ][ ][ ][ ][ ]   [A][A][A][A][A]
                             
H:
[ ][ ][ ][ ][ ]   [A][A][A][A][A]
[ ][ ][ ][ ][ ]   [A][C][A][A][A]
[ ][1][ ][ ][ ]<, [C][C][A][A][A]
[ ][ ][ ][ ][ ] | [A][C][A][A][A]
[ ][ ][ ][ ][ ] | [A][A][A][A][A]
   ^-----------G located here

G:
[ ][ ][ ][ ][ ]   [ ][A][A][A][A]
[ ][ ][ ][ ][ ]   [ ][A][C][A][A]
[ ][ ][ ][ ][ ]   [ ][C][C][A][A]
[ ][ ][ ][ ][ ]   [ ][A][C][A][A]
[ ][ ][ ][ ][ ]   [ ][A][A][A][A]

I will not be supported, because of C, so C will be failing.


Furthermore I think it would be great if the failing voxels would be removed,
so chain reactions are indeed possible (as they are in reality).

It should be possible (maybe by an architect) to gather information about how
much support is available where so the user can plan where to mine and where
not.

The 5x5 Grids shown in these examples are most likely not sufficient, as they'd
only support 8x8 large rooms. But this can easily be fixed by using larger
grids. Since usually all voxels will be supported (or they won't need to be
calculated very often again), the algorithms will for usual caves be
linear in the number of voxels. Using elaborate up-down-left-right-zigzag
constructions of steel however, it could get a bit slower.

Since the support grids are attached to the material of the wall it would be
possible to build supports into walls, even some optimized supports for
certain directions:

code:

A steel support of the form
x-----x
|
|
X

(useful maybe in the corner of a room)

would have a support like:

code:

[ 1][ 2][ 7][13][12]
[ 2][ 8][11][15][13]
[ 7][11][uu][40][20]
[13][15][40][60][30]
[12][13][20][30][40]

The exact shape and values of the support grids would need to be found out
by simulation, I suppose. If Toady considers this approach to be
computationally feasible in his current framework, I'd be grateful to write
some simulation for it.

Logged

Forumsdwarf

  • Bay Watcher
    • View Profile
Re: Simple Cave-In Algorithm
« Reply #7 on: January 21, 2008, 11:47:00 pm »

Well it's not "simple" but ... wow ... nice work.
Logged
"Let them eat XXtroutXX!" -Troas

TrombonistAndrew

  • Bay Watcher
    • View Profile
Re: Simple Cave-In Algorithm
« Reply #8 on: January 31, 2008, 02:29:00 pm »

Any cave-in algorithm that will be feasible in DF will probably only run at digging or construction completion, or upon a special event like an earthquake or some poor tanrtuming dwarf destroying a support or something. Anything that requires checks every turn will automatically fail, being too much of a resource hog.

And the algorithm should not have to check the entire mountain; it should be able to isolate affected squares to save computation resources.

. . . and, since I'm on a roll that no one but me will probably ever read, this means that the algorithm should probably actually be two algorithms: one for cave-ins caused by digging, and one for collapses caused by building. The first checks higher Z-levels; the second checks the current and lower Z-levels.

[ January 31, 2008: Message edited by: TrombonistAndrew ]

Logged