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: SCIENCE: Quantifying minecart physics  (Read 12979 times)

electrobadger

  • Escaped Lunatic
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #45 on: August 07, 2012, 06:23:56 pm »

First time poster here. I was inspired by Snaake and xmoffitt's efforts to get to the bottom of quantifying the physics of minecarts.

With numbers, and hopefully in a less cryptic form than xmoffitt's Python code.

First off, Snaake's Urist units are not a linear measure of speed. A cart travelling twice as fast will have 4 times as many Urists by this measure. I have measured speed in tiles per step (i.e. the number of squares moved using the .:One-step control, abbreviated m/s for simplicity).

As an aside, I found that almost nothing depended on minecart weight. All of my experiments were checked with a willow cart (15 U) and a lead cart filled with pitchblende boulders (453U unladen, 4253U laden). The only exception is When Minecarts Collide. Everything else seemed the same for both carts. (If anyone has proof to the contrary, I will retest.)

All of this is was done on vanilla 34.11 + Phoebus tileset.

My findings, answering Snaake's original questions, are as follows:

  • Aside from fluids, minecart physics is entirely deterministic, there is no randmness. And it bears some resemblance to real-world Newtonian physics.
  • Every dwarf gives every minecart an initial velocity of 0.2 tiles per step.
  • See above. Tested on straight and curved tracks. Also non-track, FWIW.
  • Here is Snaake's mis-step. Straight track tiles remove a constant amount of velocity per time step, not per tile. The velocity of every cart on a straight track tile decreases by 0.0001 tiles per step per step. A pushed cart at 0.2 m/s takes 2000 s to stop, travelling 200 tiles.
  • As best I can tell, curved track tiles apply the normal friction of 0.0001 m/s/s, but also subtract an additional 0.01 m/s when the cart exits the tile.
  • Carved and constructed tracks...
  • ...and bridges all have the same friction.
  • Track stops also apply friction acceleration to minecarts. The values are:
    • Lowest 0.0001 m/s/s (same as normal track)
    • Low 0.0005 m/s/s
    • Medium 0.005 m/s/s
    • High 0.1 m/s/s
    • Highest 0.5 m/s/s
    I am not sure about the 'Highest' value, but it is not infinite. A cart launched from 20 ramps up will cross 1 Highest track stop (slowing considerably).
  • Down ramps have an acceleration of 0.068 m/s/s. Since a fast moving cart will spend few ticks on the ramp, this means that it will accelerate less than a slow moving cart. As a point of reference, a cart started from rest on the 8th ramp up will reach the bottom travelling at 1.0 m/s, five time faster than a Dorven push.
  • Comparing ramps and parabolic drops is difficult. However, a falling cart actually seems to gain less energy (1/2*v2) per z-level dropped than one rolling down a ramp.
  • Up ramps have an acceleration of -0.074 m/s/s. This means that a cart can never go up as far as it dropped.
  • Unpowered rollers act like the underlying track, they have no extra friction.
  • Powered rollers give a cart a fixed speed in the direction they are pointing. The speeds are:
    • Lowest 0.1 m/s
    • Low 0.2 m/s (a dorven push)
    • Medium 0.3 m/s
    • High 0.4 m/s
    • Highest 0.5 m/s
    This attests to the general uselessness of rollers. A cart goes faster after dropping down two ramps than after being launched by the Highest speed of roller.
  • As far as I can tell, it does not matter if you have 5 rollers or just 1. As soon as the cart passes the roller, its speed is increased to the above value. This was true for both the willow and lead & pitchblende carts.
  • Max roller speed? There is only one speed. However, a cart going in the direction of the rollers, and faster than the roller speed, is unaffected by them.
  • Reverse roller running. If a cart tries to go the wrong way through a reverse roller, its velocity is decreased by 1 as it exits the tile. If the velocity goes negative (the cart would be travelling back the way it came, i.e. in the direction of the roller) it is immediately accelerated to the above roller speed. Crucially, this means a Highest speed roller can never launch a cart the wrong way through a Lowest speed roller.
  • Derailing will always occur if v > 0.5, and never occur if v <= 0.5. No rollers can ever cause a cart to derail. Again, this is independent of cart weight. Non-track tiles seem to have a uniform friction of 0.05 m/s/s.
  • Fluids introduce an element of randomness to cart physics. Here I got inconsistent and confusing results. Also, a headache. Generally, though, more water slows down a cart more, and 7/7 water slows it down a lot. This agrees with zuglar's findings, above.

Snaake's further research questions:

Maximum speed:
While I haven't tried it, there is a maximum speed set by the fact that ramps don't add a constant increment of speed. If my numbers are correct, then even a 200 z-level straight ramp will only get the minecart moving at just over 5.2 m/s. Not that that is slow, as such...

Cart-on-cart collisions:
I haven't tested this extensively, just pushing my two test carts into one another.
The results are that the collisions are not perfectly elastic. If a lighter cart strikes a heavier one, then the lighter cart stops, and the heavier cart moves off with the correct velocity to conserve momentum. If a heavier cart strikes a lighter one, then the heavier cart also stops, and the lighter cart moves off at the former speed speed of the heavier cart. Just my observations, there is a lot more to it than this.

That about covers the OP's questions.

Bear in mind, though, as with all science (and ‼SCIENCE‼), these are just the results of my tests. Corrections, complaints, comments and confirmations welcome.
Logged

Tryble

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #46 on: August 08, 2012, 04:37:05 pm »

snip of enormous, incredibly sexy test results

I would like to do things to you that aren't fit to discuss in public.
Logged

Mura

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #47 on: August 08, 2012, 05:09:03 pm »

... And welcome to the fora.
Logged
I have no idea where anything is. I have no idea what anything does. This is not merely a madhouse designed by a madman, but a madhouse designed by many madmen, each with an intense hatred for the previous madman's unique flavour of madness.

SuicideJunkie

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #48 on: August 10, 2012, 11:21:47 pm »

Down ramps have an acceleration of 0.068 m/s/s. Since a fast moving cart will spend few ticks on the ramp, this means that it will accelerate less than a slow moving cart. As a point of reference, a cart started from rest on the 8th ramp up will reach the bottom travelling at 1.0 m/s, five time faster than a Dorven push.
Comparing ramps and parabolic drops is difficult. However, a falling cart actually seems to gain less energy (1/2*v2) per z-level dropped than one rolling down a ramp.
Up ramps have an acceleration of -0.074 m/s/s. This means that a cart can never go up as far as it dropped.
How does the distance travelled carry over between tiles?
Consider a minecart with zero speed entering a sequence two down ramps followed by two up ramps, followed by flat ground:

Speed   Distance
Down Ramp 1
0.068   0.068
0.136   0.204
0.204   0.408
0.272   0.68
0.340   1.02

Down Ramp 2
0.408   1.428
0.476   1.904
0.544   2.448

Up Ramp 1
0.544   2.448
0.470   2.918
0.396   3.314

Up Ramp 2
0.322   3.636
0.248   3.884
0.174   4.058

Flat ground
0.174   4.058
0.1739   4.2319
0.1738   4.4057
0.1737   4.5794
0.1736   4.753
0.1735   4.9265
0.1734   5.0999
0.1733   5.2732
0.1732   5.4464
0.1731   5.6195
0.173   5.7925
0.1729   5.9654
0.1728   6.1382
...        ...
Logged

Urist McTaverish

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #49 on: August 11, 2012, 01:17:54 am »

Has anyone tested how a minecart full of magma reacts to being derailed? I'm interested in making a magma shotgun using a minecart and track as a sort of mass driver.
Logged
Here at Bay12, we're constantly looking for ways to set the world on fire.
But at least after all the chaos, the weather cleared.

SuicideJunkie

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #50 on: August 11, 2012, 09:42:57 am »

See:
Fully Automatic Watergun
Magma should work the same except for setting things on fire and generating long-lived dangerous terrain.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #51 on: August 11, 2012, 10:08:21 am »

Can you explain in more detail the difference in units and why the old system is wrong? I didn't quite follow that.
Logged

Dharma

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #52 on: August 12, 2012, 06:37:51 am »

First time poster here. I was inspired by Snaake and xmoffitt's efforts to get to the bottom of quantifying the physics of minecarts.
Your post is very helpful, thanks a lot :)
I am trying to build minecart repeater for archery range, but it involves turn tiles. I expected them just to have higer friction, but it turned out they subtracts 0.01 m/s from minecart velocity (probably similar to reverse roller running) in addition to normal friction.
« Last Edit: August 12, 2012, 06:41:01 am by Dharma »
Logged

Reese

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #53 on: August 12, 2012, 10:58:51 am »

Can you explain in more detail the difference in units and why the old system is wrong? I didn't quite follow that.

the new system is squares per tick(and it more likely the actual numbers behind the system), the old system was ticks per square

in other words, how far you can get in a given period of time vs how much time it takes to go a set distance.
Logged
All glory to the Hypno-Toady!

expwnent

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #54 on: August 12, 2012, 12:07:01 pm »

But a minecart could be travelling at 1 1/2 ticks per tile, and its speed could be changing slowly on a tile by tile basis, or a tick by tick basis. Ticks per tile is hard to measure accurately, isn't it?
Logged

Dharma

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #55 on: August 12, 2012, 01:38:01 pm »

Can you explain in more detail the difference in units and why the old system is wrong? I didn't quite follow that.
Urist is measure of energy and m/s is measure of speed. Urists are quite handy as they define how far cart can go until it stops, how many upward ramps it can pass etc. Unfortunately, Urists don't exists in code, they are just a by-product of speed and acceleration calculations. Hence m/s are better suited to emulate DF's internal work (which is a must for high precision things like repeaters).
Another aspect of m/s is easiness of calculating travel times. It is much easier to estimate how much time it takes for highest speed rolled cart to cross 50 tiles knowing that cart speed is 0.5 m/s than that its energy is 1250 Urists.

tl;dr Urists aren't wrong, and can be better than m/s (depends on situation).

Logged

zuglar

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #56 on: August 14, 2012, 11:58:43 am »

Down ramps have an acceleration of 0.068 m/s/s. Since a fast moving cart will spend few ticks on the ramp, this means that it will accelerate less than a slow moving cart. As a point of reference, a cart started from rest on the 8th ramp up will reach the bottom travelling at 1.0 m/s, five time faster than a Dorven push.
Comparing ramps and parabolic drops is difficult. However, a falling cart actually seems to gain less energy (1/2*v2) per z-level dropped than one rolling down a ramp.
Up ramps have an acceleration of -0.074 m/s/s. This means that a cart can never go up as far as it dropped.
How does the distance travelled carry over between tiles?
Consider a minecart with zero speed entering a sequence two down ramps followed by two up ramps, followed by flat ground:
Spoiler (click to show/hide)

So, under certain circumstance pairs up down and up ramps can deliver a net gain of energy.

For example, suppose we had a cart pushed on a track that has zero or flat segments followed by a down-up. For most lengths, the cart wouldn't make it back out of the pit, and for most of those that remain there's still a net loss of energy. For a few, though, there's a net gain:
Spoiler (click to show/hide)

20 leading tiles seems to be the best, a pushed cart will exit the up ramp moving 0.31m/s, assuming that the push starts the cart halway through the first tile and that position is updated before velocity. 29, 39, 41 and 44 also give exit velocities above 0.3m/s. The biggest problem is the numbers are *very* sensitive to initial velocity and position, so it would take some searching to find robust setups that accelerate under all conditions they might be subjected to in your particular track.

Unfortunately, it takes about 0.4m/s to climb a z-level, so it would take a lot of work to exploit this as a replacement for rollers, though I think somebody had posted a trick that repeatedly derails the minecart off corner ramp tracks.

« Last Edit: August 14, 2012, 12:09:38 pm by zuglar »
Logged

Dharma

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #57 on: August 16, 2012, 02:33:57 am »

When cart goes up or down ramp it skips half of the next tile. In case of down-up pit, the next tile is up ramp, so down-up almost always result in net gain (and up-down in net loss) of energy.
Logged

zuglar

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #58 on: August 16, 2012, 10:15:39 pm »

When cart goes up or down ramp it skips half of the next tile. In case of down-up pit, the next tile is up ramp, so down-up almost always result in net gain (and up-down in net loss) of energy.
!!

That's news to me. It changes a lot, probably makes the numbers *much* less touchy.

I'm having trouble modeling this tho. Consider a track that goes like this (seen from the side):

A_      __C
  \B_  /
     \/


My calculations suggested that pushing the cart east from B should give it enough momentum to reach C. Instead, it got almost to the top where C is, then reversed directions and ended up at A. The tiles between A and B weren't even smoothed track -- I didn't think they were needed -- and still the cart got past them, and several tiles beyond until it collided with a wall!

If it really skips a half a tile per ramp, then I don't see how it could go B-almostC-B-A when it can't go B-C. Or does it only skip the half tile when changing vertical directions (e.g. flat-up, up-down, etc.)?

BTW, speaking of skips: how much momentum does it take for a cart to skip over a gap? Does filling the hole with water/magma change that?

And, speaking of loss of energy, how much does a minecart lose when derailing or going off end of track?I've noticed that the following loop can skip over the gap outbound, but not on the return trip, when pushed east from the track stop:

   ▼╔═╗
≡══╝╞╝


But on the other hand, just two down ramps (even with matching up ramps later) gave enough momentum to run over quite a bit of terrain in my first example above...
Logged

Dharma

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #59 on: August 16, 2012, 10:55:12 pm »

When cart goes up or down ramp it skips half of the next tile. In case of down-up pit, the next tile is up ramp, so down-up almost always result in net gain (and up-down in net loss) of energy.
!!

That's news to me. It changes a lot, probably makes the numbers *much* less touchy.

I'm having trouble modeling this tho. Consider a track that goes like this (seen from the side):

A_      __C
  \B_  /
     \/

Probably, skip after ramp happens only after direction change(du - u skipped, dd - d not skipped), so it is not as useful as I thought at first. Still, it is another thing to be aware of...

Our knowledge on minecarts is far from complete. Turns and flats works exactly as they should, but ramps simulation doesn't work at all for now - and not only because of skip. I'll continue work on perfect minecart simulator, but my other, less interesting, projects demanding my attention too.
Logged
Pages: 1 2 3 [4] 5