Bay 12 Games Forum

Please login or register.

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

Author Topic: SCIENCE: Quantifying minecart physics  (Read 39045 times)

Snaake

  • Bay Watcher
    • View Profile
SCIENCE: Quantifying minecart physics
« 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 and expwnent's 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 and #230, and xmoffitt's, in posts #441 and #488. 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, 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 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. 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.
« Last Edit: August 24, 2012, 08:21:10 am by Snaake »
Logged

darkrider2

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #1 on: July 06, 2012, 02:41:43 pm »

Welp, watching this thread, and possibly participating later on.
Logged

xmoffitt

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #2 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)
Logged

Trif

  • Bay Watcher
  • the Not-Quite-So-Great-as-Toady One
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #3 on: July 06, 2012, 04:05:30 pm »

I did some research on parabolic paths (#10) in Kelnimar. (here and here)

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.

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.
Logged
Quote from: Toady One
I wonder if the game has become odd.

goladith

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #4 on: July 06, 2012, 04:13:14 pm »

I blame the Higgs-Boson.
Logged

Snaake

  • Bay Watcher
    • View Profile
Experiments & Results Part 1
« Reply #5 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.
« Last Edit: July 06, 2012, 05:14:28 pm by Snaake »
Logged

darkrider2

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #6 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.
Logged

Trickman

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #7 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.
Logged
This is a plain text forum signature. All typedwarfship is of the finest quality. It menaces with sentences of plain text.

Snaake

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #8 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, 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.
Logged

darkrider2

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #9 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, 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.
Logged

lcy03406

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #10 on: July 07, 2012, 02:10:19 am »

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

Snaake

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #11 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.
« Last Edit: July 07, 2012, 05:22:31 am by Snaake »
Logged

lcy03406

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #12 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.
Logged

Snaake

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #13 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.
« Last Edit: July 07, 2012, 10:19:43 am by Snaake »
Logged

xmoffitt

  • Bay Watcher
    • View Profile
Re: SCIENCE: Quantifying minecart physics
« Reply #14 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 )
Logged
Pages: [1] 2 3 ... 5