Idea for Structural Physics in Minecraft

Discussion in 'Archived: Plugin Requests' started by roeltrachsler, Jan 31, 2012.

  1. Offline

    roeltrachsler

    I'm a big fan of Structural Physics games. Like Armadillo run, world of goo. Also have my own minecraft server. In my free time i'm studying to become a mechanical engineer. So i started thinking about a way of implementing structural psysics in minecraft.

    I don't have any experience making plugins, nor do I intent to get any. So i leave my thoughts here and maybe they inspire someone to make a plugin.
    I have a pretty good understanding of real world physics but the rules i've created are very simple in an attempt to keep it manageble for a possible plugin creator.

    The Goals:
    1: Simulating gravity, by making floating blocks or structures fall to the ground
    2: Simulating failure of blocks due to overloading
    3: Simulate failure of bonding between blocks


    to achieve these goals i've constructed the following rules:

    The rules:

    The assumptions:
    -Blocks are rigid
    -All Blocks are constrained so they can only move straight down.
    -Players/mobs have no weight or mass.
    -Blocks will fall down if they are not supported
    -Blocks that touch other blocks will be invisibly glued to all blocks they touch.

    -Glue cant fail, but the connection between the glue and a block can.
    -If two different types of block are glued together the strength of the connection is equal to lowest Adhesiveness of the two blocks.


    Blocks have the following properties:
    Weight (i.e. the force gravity exerts on all objects witch have mass )
    Adhesiveness (The strength of the bonding between the block and the glue. wich is used to attach it to other blocks)
    Max Load (the weight a block can support without being crushed)


    Implementation of failure
    If in a structure the maximum load or adhesiveness is exceeded the structure wil fail at the biggest exceedment (is that the right word?). If there are places of equal exceedment, al these places wil fail simultaneously.

    If the a glue connection fails all the blocks that are supported bij it will move one block down, and then the calculation will be done again.

    I a block is overloaded the block will be destroyed and the structure it supported will move down by one block. Then the calculation is run again.

    The strength of a connection is normally described as a maximum pressure. Wich means force over a given surface area. Because all the block are 1m^3 big I use the maximum force wich can be excerted on surface area of 1m^2 as a measure of the strength of the connections.


    Examples:
    Show Spoiler


    For these examples the following properties are assumed:

    (These are in no way realistic, are in no way intended as final values for an eventual plugin and are only chosen this way so i can make clear examples)



    Stone:
    Weight = 10N
    Adhesiveness = 50N
    Max Load = 100N

    Dirt:
    Weight = 10N
    Adhesiveness = 0N (i.e. can't be glued)
    Max Load = 200N

    Gold:
    Weight = 50n
    Adhesiveness = 50N
    Max Load = 200n

    Bedrock: (not affected by physics)
    Weight = 0N
    Adhesiveness = Unlimited
    Max Load = Unlimited
    Can float in thin air

    (In these examples when i say the glue fails, i mean the connection between a block and the glue fails.)


    Example 1+2:

    [​IMG]



    In this picture the Dark grey blocks are bedrock, and are not affected by physics. The light gray represents rock. On the left the block of rock is attached to the wall with glue that can support up to 50N. The weight of the block is only 10N, so the block will stay there.

    On the right a column of rock is standing on a bedrock floor. Each block is exerting a force of 10N straight down. The top block has no block to support, so it's load is 0N. The block under it is under a load of 10N (from the top block). The third block from the top block is under load of 20N, the fourth under a load of 30N and the bottom one under 40N. None of these loads exceed the max of 100N so this structure is sound.

    Example 3+4:

    [​IMG]

    In the structure on the left a stack of dirt is supported by a single block of rock. Altough the dirt is touching the bedrock wall, it cant be glued so its weight must be supported by the rock. The force on the glue between the rock and the wall is 6x10N (weight of the dirt) + 10N (weight of the stone) = 70N. Wich is more than the maximum of 50N the glue can withstand. Therefore the glue will fail.

    In the structure on the right a stack of gold blocks is standing on a single stone block. The top block is not under any strain. However the second block from the top is under a load of 50N, from the top block. Third gold block is under a load of 100n (the weight of the two gold block above it) and the stone block on the bottom is under a load of 150N. This however is more than it can support, so the rock block will fail.


    Example 5+6+7:
    [​IMG][​IMG]


    In this final example you can see two designs for a bridge, only half because that doesn't affect the calculation. On the left the maximum pressure is at the bottom of the pillar (18x10N = 180N). But it is supported by two blocks. So the pforce on each block is only 90N, witch can be supported by rock. The max shear stress (the load on the glue) is at beginning of the 'arm' where it is attached to the pillar. The force that must be supported is 60N (6x10N), wich is too much, so the glue will fail.

    On the right there is an improved version of the bridge. Here the max load is (29x10N)/3 = 96,7N and, more importantly, the max shear stress is only (8x10N)/3 = 26,67 so this structure is sound.

    [​IMG]

    An even more improved version, can you find the max load and sheer stress?


    Possible problems:

    -Trying to calculate the stress in the naturally generated world of minecraft will probably be a heavy load on a server, so this may only be possible, if at all, on a flatmap.

    - if a structure fails, it wil fail at the highest loaded section. That means that large sections can break off and become useless. Although this is realistic, it can be very frustrating.

    -These rules don't take in account that structures will rotate if they are not supported evenly. So there is nothing stopping you from making a lob sided tower or half a bridge.

    Other Thoughts:

    -The values of the block properties need quite a bit of finetuning

    Thats al i've got for now, i'll expand on it as things come to mind. Feel free to ask me anything!
     
  2. Offline

    ChumChum

    This is really really really really a big project...
     
  3. Offline

    roeltrachsler

    Do you think? I can't really make a good estimation. All i can see is that it seems possible, judging on the things you can do with a plugin. But i have no way of estimating calculation time or algorithm complexity. So i leave it to a developer to judge if it is possible.
     
  4. Offline

    RROD

    You might need Spout for these Physics, unless there is a way you can give the physics of sand/gravel to normal blocks.
     
  5. Offline

    roeltrachsler

    Did you read the entire post? Or maybe i just wasn't very clear.

    In any case, by moving down upon failure i mean it just moves there. It is not necessary for the block to actually show an animation of it sliding down. Altough that would be cool.

    I have seen mods were blocks can move freely and thrown around, but that is not what i am interested in. The goal of this plugin would be to apply mechanical properties to blocks. So you must take structural integrity in to account for your buildings. To provide an extra challenge.
     
  6. Offline

    codename_B

    Hmm, I like this, I like this a LOT.

    Anyone else up for adding another dimension of physics? As a group project this could be really fun.
     
  7. Offline

    roeltrachsler

    As stated in the start post, i can't help with the actual programming. However i am currently thinking about what the algorithm should look like. It's proving to be quite a challenge XD
     
  8. Offline

    mikeyagoto

    One problem... Wouldn't all the stone at the bottom of the map get crushed?
     
  9. Offline

    roeltrachsler

    I don't think that will be a problem. If rock is configured to be able to support 200 times its own weight (for example) it should leave the normally generated caves intact while still preventing you from making buildings with unrealistically thin supports.

    If you make a sound structure but it starts sagging into the ground, you should have made a sturdy foundation (e.g. a floor of stone blocks), wich is also realistic.

    Come to think of it,

    I think the strength of rock doesn't have to be so high. Because, assuming stone is the heaviest natturally occurring block, the maximum load for any naturally generatated block is 128x the weight of stone. If you imagine a world of solid stone, so there are no shear stresses, all the bottom block will be loaded with a force of 127x[weight of stone]. Now if you add caves those loads will only be reduced. Unless something like an inverted pyramid is generated, wich looks unrealistic, and shóuld crumple.

    Figuring out the same for the shear stresses is a little more difficult, so i will come back to that later.

    I cant think of solid mathematical proof, but for naturally generated structures to fail due to shear stress there must be either a large thin outcrop or a giant pile of dirt on a thin ceiling of stone. Both don't occur very often, and don't cause problems when they collapse.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  10. Offline

    AmoebaMan

    This is an ambitious project, but I think a worthy one. If I had time, I might even try it myself.

    However, I would probably change a few things. This will be complicated to explain, but it makes sense in my head :|

    Blocks should all be deemed either "supported" or "non-supported". A block is deemed "supported" if it either has a block under it, or the combined adhesive effect between it and all its neighboring blocks is less than the force normal exerted on it by the block above.

    In determining the success of a cantilever-type design like your half-bridge above, one would use a recursive algorithm to spread out and search all the nearby blocks. The checked block would have a "maximum defiance" property with respect to gravity, in meters. If there is a "supported" block within that distance of the block in question (with the search not propagating through air of course) then the block remains in place, although not necessarily "supported" itself. If no "supported" block exists within the blocks "maximum defiance" range, then the block falls.

    This system would allow structures like caves to exist easily, and would also provide the technical reasoning behind arches - a block in the center of the arch can search for supporting blocks in all directions. In addition, I would scrap the idea of blocks crumbling (except for designated "weak" blocks like perhaps wool or dirt), or maybe just crank up the value of certain materials (like stone) to the point where they would never fail from pressure.

    All the math would actually be fairly easy quite frankly. The most difficult part would be figuring out how to make the blocks actually fall...
     
  11. Offline

    Waterflames

    This seems like it would create some performance problems...
     
  12. Offline

    mikeyagoto



    my analysis of what this means is that a stone block can only hold 100N and each stone is 10N

    That means that 1 stone can only have 10 stone stacked on top of it without being crushed.

    That means that the whole bottom of the map will get destroyed.

    I take this as meaning that you think stone should be practically indestructible, but what about ores? Dirt? Gravel? the other blocks that are found deep, should they be also indestructible? The bottom of the map is holding up a lot of weight and you have to account for that...
     
  13. Offline

    roeltrachsler

    I changed the sentence, maybe its more clear now. I chose those values to explain the concept as clearly as possible, and so i didn't have to use overly complex examples.

    The point of that post is that the strength of stone (and the other blocks) doesn't have to extremely high for natural caves to be able to exist, but maybe i should elaborate on that.
     
  14. Offline

    spywhere

    That's a lot of calculation out there lol. Anyway, I used to think of how to make support like Example 5+6+7 in my plugin and that's make me go crazy. In my opinion, only one thing that could be a huge problem is the server performance. The loop to check every blocks around updated block is infinite (until you limit them) and this is a cause of server lag.

    PS. Sorry for bad English ):
     
  15. Offline

    Fyre

    Just to clarify for those who don't understand, making the block fall would be incredibly easy, you just have to set the block that needs to fall to air, and then set the block below it to the same type as the original block. Considering that all that would happen in a single tick, it might look smoother than you'd expect, In fact you'll probably have to run a physics check by the bukkit scheduler with a repeated task, and with at least two ticks between runs, else the server will eventually crash due to sheer quantity of block changes that can be caused as new chunks are generated.
     
    dannycrafts likes this.
  16. Offline

    roeltrachsler

    That's what i thought, i didn't think it would be a problem either.
     
  17. Offline

    AmoebaMan

    You and a lot of other people seem to be overlooking the fact that there is absolutely no need to perform a check on every block every tick (or even every second). You're right of course, doing so would tax a server tremendously. However, you don't need to. You only need to run a check on block placement, breaking, decaying, flowing, burning, piston push, falling, or basically whenever the world is actually changed.

    You'll even notice that this is how Minecraft itself handles block physics. Most of us have seen the fairly common sight of a block or two of sand hovering in the air because a pond was generated removing the block below it. That block doesn't fall, obviously, because Minecraft only checks to update blocks if a block next to it is changed. This is why placing or breaking a block next to that hovering sand block will cause it to fall. This is also the principle behind the existence of B.U.D. (block update detector) circuits.

    This is probably something I'll try my hand at when I have time (I code custom plugins for The Battlecraft, so I'm fairly busy). If I give up, I'll be sure to upload the source to Github or something.
     
  18. Offline

    roeltrachsler


    This idea seems great, i will write a full reply tomorrow, because i think you are really on to something.
     
  19. Offline

    AmoebaMan

    Excellent :)

    One of my ultimate goals as far as Bukkit plugins goes is to use plugins only to create a server that makes Minecraft as realistic as possible. For instance, I've made a plugin that makes arrows deal more or less damage based on where they impact their target. I'm also in the process of making a plugin that simulates realistic, finite fluids.
     
  20. Offline

    roeltrachsler

    I'm going to kill Bill gates. Windows decided to restart after i had been working for an hour to make a decent analysis of your ideas (in the reply window XD). I'm not feeling like retyping it all right now, so first some other thoughts.

    Please note that, from here on, i'm using "you" as though the reader would be making the plugin, i'm not talking to anyone specific.

    I think any improvement of minecraft's structural physics will be a great asset to the gameplay. A plugin which would cause any blocks, wich are not somehow supported, to fall to the ground would imho be already be worth while.
    Provided the bottom of each map is at least one layer of solid bedrock, a 'simple' recursive algorithm could find all blocks which are somehow connected to a structure which is itself connected to bedrock. In fact, in a vanilla minecraft world, there would be only one, giant, supported structure. Al blocks which are not in that structure are then labeled floating and are moved down one meter. Then the algorithm could run again, until all block are connected to a structure which is itself connected to bedrock.
    If after an initial analysis the algorithm would only have to look for blocks wich are in the main structure which were exposed to air, but after the shift have made contact with an additional block. Then the algorithm would deem all block connected to that block 'landed' and would add them to the list of supported blocks. This way it would require only minimal recources from the server.
    If such a plugin would be created you could expand from there by adding maximum loads and other mechanical properties to blocks.

    For a full version I don't think properties have to very specific to allow for the 'natural' world to be sustained ánd invoking realistic building constraints. However, i do think calculations will be heavy unless an efficient algorithm is created. So starting with the constraint of only being able to use a flatmap is probably inevitable. However would still be still something i would like to play. Trying to design viable structures in creative mode could keep me entertained for hours.

    does anyone know a way to make text and pictures collapsible on this forum? I'm trying to make the startpost easier to read, but i don't want to remove big chunks of text.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  21. Offline

    AmoebaMan

    If they've got the spoiler tag enabled, you can use this:

    [.spoiler][./spoiler]

    Without the dots of course

    A recursive algorithm to sweep-check every block in the world? Java.lang.StackOverflowException is not your friend.

    Rather, like I said, do things on a case-by-case basis. Every time a block is updated, check every block around it, only up to its "maximum defiance" radius. This "maximum defiance" would both be a realistic element, as well as serving the purpose of massively lightening the burden on the server.

    And in any event, causing a block to fall is as simple as checking if the block beneath it is air. There's no real need for massive recursive algorithms.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  22. Offline

    roeltrachsler

    I was talking about a plugin wich prevented blocks from floating in thin air, but in which can still attach blocks to eachother. It does however not take maximum loads, shear stresses or defiance in account. Which could be a nice start.

    I agree that when you place a block only the direct surroundings have to be reevaluated. However, i think there should be an initial check of the entire world for naturally generated floating blocks. The algorithm only has to check blocks that touch air, so it maybe it doesn't cause an overflow. (but i'm not a devloper so i don't know)

    Of course you can assume there aren't any floating bits, in which event you can skip the initial check. Any floating bits will then be unaffected until they are connected to the 'global structure' and are then cut off again.




    The implementation of maximum loads/stresses or a simulation (using max defiance) of it is another case altogether.

    (on which i will reply some other time)

    Ok, here is a little thought experiment to figure out in what range the strength of rock has to be to:

    a: allow natural caves
    b: constrain man made buildings

    Assume all blocks (including dirt) to be glued together with an unbreakable bond. The entire world is a single structure. For now it only consists of a solid tower standing in a flat biome. Like this:

    [​IMG]

    Now imagine a crosssection in the x-z (horizontal) plane. And putting on the highest point of the map (the spire of the tower). All you can see is a single block. Wich has no load on it. Now move the crossection down one meter. Still ony one block., but this block has to support all the blocks above it. So it's load is:

    (the combined weight of all blocks above it)

    Now move down to a level where there are more blocks, about 3 levels down you encounter a crosssection consisting of, lets say, 5 blocks. The load on each block is:

    (the combined weight of all blocks above this layer) / (amount of blocks in that level)

    Now imagine the tower having a hole in it. If you kept moving the plane down you would eventually encounter a crossection consisting of two or more areas, at the levels where the hole is. This wouldn't change the calculation, because both areas are connected to the blocks above. And must therefore support the same blocks.

    So this calculation can be used for any level in the tower, provided the tower is build on the highest point on the map, and is the only building.

    But what if it is not?
    In the picture next to the tower is some building. We lower the cross-section to the top of that building. Now the calculation fails. We should exclude the area of the top of the building from the calculation to make the calculation for the blocks in the tower correct again. The blocks on top of the building are not loaded.

    If you you lower the crosssection even further, lets say two meters. You can calculate the loads on the blocks in both crossections seperately:

    (the combined weight of all blocks in the tower above this level) / (amount of blocks in the tower on that level)

    and the same for the building.

    Now we move the plane even further down, until we hit the ground. Now there is only a single area which is supposed to handle the load. Remember that all block are glued together. Then the calculation is back to:

    (the combined weight of all blocks above it) / (amount of blocks in that level)

    So if a crossection 'splits' it doesn't change the calculation. only if a new area arrises (because you encounter a tower or a bulge), do you need to change the calculation.

    The load on the blocks on the bottom (lowest layer which doesn't contain any bedrock) of the world is (ignoring bulges and towers resting on that level):

    (combined weight of all blocks above)/(amounth of blocks on that level)

    Wich is:

    (total area of world m^2) x (distance to sea level in m) x (percentage of air under sea level) x (averige weight of blocks in N)
    -----------------------------------------------------
    (total area of the world m^2) x (percentage of air under sea level)

    wich can be simplified to:

    (distance to sea level) x (averige weight of blocks)

    So, if air is evenly distributed in the ground, the percentage of it is not important.

    So the stone should be able to support about 64 times it own weight for the most of the natural world to stay intact. And 128x for it to be able to support mountains. However if you want to build a an inverted piramid, it would collapse if you build it higher than 5 levels. (because the load on the bottom block will be 164 x weight of a block). So man made buildings are still constrained.

    Off course this is a rough estimation, but i think i can conclude that my goals are acceavable.

    Now i should say that maximum load constraints are in my opinion not nearly as important as shear stress/deveanxe constraints, and not nearly as much fun. So i think i they can be left out for now and should only be added when the other constraints are functioning.

    (yes i know i stil don't have replyed to the theory of max 'deveance', but i will soon :) )

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  23. Offline

    AmoebaMan

    @roeltrachsler The only problem with this system is that like you said, it can only apply to a world like the above in which there are no outside structures, otherwise the cross-section calculation would deviate from reality. You could use a recursive script to get the blocks in the cross-section for only that building, but frankly that would be a little unwieldy.
     
  24. Offline

    mikeyagoto

    I dont think you understand my concern at all. The crush physics would crush the whole bottom of the map, it has nothing to do with caves. You must remove the crush or you map will be destroyed.
     
  25. Offline

    roeltrachsler

    I think understand what you mean.

    But don't you agree that blocks that could carry 128x their own weight would suffice to withstand the pressure a bedrock levels (y=6 or something like that)?

    Even if you imagine a world of solid stone from y=1 to y= 127. Blocks would only have to support 127x their own weight.

    So a value for maximum load (strength) could be 1300N and the weigth of a block could be 1oN. (for example)

    Then there would no problem for the naturally generated world. The presents of air/ore/dirt wont affect the load on the bottom layers very much. So i don't think there is a inherent problem with crushability.
     
  26. Offline

    mikeyagoto

    Ok, but remeber all of the ores and such at the bottom of the map have to be that strong also or all of the diamond will be crushed!
     
  27. Offline

    AmoebaMan

    Just started actually working on this. So far I've got four properties for Materials: weight, maxLoad (the force normal exerted by the block above), adhesiveness (basically the coefficient of friction, but with implied stickiness), and maxDefiance (maximum distance from a supported block without falling).

    Another system I'm adding is that should easily solve the problem of crushing blocks at the bottom of the map. The force normal exerted by a block on the block beneath it is decreased by the frictional force between it and all of its neighboring blocks, with the force normal between neighboring blocks assumed to be 1N in all cases. For example:

    Stone in this example has weight=10N, maxLoad=100N, adhesiveness=2.5, maxDefiance=10. In a solid block of stone, there is no force normal exerted on a block by the block above it. This is because the weight of 10N is decreased by the force of friction (2.5*2.5*1N=6.25N) for each of the four blocks surrounding it, with a net force normal of -15N (which obviously just becomes 0N). However, if a stone block only has one neighboring stone block, the force normal will only be reduced by 6.25N, and the remainder of 3.75N will be applied to the block beneath it.
     
    mushroomhostage likes this.
  28. Offline

    roeltrachsler

    First of all, i'm really excited about the fact that my idea has inspired someone to actually build a plugin (or am i giving myself to much credit XD) That was in fact the ultimate goal of this thread.

    But i would like to restate the fact that there is no inherent problem with the crushabilty of blocks on any level in the generated world. So there is no need for gravity neutralizing rules to allow for the normal world to exist. It could be that i made mistake in my reasoning or calculation, or that they are not as self-evident as I hold them to be. But i will be happy to explain or correct them should that be needed.

    Please note that this in no way a critisism of your system (i will get to thát shortly :p), but it would be a shame if you based your system on wrong assumptions.

    Also, in an effort to help as much as possible, i will continue to spout all my thoughts and opinions about the subject.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  29. Offline

    JoneKone

  30. Offline

    thedeadlybutter

    Just an idea to make the calculations simpler. Can you "cuboid" a region where you want physics applied? Or have a config to disable certain blocks from having physics applied? By disabling, Dirt stone you can just check if(block.getMaterial == Material.STONE). Or just see if a list contains the blacklisted material. At least so a working version might be easier to get up and running. I don't have much time but I will give a better response when I get home. I am really liking this idea!
     

Share This Page