Bay 12 Games Forum

Dwarf Fortress => DF Dwarf Mode Discussion => Topic started by: Snaake on July 06, 2012, 02:19:58 pm

Title: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 06, 2012, 02:19:58 pm
Your attention please!
Below is my original post on the subject, edited with most of my results. However, there's lots of newer, more accurate info (and written much more concisely) in eg. electrobadger's (http://www.bay12forums.com/smf/index.php?topic=112831.msg3508793#msg3508793) and expwnent's (http://www.bay12forums.com/smf/index.php?topic=112831.msg3536975#msg3536975) posts (#45 and #65, respectively). I didn't feel like rewriting everything to include their data, so go read those, or hopefully the same info will end up on the wiki pretty soon.

Quantifying minecart physics

I've been thinking about doing some sort of SCIENCE before, but haven't really had any subject strike my fancy. Until now. I'd really want to have more numeric data for minecarts, similar to how we can plan a windmill farm or waterwheel power generation scheme beforehand (power is also visible in-game though), for better design of rail systems. Exactly how much roller power do you need to ramp up a level? How long can you make a flat track before the cart stops? Does is matter how strong the dwarf pushing off the cart is? What about the weight of the cart and/or its contents? Other factors?

So, the idea is to do some more quantifying of some aspects of minecarts and their physics. When I started thinking this out, I read some stuff, and while there had been some research, most of it seemed more engineering than physics  - "how do I get this thing done/this setup to work", instead of "1 roller tile of lowest-speed rollers gives a standard iron minecart x Urists of kinetic energy." The significant exceptions I found on a read-through of the entire The "How Does Minecart?" Thread were Sadrice's testing, in posts #200 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3290448#msg3290448) and #230 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3292304#msg3292304), and xmoffitt's, in posts #441 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3328930#msg3328930) and #488 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3362517#msg3362517). At least Sadrice was using versions 34.08-34.09, I think. So some of this is verification of their results for 34.11 (even though I don’t think any of the numbers have changed since 34.08, and anything for minecarts in any way since 34.09), other stuff will be new SCIENCE. If I've missed any other results like these, please point them out, I would be very interested to compare results.

Assumptions/hypotheses and areas of research are listed below. I'll be using empty minecarts for now. Contents will weigh down the minecart, but the effects of that will have to be tested separately. I'll start off with pushing minecarts, since guiding doesn't really involve the physics at all, treating the minecart like a big, tracks-only wheelbarrow with more elaborate options, and riding is like pushing but with the dwarf as extra contents. I'll start with the speed gained from pushes, move onto the slowing effect of a flat track, then the friction of track stops, rollers of varying speed, then speed gained/lost from ramps,and finally fluids. This post will have a list of all the assumptions and their current status. Then, I'll post the actual descriptions/narrative of the experiments. I hope you'll forgive the multi-post, since my RTF of this is about 8 pages long. I will put some stuff in spoiler tags, so you don't have to scroll as much. I was originally going to post this in The "How Does Minecart" Thread (http://www.bay12forums.com/smf/index.php?topic=109460.0), since that's where the previous results were posted, and it was my inspiration as well; however, it is already 39 pages long, and doesn't seem to collect much interest anymore, hence the new thread.

List of stuff to test:
#1-6 (pushing, tracks and turns) - mostly done:
Spoiler (click to show/hide)

#7-8 (bridges and track stops) - mostly done:
Spoiler (click to show/hide)

#9-11 (ramps) - testing done, no simple answers found:
Spoiler (click to show/hide)

#12-16 (rollers) - partially/mostly done:
Spoiler (click to show/hide)

#17-21 (derailing and fluids) - abandoned/left for others to test:
Spoiler (click to show/hide)

Later research questions - left for others, as planned originally:
Spoiler (click to show/hide)


Note on units:
Spoiler (click to show/hide)

I'll be posting the more detailed descriptions of the results/setup in later posts, but will edit any knowledge into the list above. I've uploaded the save folder (http://dffd.wimbli.com/file.php?id=6626) to DFFD, if you want to do some testing with ready-made tracks (read the DFFD description and preferably the epilogue, which will come in the last of my initial experiment posts here, to get an idea what you're getting into with the fort). The version is 34.11, Phoebus tileset.
I'll be editing some results to the wiki, if they seem reliable. Feel free to test any/all of this yourself too, either for more verification, or new research into the stuff I haven't gotten into yet. It's very likely I won't have the attention span to test everything listed above in full detail; I will try to get at least some results for everything, though.


edit:
my first post describing the experiments ended up as reply #5, so scroll down a bit.
3rd post describing results (questions #9-11) is #21 (http://www.bay12forums.com/smf/index.php?topic=112831.msg3440875#msg3440875). Short versions of results also added above.
As of 25th July 2012, I'm not actively working on this anymore (will still try to check in on the thread, but not doing testing). See post #33.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: darkrider2 on July 06, 2012, 02:41:43 pm
Welp, watching this thread, and possibly participating later on.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: xmoffitt on July 06, 2012, 03:53:05 pm
One thing I discovered in my research, is that the truncation of continuous units speed and positions onto discrete units of tile location and time has a huge effect.   For example, a trackstop placed at tile "15" could have much different slowdown distance than a trackstop placed at tile "16" because the linger time is 3 ticks versus 2 ticks.

Here is a python program I wrote that models the physics and exactly reproduces all stop-distances for lowest,low, and medium trackstops.  I left off in the middle of trying to figure out what ramps do, so no guarantees on usability.

Spoiler (click to show/hide)
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Trif on July 06, 2012, 04:05:30 pm
I did some research on parabolic paths (#10) in Kelnimar. (here (http://www.bay12forums.com/smf/index.php?topic=106649.165) and here (http://))

Spoiler: Setup (click to show/hide)
Spoiler: Results (click to show/hide)

You can download the fortress and check my results (or use the setup for further falling ‼Science‼) over here (http://dffd.wimbli.com/file.php?id=6601).

I also tried it with 20 rollers, and the trajectories were identical. The maximum roller speed (#15) must be lower than or equal to ten rollers.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: goladith on July 06, 2012, 04:13:14 pm
I blame the Higgs-Boson.
Title: Experiments & Results Part 1
Post by: Snaake on July 06, 2012, 04:26:24 pm
Okay, so the descriptions of what I did start here. I hope you'll excuse the relatively free-form, written-as-I-went style. I'll try and edit some of the more number-heavy, repetitive text into more of a standard list format or something. I'll be putting the text in a few big blocks, and spoilering those, so you can read the sections you want and hide the rest. If the text feels too small, ctrl- +/- is your friend (or whatever your browser's zoom feature has as a hotkey).

So, here goes. Spent some time looking for a decent embark. 5x5 is a bit more than 200x200 tiles, and is necessary to fit a straight track long enough.
Results for #1-4 and #6.
Spoiler (click to show/hide)

Moving onto #5.
Spoiler (click to show/hide)

#7-8:
Spoiler (click to show/hide)

#9-11 postponed in favor of roller testing.

#12-13:
Spoiler (click to show/hide)

Small sidetrack to #16, then medium+ rollers for #13 & high/higher track stops for #8:
Spoiler (click to show/hide)

Finally, the epilogue:
Spoiler (click to show/hide)

That's that so far. I'm posting this now; be back in a bit to do some more editing and to reply to any posts others have made.

Added in a bit to the end of the #16 side track spoilerblock about a "best guess" for the friction of a high track stop.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: darkrider2 on July 06, 2012, 04:45:45 pm
Anyway I made a perfectly straight segment of track and measured how many frames the cart stayed on each tile, using . to advance the frames. Here are my results for the first 50 tiles. For some reason the first tile doesn't work like the rest of the tiles, I don't know why this is.
Spoiler: I now hate tables (click to show/hide)
It does slow down but I can't tell by how much each tile. The first 50 tiles seems to have an average of ~5.2 frames per tile. The tiles that need six frames get closer together and the ones that need five start getting further apart near the end.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Trickman on July 06, 2012, 04:49:26 pm
First time doing SCIENCE and you do a friggin thesis :o

Well done, mate. I'll follow this thread for more findings.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 06, 2012, 06:05:23 pm
One thing I discovered in my research, is that the truncation of continuous units speed and positions onto discrete units of tile location and time has a huge effect.   For example, a trackstop placed at tile "15" could have much different slowdown distance than a trackstop placed at tile "16" because the linger time is 3 ticks versus 2 ticks.

So your thinking is that the friction experienced is also dependent upon the time spent on the tile? Possible, I suppose, just makes our job of reverse-engineering the equations a bit harder. :P I admit I still prefer the hypothesis that the effect of a medium or stronger track stop, and probably turns, are somehow %-based off of speed, or more probably energy. One thing that complicates matters slightly is the question of which order are things calculated in: for example, is the slowdown of a turn calculated before or after the friction from just being on a track is applied?

While you're here, what's your comment on the 0.5 tiles initial push impulse by the dwarf (whereas I assumed 1 tile of guiding)? To be more specific, why/how did you decide on 0.5 tiles of push impulse, or was it just the first thing that came to mind for you? I'd also be interested in how you tested for the values you stated previously for medium track stops, floors, and turns (converting to my Urists, 50, 20, and 17.7 Urists, respectively).

Won't comment on the python program; while I can understand some python, I've never really learnt that language, and not much of a coder anyhow. :P

Trif: Nice looking results! Shows the parabolic path (=constant downwards acceleration) really well. It does look an awful lot as though the ramp doesn't add any significant upward velocity though, instead just slowing down the horizontal velocity of the cart before it launches off. Will have to have a look at those again once the slowdown from going up a ramp is figured out. More upward ramps might have enough of an effect to launch it upwards a bit, too. The setup I would use (knowing that there's probably a max speed you can achieve with rollers) would be more like a straight ramp down 10 z-levels, then a straight ramp up 3 z-levels.


Anyway I made a perfectly straight segment of track and measured how many frames the cart stayed on each tile, using . to advance the frames. Here are my results for the first 50 tiles. For some reason the first tile doesn't work like the rest of the tiles, I don't know why this is.
Spoiler: I now hate tables (click to show/hide)
It does slow down but I can't tell by how much each tile. The first 50 tiles seems to have an average of ~5.2 frames per tile. The tiles that need six frames get closer together and the ones that need five start getting further apart near the end.

Yeesh, yea that table looks like a pain to write, and I'm just quoting it. Lessee... let's just ignore the first tile, since that clearly doesn't work with normal push logic (or if it does, it only counts as half a tile)... it takes 46 ticks for the first 6-tick delay to show up (counting said 6-tick delay), then 31 ticks, then 21, 21, 16, 11, 16, 11, 11, 11, 11, 11, 6, 11, 11, 6, 11, 6, 6. Nope, can't make sense of it either. These seem to be basically the same results as xmoffitt posted in The "How Does Minecart" Thread post #488 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3362517#msg3362517), just measured in a different way? I was able to convert it so I had the location of the cart at each tick, and graph the location as a function of time; unfortunately the bending of the slope (the slowing down) is only very slightly visible. The slowing of the cart only becomes easily noticeable sometime after the first 50 tiles :(.   Always good to have people making their own, independent checks though, else we'd never catch mistakes.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: darkrider2 on July 06, 2012, 08:05:15 pm
Yeesh, yea that table looks like a pain to write, and I'm just quoting it. Lessee... let's just ignore the first tile, since that clearly doesn't work with normal push logic (or if it does, it only counts as half a tile)... it takes 46 ticks for the first 6-tick delay to show up (counting said 6-tick delay), then 31 ticks, then 21, 21, 16, 11, 16, 11, 11, 11, 11, 11, 6, 11, 11, 6, 11, 6, 6. Nope, can't make sense of it either. These seem to be basically the same results as xmoffitt posted in The "How Does Minecart" Thread post #488 (http://www.bay12forums.com/smf/index.php?topic=109460.msg3362517#msg3362517), just measured in a different way? I was able to convert it so I had the location of the cart at each tick, and graph the location as a function of time; unfortunately the bending of the slope (the slowing down) is only very slightly visible. The slowing of the cart only becomes easily noticeable sometime after the first 50 tiles :(.   Always good to have people making their own, independent checks though, else we'd never catch mistakes.

I measured speed as frames per tile. He measured as tiles per frame. 5 on my chart is 0.2 on his. Glad to see the results are somewhat consistent with other scientists. I'm thinking the game does minecart speed similarly to the way it treats creature speed. A speed of 400 means that the cart/creature must wait 4 frames before moving. While a speed of 450 means it has to wait 4 frames, move, then wait five frames to move again for a total of nine frames in wait. (450+450=900)

Unfortunately since minecarts are constantly decelerating it's a bit difficult to determine speed when the system waits till the speed ticker remainders add up to an even 100 or so before adding an extra frame to the wait counter.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: lcy03406 on July 07, 2012, 02:10:19 am
Very glad to see the science!
Would you do some experiments on ramps or water/magma?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 07, 2012, 05:19:38 am
I'm thinking the game does minecart speed similarly to the way it treats creature speed. A speed of 400 means that the cart/creature must wait 4 frames before moving. While a speed of 450 means it has to wait 4 frames, move, then wait five frames to move again for a total of nine frames in wait. (450+450=900)

Thank you for that info. I was assuming that friction etc. is calculated once per tile, and the above provides explanation of how that would work (do friction, speed adjustments etc., figure out appropriate delay before moving to next tile, wait, move, repeat).

Very glad to see the science!
Would you do some experiments on ramps or water/magma?

Like I said, I will. #9-11 are about ramps, #18-21 about liquids. I'll try and get these done first, before getting bogged down in the problem areas (medium+ track stops, turns) again. Probably not this weekend, though.

On a side note, now that low track stops have been confirmed (?) as reliably giving 4 extra friction/multiplying the track's friction by 5, you don't need a 5x5 embark to be able to test stuff (especially thinking about turns here) and be able to compare to a straight track. You only need about a 50x50 tile area at a minimum, if you use low track stops smartly. A straight track of 40 tiles with low track stops would just stop a 200-Urist cart, but you should rather use 39 tiles of low track stops and about 10 tiles of regular track, for accuracy.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: lcy03406 on July 07, 2012, 05:46:05 am

On a side note, now that low track stops have been confirmed (?) as reliably giving 4 extra friction/multiplying the track's friction by 5, you don't need a 5x5 embark to be able to test stuff
I suggest not to use any stops but embark to 1x10 or 2x10 area.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 07, 2012, 08:08:52 am

On a side note, now that low track stops have been confirmed (?) as reliably giving 4 extra friction/multiplying the track's friction by 5, you don't need a 5x5 embark to be able to test stuff
I suggest not to use any stops but embark to 1x10 or 2x10 area.

Well, that can work too, but then you can't test single turns. Hm, I was going to play my main fort for a bit now, but a thin rectangular embark would actually make for an easy test for high/highest power rollers. (duh!) Be right back.

edit: well, set up a fort in a 2x16 serene woods embark, but haven't dug out the full length of the track yet. So, you'll have to wait for next week anyway, for any results. Edit2: derp! Only just realised that even 2x16 will only be about 700 tiles of straight track. I think I'll still use this fort, because it's a lot safer than the old one (being brand new, and iirc on an island with only elves). The extra length will come in handy with downward ramp testing, which was next on the list.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: xmoffitt on July 07, 2012, 10:55:24 am
So your thinking is that the friction experienced is also dependent upon the time spent on the tile? Possible, I suppose, just makes our job of reverse-engineering the equations a bit harder. :P I admit I still prefer the hypothesis that the effect of a medium or stronger track stop, and probably turns, are somehow %-based off of speed, or more probably energy. One thing that complicates matters slightly is the question of which order are things calculated in: for example, is the slowdown of a turn calculated before or after the friction from just being on a track is applied?

This is correct.  Your conclusions about order are also valid.  For example, do you take the friction value from the tile you started in or finished in?  Do you decrease speed from friction before or after you move?  I believe I have all those things done correctly in the python program, as it exactly matches my experimental observations.   I do have a spreadsheet of raw results if you want to PM me your email address.

While you're here, what's your comment on the 0.5 tiles initial push impulse by the dwarf (whereas I assumed 1 tile of guiding)? To be more specific, why/how did you decide on 0.5 tiles of push impulse, or was it just the first thing that came to mind for you? I'd also be interested in how you tested for the values you stated previously for medium track stops, floors, and turns (converting to my Urists, 50, 20, and 17.7 Urists, respectively).

My experimental setup was a long straight track greater than 200 tiles long.  One time, I did measure the ticks the cart lingered on each tile for the entire trip (just like darkrider2).  Obviously, that was a tedious measurement.   For all subsequent observations, I just measured where the cart stopped with various obstacles along the way.  By slightly changing the number and location of the obstacles, I was able to get very accurate measurements for their friction values.

As far as the initial push, I used the per-tile delay data on the straight track to solve for the unknowns: starting position, starting velocity, and per-tick friction.  I had to try a few different assumptions about order of effects, but eventually it matched exactly.  So the reason for 0.5 is because the numbers fit and it made sense.   (Speculating about DF's internal implementation, it seems positions are tracked as floating point numbers but tiles are defined at integers, so whenever something gets built or placed it probably gets put at an exact spot "in the middle" of the tile )
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Friendstrange on July 07, 2012, 11:09:30 am
Dont we have a "How does Minecart" thread?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent on July 07, 2012, 11:48:26 am
Posting to watch.

Dont we have a "How does Minecart" thread?

This looks like it'll be MUCH more detailed and quantitative.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: darkrider2 on July 07, 2012, 02:09:02 pm
Dont we have a "How does Minecart" thread?
This looks like it'll be MUCH more detailed and quantitative.
I think that thread went off the rails at some point.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Ivir_Baggins on July 07, 2012, 02:11:46 pm
Dont we have a "How does Minecart" thread?
This looks like it'll be MUCH more detailed and quantitative.
I think that thread went off the rails at some point.

Ba-dum TISH
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 07, 2012, 05:01:56 pm
Dont we have a "How does Minecart" thread?

I'm fairly certain I mentioned this at some point:   my experiments posted here are inspired by (a few posts in) that thread, but the focus is pretty different.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: krenshala on July 07, 2012, 05:21:42 pm
For those wanting to do tables of aligned data, use the {tt} tag (I'm using braces here instead of brackets due to BB code). Its the typewriter looking icon next to subscript in the button selection above the text box for post submission.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 10, 2012, 07:01:58 pm
...Your conclusions about order are also valid.  For example, do you take the friction value from the tile you started in or finished in?  Do you decrease speed from friction before or after you move?  I believe I have all those things done correctly in the python program, as it exactly matches my experimental observations.   I do have a spreadsheet of raw results if you want to PM me your email address.
...
As far as the initial push, I used the per-tile delay data on the straight track to solve for the unknowns: starting position, starting velocity, and per-tick friction.  I had to try a few different assumptions about order of effects, but eventually it matched exactly.  So the reason for 0.5 is because the numbers fit and it made sense.   (Speculating about DF's internal implementation, it seems positions are tracked as floating point numbers but tiles are defined at integers, so whenever something gets built or placed it probably gets put at an exact spot "in the middle" of the tile )

I'll send you a pm with my email address, but would you mind explaining the basics about the python program (seeing as you already posted the code anyway), or rather, describe the calculation steps (done per tick?), and their order, so others could understand it better too?


So yup, 2nd minecart science fort: 2x16 embark, forested island, right next to some elves, hopefully no goblins (didn’t remember to check, but most of the island was inhabited by the elven civ). 2x16 means the embark is a bit under 100 tiles wide, but I now have a N/S tunnel 766 tiles long.

Testing #9-10 (down ramps, ramp friction):
Spoiler (click to show/hide)

Testing #10 (up ramps):
Spoiler (click to show/hide)

I also think it’s noteworthy that due to my impatience and lazyness (to disable the push command for the short while dwarves were doing modifications), at least 4 dwarves have received various fractures and at least as many others some bruises (one got hit 3 times because he took so long to carve tracks). One was unlucky enough to get a piece of skull jammed through his brain, and died. So… feather wood minecarts: maybe safer than iron ones, but don’t bet on it?

For the next update, I think I'll test how much energy highest rollers give (finishing up #13), then maybe continue with the rest of the roller questions. I think I'll try and split up the SCIENCE into smaller chunks from now on (well, this post is already implementing that idea, but the reasoning for the earlier megaposts is I didn't want to just make a post with all the research questions, then have people wait several days before giving any results).
Title: Re: SCIENCE: Quantifying minecart physics
Post by: DrKillPatient on July 10, 2012, 09:11:27 pm
Here's something perhaps worth investigating, if at some point the tests branch off into physics of creatures in minecarts: if a dwarf swings his melee weapon at an enemy while riding past it in a minecart, will the momentum of the minecart add to the force of the swing? I'd guess that the best way to test this would be with hammers hitting low-weight creatures. If the force of the swing is at all affected, it will likely cause the creature to fly farther. This probably cannot be quantified by injuries to the enemy unless the effect is so extreme as to yield radically different types of wounds.

EDIT: Two more points of interest:
- Can enemies strike at a dwarf in a minecart, and if so, do they suffer any penalty for doing so?
- If a weapon is embedded in a minecart-riding dwarf, will it be yanked out of the wielder's hands and carried along? If not, will it be pulled out of the dwarf by the advance of the minecart?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 11, 2012, 05:36:45 am
Here's something perhaps worth investigating, if at some point the tests branch off into physics of creatures in minecarts: if a dwarf swings his melee weapon at an enemy while riding past it in a minecart, will the momentum of the minecart add to the force of the swing? I'd guess that the best way to test this would be with hammers hitting low-weight creatures. If the force of the swing is at all affected, it will likely cause the creature to fly farther. This probably cannot be quantified by injuries to the enemy unless the effect is so extreme as to yield radically different types of wounds.

EDIT: Two more points of interest:
- Can enemies strike at a dwarf in a minecart, and if so, do they suffer any penalty for doing so?
- If a weapon is embedded in a minecart-riding dwarf, will it be yanked out of the wielder's hands and carried along? If not, will it be pulled out of the dwarf by the advance of the minecart?

I think it would be difficult to test even with the knockback, since that can be quite random too. I've had cats fly a few tiles, or not fly at all, when getting hit by a cart (of approximately the same speed). That said, cavies/bunnies.would be pretty ideal test subjects I think. And I think we know so little of the exact statistics of combat mechanics and skills (cprrect me if I'm wrong) that figuring out any sort of penalty that might result from the speed would be nigh impossible.

Regarding the other two points, there was an example in the dev logs where a dwarf was riding a cart that was launched through the air and it's flight path passed near a goblin on the ledge. The goblin swung at the dwarf as he passed by, and the dwarf dodged out of the cart and onto the ledge.

Not going to do it any time soon (since I still have several of my original points untested), but I'd probably test this by pitting some the target(s) in a something*3 area, and engineering a cart to pass through the middle (preventing gobbos from getting out somehow - probably easiest just with gaps in the floor).
Title: Re: SCIENCE: Quantifying minecart physics
Post by: WanderingKid on July 11, 2012, 02:58:53 pm
Just to add in a little extra data, I believe you're correct that 'highest friction' is roughly infinite.  I currently have a minecart build that gets guided up about 30 z levels and gets pushed back for marble rock movement up to the main smelting area (I've got a ton of coal in this fort).

That cart's return path is simply a series of slopes back down to the pickup zone.  If it's picking up 500 Urists (roughly) per level, it's at (at least) 15,000 Urists when it hits the turn near the bottom (walled for guidance) and then the friction stop.

A way to test this might be to use simple floor friction.  Don't use the track after a certain point and see how far it goes on the floor.  Hm.  My current embark isn't wide enough to try that.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 11, 2012, 03:14:24 pm
A way to test this might be to use simple floor friction.  Don't use the track after a certain point and see how far it goes on the floor.  Hm.  My current embark isn't wide enough to try that.

Definitely a good way to test it, once floor friction is known :P. You mentioned that the track stop is after a turn, what about if you move it to right at the bottom of the 30z ramp? Of course, I think we can only call it "effectively infinite" if it's tested on something like a straight set of ramps down a mountain slope and underground all the way to SMR, and a highest track stop there, immediately. That could net something like 300z at least, for about 150 000 Urists. Effectively infinite, since that's the highest-energy setup I can think of that's achievable with regular worldgen (oh, you can add a set of highest rollers at the top I guess, but that's only a couple of thousand Urists more, probably).
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Reese on July 11, 2012, 03:57:02 pm
I am so glad people are quantifying these things, I have been having so much trouble figuring this stuff out on my own.

The how does minecart thread was so disappointing and lacking in !!science!!, and the wiki doesn't have much info yet either.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: WanderingKid on July 11, 2012, 04:02:35 pm
Definitely a good way to test it, once floor friction is known :P.
I thought earlier in the thread it was tested out at 16 Urists?

Quote
You mentioned that the track stop is after a turn, what about if you move it to right at the bottom of the 30z ramp?
Not in that particular setup, I can't.  I'm relatively sure I'll be making another 'long hauler' cart shaft down to the caverns eventually to bring up random goods, I'll try it then.


Quote
Of course, I think we can only call it "effectively infinite" if it's tested on something like a straight set of ramps down a mountain slope and underground all the way to SMR, and a highest track stop there, immediately. That could net something like 300z at least, for about 150 000 Urists. Effectively infinite, since that's the highest-energy setup I can think of that's achievable with regular worldgen (oh, you can add a set of highest rollers at the top I guess, but that's only a couple of thousand Urists more, probably).
I'm expecting there's a max-Urist speed for minecarts, otherwise they'd eventually catch on fire from air friction.  Though, I have to admit, using that as a weapon into your HFS entry could be hysterical, if you can control it to be a single path outwards.  Clown Smear by Cart.  Joy.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 11, 2012, 04:54:35 pm
Definitely a good way to test it, once floor friction is known :P.
I thought earlier in the thread it was tested out at 16 Urists?

That's what I got from one non-repeated test (since it was actually an accident). xmoffit quoted a figure of 20 Urists in the other thread, though, iirc. Something in that range, probably, but the exact mechanics are still less certain.

Quote
I'm expecting there's a max-Urist speed for minecarts, otherwise they'd eventually catch on fire from air friction.  Though, I have to admit, using that as a weapon into your HFS entry could be hysterical, if you can control it to be a single path outwards.  Clown Smear by Cart.  Joy.

I also think it's possible there's a general max speed, hence it's inclusion in "later research."
Title: #13-14, plus bonus question
Post by: Snaake on July 12, 2012, 04:52:22 pm
#13-14:[/u]
Spoiler (click to show/hide)

tl;dr version: Posting some results now: Highest rollers are 1250 Urists (I think; see the full text), as per my previous guess. Having several 1-tile rollers just gives the same speed as with only one 1-tile roller. Longer rollers not yet tested.

Started testing a new question: how much energy does a minecart need to skip over a 1-tile "open space" channel? Answers so far:
p=.== or R.== both work, that is to say, if a dwarf pushes (the p) a cart, it needs to have 1 tile between the channel and the hauling stop with the push, but if rollers are used, the gap can be adjacent. Testing for energy required is ongoing (didn't have time to play today, just writing up what results I got yesterday evening).
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Urist Da Vinci on July 12, 2012, 08:30:27 pm
... if a dwarf swings his melee weapon at an enemy while riding past it in a minecart, will the momentum of the minecart add to the force of the swing? ...

Nope, it doesn't. We'll have to wait for Toady to add mounted combat before that'll work.

Other interesting points: a dwarf who jumps out of a moving minecart will keep moving in the direction of travel, but if he then drops an item from his inventory, it falls straight down. Shooting a crossbow from a moving minecart likewise assumes a stationary launching position.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: lcy03406 on July 12, 2012, 11:29:48 pm
... if a dwarf swings his melee weapon at an enemy while riding past it in a minecart, will the momentum of the minecart add to the force of the swing? ...

Nope, it doesn't. We'll have to wait for Toady to add mounted combat before that'll work.

Other interesting points: a dwarf who jumps out of a moving minecart will keep moving in the direction of travel, but if he then drops an item from his inventory, it falls straight down. Shooting a crossbow from a moving minecart likewise assumes a stationary launching position.

But HOW to give the mount and shoot order?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: xmoffitt on July 15, 2012, 09:35:15 pm
I'll send you a pm with my email address, but would you mind explaining the basics about the python program (seeing as you already posted the code anyway), or rather, describe the calculation steps (done per tick?), and their order, so others could understand it better too?

Sure, here is the simple overview.

Everything is is just fancy stuff to look for different values that "fit" the observation.   I used it to get the friction values for Lowest, Low, and Medium track stops.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on July 25, 2012, 08:47:45 am
Hey, just though I'd pop in to explain why I haven't been posting, and do a little "what now?" post in general.

So, I sort of drifted away from DF. The blame is largely on Steam summer sales; I've been playing Terraria (inspired by minecraft, which was inspired by DF), especially the multiplayer with my girlfriend. Also gotten into the Day Z mod in the past couple of days. At the moment, I don't think I'll be playing DF very actively for a few weeks at least, but might be longer than that, to be honest (months, a year...). DF is one of those games I drift in and out of.

I will try and push myself to finish testing #14-15, since I've done part of that already; no promises though. The same applies to editing some of this info to the wiki (I did write a mention of the thread on the discussion page for the minecart article, requesting a rewrite of the physics section, citing at least this thread, can't remember if I cited others too). Other than that, feel free to finish testing this stuff, using either this thread or some other, more active one, to post the results in.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: eRaz0r on August 01, 2012, 03:20:15 am
While my "experiments" are not to the rigorous level of scientific inquiry as my predecessors here, I'd like to add some minor observations of my own.

1. Rollers built on an upward track (track and roller a single tiles length) can and will launch a cart off the rails on the level above.
2. Carts do have some kind of angular momentum.  A descending ramp track with a turn in it (.e.g a corner ramp) can derail a minecart if there are no walls. The derailment is at an angle less than the 90 degree angle that the ramp should have imparted.
3. Track Stops set to "dump"  will not dump riding dwarves.
4. When using a T-junction with rollers (as presented in the wiki) to control automated movement, riding dwarves are forcibly dismounted at the T, when the cart continues in the direction of the roller. I have not finished testing this last one.  I want to see if I can slow the cart down enough that the direction change is gentle enough that the dwarf remains in the cart.


My fort has a large "roller coaster" that I intended to use to put my marksdwarves on - to ride around the map shooting at whatever they see. The coaster works reasonably well - I have a mount point on top of an archer tower in the west above the "yard" (my old fort entrance). The track ramps down a few Z's as it progresses east over the yard, and turns south until it hits the top of another tower where it joins the "gatehouse" track that zooms in front of the gate (2 z's above the entrance)  and eventually enters the northernmost archer tower where it spirals down into the earth. At bottom the track heads due south.  About the middle of the map there's a T junction. If the rollers are off, the hapless marksdwarf will continue back to the southern archer tower and spiral up the ramps automatically (thanks to the windmill farm on the tower top) where he continues to zip in front of the gatehouse. That's entirely automated.  If the rollers are on, he was supposed to go back to the base of his original archer tower, where he'd have to climb the stairs to top.

So far, the problems are
a) dismounting on the rollers
b) can't get the marksdwarves to ride the thing properly.  Even locking doors and hatches and things, and they still just stand there.  I may have to experiment with burrows next.

Well, that's my contribution (such as it is) to the science of minecarts
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Gerottomo on August 01, 2012, 09:05:53 am
One thing to test would be if a minecart with a large weight in it will derail easier than one without as it would in actuality due to inertia and center of gravity.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Sutremaine on August 01, 2012, 11:01:09 am
My fort has a large "roller coaster" that I intended to use to put my marksdwarves on - to ride around the map shooting at whatever they see.
I think this would work as a track switcher, but I haven't done anything with bridges yet:

Code: [Select]
.1....
.1....
.11111
......
.22222
.2....
.2....
Track 1 is, at least at that corner, slow enough to not derail the track as it turns the unwalled corner. To make the switch to Track 2, you unretract the three-tile bridge that covers the gap plus the two corner track tiles, and have the cart come from the north.

Code: [Select]
.1....
.1....
.|1111
.|....
.|2222
.2....
.2....
Title: Re: SCIENCE: Quantifying minecart physics
Post by: eRaz0r on August 01, 2012, 01:16:04 pm
My fort has a large "roller coaster" that I intended to use to put my marksdwarves on - to ride around the map shooting at whatever they see.
I think this would work as a track switcher, but I haven't done anything with bridges yet:
That looks workable. 
My current set up is more like this :

Code: [Select]
1 . . .
1 . . .
1 . . .
2 2 2 2
1 O O O
1 O . .
1 O . .
Where track 2 has a roller on it to pull the cart on to it.   Your idea sounds better. I've had a lot of luck with controlled derailment feeding from one track to another. 
(I have a double-helix spiral that goes down many z's to various levels - marble mine, spider silk farms, gold mine.  At each major level, using doors and derailment instead of T junction tracks, I can control whether the cart stops there and short-circuits the rest of the descent depending on what my dwarves need..
Title: Re: SCIENCE: Quantifying minecart physics
Post by: eRaz0r on August 01, 2012, 05:00:39 pm
I've gotten the T junction working perfectly as you described. This is much more elegant than the Rollers, and the riders stay in the cart.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Sutremaine on August 01, 2012, 05:17:27 pm
Much easier to power as well, on account of not needing any power.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: eRaz0r on August 02, 2012, 01:19:45 am
Much easier to power as well, on account of not needing any power.

Indeed - one problem though - it's too vulnerable to changes in cart speed. With the bridge retracted, the cart may or may not derail depending on the speed it's gotten at that point.

I went with a different option - a door instead.  The door acts as a wall to "encourage" the cart to stay on the corner, and when closed, the carts jump the corner on to the continuing track.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Tryble on August 05, 2012, 02:58:28 pm
So, if I'm reading all of this right, a short list of facts we now know based on your testing:

One tile of distance traveled is labeled one Urist.

Propulsion:
Minecart travel distance is unaffected by weight or load.
Dwarves push at 200 Urists regardless of Strength, but ignore all or some of the friction of the initial tile some.
Roller speeds are measured at 51/201/451/801/1250, medium/high speeds being estimates.
Downward ramps grant an additional 470-560 Urists of movement.

Friction Costs:
Minecart tracks of any sort cost 1 Urist per tile.
Bridge tiles also cost 1 Urist.
Non-track floor costs 14 Urists.
Track stops add an additional 0/4/40-52/800-850/∞ friction to a tile, medium and higher being variable or estimated.
Turns on a track have an estimated friction cost of 9-14, variable for unknown reasons.

Other:
Bridge tiles operate identically to tracks except for pathing purposes when the cart is guided.
Upward ramps are wonky; they can decrease or increase the distance traveled by a cart.
A 200 Urist push is enough to cause a cart to jump over a 1 tile gap, as long as the gap is not adjacent to the dwarf push (pushd by roller is fine).  The gap doesn't cause any loss in travel distance.


Is this right?  I may have misread or misinterpreted some things.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Sutremaine on August 05, 2012, 03:47:54 pm
Indeed - one problem though - it's too vulnerable to changes in cart speed. With the bridge retracted, the cart may or may not derail depending on the speed it's gotten at that point.
You can use track stops to slow a cart down, and they can be made one-way if you use a pressure plate with the track stop.

Quote
I went with a different option - a door instead.  The door acts as a wall to "encourage" the cart to stay on the corner, and when closed, the carts jump the corner on to the continuing track.
Closed?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Urist Da Vinci on August 05, 2012, 03:59:47 pm
...
Dwarves push at 200 Urists regardless of Strength, but ignore all or some of the friction of the initial tile some.
Roller speeds are measured at 51/201/451/801/1250, medium/high speeds being estimates.
Downward ramps grant an additional 470-560 Urists of movement.
...

Another implication: we think rollers have a "do not exceed" speed, and rollers alone aren't sufficient to "shotgun" cart contents. We also know that 3 z-levels (perhaps plus a dwarf push) are required at minimum to "shotgun". This puts the shotgun requirement somewhere between 1250 - 1680. Careful use of track stops could make this number range smaller.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: zuglar on August 05, 2012, 04:50:19 pm
Very glad to see the science!
Would you do some experiments on ramps or water/magma?

I can throw in what I've observed building a magma dipper route:

The dip needs to be at least 2 tiles wide (cart skips over 1-tile holes, I've never tried 3). An iron minecart needs a 2z drop into still 7/7 magma to pick anything up and still escape. A 1z drop will leave it stuck (and Newton's cradle won't get it out). 6/7 magma won't give any to the cart (contrary to the wiki). Sending a cart in while a magma pump is active will get the cart stuck. I have no idea why the latter, unless 7/7 magma is too much friction for a full cart to escape.

Title: Re: SCIENCE: Quantifying minecart physics
Post by: electrobadger 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:


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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Tryble 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Mura on August 08, 2012, 05:09:03 pm
... And welcome to the fora.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: SuicideJunkie 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
...        ...
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Urist McTaverish 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: SuicideJunkie on August 11, 2012, 09:42:57 am
See:
Fully Automatic Watergun (http://www.bay12forums.com/smf/index.php?topic=114654.0)
Magma should work the same except for setting things on fire and generating long-lived dangerous terrain.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Dharma 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Reese 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent 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?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Dharma 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).

Title: Re: SCIENCE: Quantifying minecart physics
Post by: zuglar 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.

Title: Re: SCIENCE: Quantifying minecart physics
Post by: Dharma 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: zuglar 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...
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Dharma 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.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: zuglar on August 16, 2012, 11:40:49 pm
Non-track tiles seem to have a uniform friction of 0.05 m/s/s.

I think this is wrong. I'm trying to verify with the following setups, where the top is purely rough stone and the bottom two are stretches of rough followed by track:
■....................
■..........==========
■.........========================================

Pushing each cart, the top one travels 11 tiles, the middle travels 18, and the bottom 37.

Assuming vIn=0.2, that the push skips the first half tile, and that position is updated before velocity***, that's a friction of roughly 0.002m/s/s, but not exactly: it predicts travel of 10.4/18/31; using friction of 0.00185m/s/s instead predicts 11.2/14.9/31. Again that numerical instability shows up, which makes me suspect the computation is based on ticks/tile rather than tiles/tick. I'll try to work out numbers that way and report back.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent on August 17, 2012, 09:31:54 am
Creatures can move "partial" tiles, in that if they don't have a speed of an integer number of ticks per tile, it'll average out correctly. Could that explain the numerical instability?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Sutremaine on August 17, 2012, 01:14:42 pm
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:

   ▼╔═╗
≡══·╝╞╝

Corners drain speed. Try pushing a cart along a track vs. along a track with channels vs. along a track that derails at every tile (you might want to construct that last one...).
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent on August 17, 2012, 03:27:53 pm
I've discovered something strange. I use a linear accelerator as described, with 20 NE ramps to accelerate a pushed minecart. After the 20 NE ramps, there's an EW ramp to launch the cart. One tile above it and to the east, there's another EW ramp, but the higher ramp does NOT have a wall to the right of it, so it's unusable.

Minecart is pushed from the far west:

Side view:
Code: [Select]
       R
...AAARW

A = accelerator = NE

The effect: the minecart stops in midair after launching off the second ramp. With a wall placed after the second ramp, the minecart launches as you would expect. With the wall after the first ramp removed, it just ignores the first ramp.

This is still quite unsafe for dwarves riding in the cart. They tend to take damage in midair just before the cart falls, probably due to the rapid acceleration.

Strangely enough, you can get splatterings of blood in midair in this way. I'm sure this can be weaponized somehow. If you can launch a creature with poisonous blood in this way, you can use it as defense against flying creatures maybe.

edit: It will also launch its contents, if any.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: zuglar on August 17, 2012, 05:18:23 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.

Quote
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.

What's the fastest anyone's ever actually observed a cart going? If the model I'm working on is correct, the absolute upper speed limit approaches two tiles/tick. A 100-z down ramp would give enough velocity to make a cart skip a tile very few tiles traveled. Caveat: this does *not* incorporate the half-tile skippage that was recently pointed out, so occasional "glitch" tile skips are probably possible at lower speeds.

Another prediction of my model: a 2x2 all-corners downward spiral should be somewhat self-regulating, with v approaching 0.67m/s and taking about 80z for a cart to pass 0.6m/s.

Only problem: my model predicts that an 8z down-ramp should only accelerate a cart to 0.4m/s; I haven't tested this prediction explicitly, but it is fairly consistent with my observations of a spiral down-ramp (diameter 3) I had dropping 30z.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent on August 18, 2012, 08:05:56 pm
I can confirm electrobadger's main results. I used CheatEngine to look into the game. The minecart has a variable for speed. Speed is measured in tiles/100000 per tick, so a speed of one hundred thousand means one tile per tick. Since the game internals use these units, this is what I will use.

The maximum speed is 270,000. You can hit it exactly by going down enough ramps.

Every tick, your speed goes down by some constant based on what tile you are currently on.

Distances: if you push a cart, you start in the MIDDLE of the next tile, not the far end of it, so it takes half as much for you to get past it. Normally, once you've accumulated 100000 distance units, you move to the next tile. This DOES carry over to the next tile.

Tile: friction
Tracks: 10
ground/floor: 200
unusable ramp: 10
going up a ramp: 4910
going down a ramp: -4890

A dwarven push starts the minecart at 19990 in the middle of the next tile, in that the first nonzero speed that the cart has is 19990.

Corner tracks are 10, but on leaving the corner tile, you get penalized another 1000 (in addition to the friction of the next tile).

Track stops:
highest: 50000
high: 10000
medium: 500
low: 50
lowest: 10

Empty space is entirely frictionless.

You CAN phase through walls if both flying and moving faster than one tile per tick, but you stop immediately on the other side. Cue everyone's secret fortress entrances behind walls.

---
WATER

Take the water level (out of seven), then subtract one, then multiply by 100. Add this to the tile's normal friction to get the friction of the tile in that much water.

MAGMA

Take the magma level out of seven, then subtract one, the multiply by 500. Add this to the tile's normal friction to get the friction of the tile in that much magma.

If the cart at least 6/7 deep, and it has room, it will take 2/7 into itself.

I'm (finally) tired of this. I'll put it in a more digestible format on the wiki later.

edit: Different water/magma levels have different maximum speeds. Research for later.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Snaake on August 24, 2012, 08:16:08 am
So, if I'm reading all of this right, a short list of facts we now know based on your testing:
...
Upward ramps are wonky; they can decrease or increase the distance traveled by a cart.
...

Is this right?  I may have misread or misinterpreted some things.

The rest was correct: upward ramps do always decrease the distance traveled from what it would've gone on the lower z-level; however, if minecarts go down, then up a ramp, that's unpredictable. Probably because both vary around some identical(?) average (due to some integer rounding or something in the physics), so sometimes you get a net gain, sometimes a net loss. Looking back at the data (post #21), the most common result I got was an increase in kinetic energy.

Other than that, I'd like to thank at electrobadger for doing some independent testing; from a quick(ish) look, it seems that portions of both xmoffitt's and my research were validated. Looking at his results, I'm especially happy that the abovementioned mystery of ramps is solved (points 9-11, post #45 (http://www.bay12forums.com/smf/index.php?topic=112831.msg3508793#msg3508793)): up ramps do take away more energy from a cart than a down ramp gives, but this is per tick, not per tile, and so, since the cart is traveling faster after the down ramp than it was before, it spends less time on the up ramp than it did on the down ramp, and hence, often has some speed "left over". Also an interesting note about the existence of an asymptotic maximum speed, even for megaramp-powered carts.

Also, kudos to zuglar and expwnent (why on earth didn't someone check what the actual internal units were before... *facepalm*). This is starting to look more or less "solved". I think I'll have another look at all that weird-looking data I got for turns, would be satisfying to see it match simulations based off the values mentioned recently.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: taptap on June 13, 2015, 04:27:34 am
Track stops:
highest: 50000
high: 10000
medium: 500
low: 50
lowest: 10

Is this still correct?

A minecart coming out of a speed limiter (i.e. 45-50k speed) when going through a series of high friction track stops on the second, indicating 25k friction if I am not missing anything. Wait, per tick not per tile?
Title: Re: SCIENCE: Quantifying minecart physics
Post by: expwnent on June 13, 2015, 05:28:05 am
It is per tick, not per tile. I have not checked the results since I originally produced them.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: taptap on June 13, 2015, 06:22:07 am
It is per tick, not per tile. I have not checked the results since I originally produced them.

Sorry, I realised it a little later.
Title: Re: SCIENCE: Quantifying minecart physics
Post by: Max™ on June 13, 2015, 04:13:44 pm
Huh, I think I bumped into the 270k speed cap from the other direction while screwing with launch.lua, I was opening gm-editor in mid-air and screwing with the projectile speeds and I recall that setting it over something like 2.5 million tended to result in death, superdeaths whereupon even if you cheat and resurrect yourself you immediately slam into something again.

Oh and at speeds that high you can grind yourself against the roof of the skybox it looks like. I didn't think to try 2.7 exactly, I just know 3.0 = death, 2.5 = generally ouch, ~2.25 = usually safe.

...BAHAHAHAHAHAHAHAHAHAHAHAHAHAHA... ok, yeah, I confirmed that 2.7 million is a safe speed for a unit in flight, and was going to see what happened if I touched down with the flag toady told me lets you do a safe jump to land on your feet, well, this is also the save I was testing artifake and names with right?
Spoiler (click to show/hide)
So yeah, I hit a tree (and went through to the other side, painfully >.<) but that isn't why I'm laughing.

I named my upper greaves "Crotchsaver" because I was just doing simple names, Headbox, Kittenstomper, etc, and Crotchsaver seemed apt... and it was!
Title: Re: SCIENCE: Quantifying minecart physics
Post by: NW_Kohaku on June 13, 2015, 06:09:32 pm

A minecart coming out of a speed limiter (i.e. 45-50k speed) when going through a series of high friction track stops on the second, indicating 25k friction if I am not missing anything. Wait, per tick not per tile?

Are you accounting for the checkpoint bug?  The first tile after a ramp has no effect upon a cart, and a cart will pass through it in one tick.