v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User:Larix/MPL/1

From Dwarf Fortress Wiki
< User:Larix‎ | MPL
Revision as of 19:04, 8 October 2013 by Larix (talk | contribs) (Created page with "1. Foundations: intensely boring minecart physics A cart going across a track ramp will be accelerated when moving down and decelerate when going up. So far, so obvious. Howe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

1. Foundations: intensely boring minecart physics

A cart going across a track ramp will be accelerated when moving down and decelerate when going up. So far, so obvious. However, the exact rules get rather complicated: a ramp will only provide acceleration if it has an actual "up" and an actual "down" connection - one "branch" must touch a wall, another a "non-wall". A ramp not so connected will provide no acceleration (except for some peculiar cases with one-connection ramps). A cart will accelerate if it is moving towards the "down" connection of the ramp, regardless of where it came from. This is the basis of "impulse ramps" - a cart moving to the north and passing over a track ramp connected to a wall to the east and with a proper "down" connection to floor to the north or west will accelerate, even though the cart clearly didn't enter from above. A cart set down on a legal ramp will roll "down" the ramp, gaining speed from a complete standstill.

To make matters even weirder, distance calculations when coming off ramps are strange and buggy. The cart will "teleport" through most of the next tile. Since acceleration/deceleration on ramps is calculated per game step, this reduction of lingering time on "neighbouring" tiles will massively reduce the deceleration experienced on up ramps directly adjacent to down ramps, to the point that a cart standing inside a pit consisting of two adjacent track ramps will first gain speed by going down one of the ramps and lose so little speed on the up ramp (thanks to the teleportation bug) that it will lift itself out of the pit and move off at a substantial speed. As a minor adjunct, the cart will typically also spend next to no time on the tile just outside the pit after ascending.

By abusing those bugs, carts can be set in motion and kept moving, and their speed can be regulated to the desired range. Keep in mind that sequential ramp accelerators can accelerate carts past derail speed, causing the vehicle to jump out of the pit, potentially colliding with the ceiling or walls and refusing to enter later pits.

Foundations: Path-blocking buildings

Hatches are a very convenient tool to switch paths of incoming minecarts: they react instantly to received signals and are easy to build. The most reliable switching method is to put the hatch cover over a ramp a cart is trying to pass from below. In this case, the cart will never be in the same tile as the hatch: if the hatch is closed, the cart will bump against it from below and roll back down the ramp. If the hatch is open, the cart will pass directly from the ramp tile below the hatch to the floor tile next to the ramp and hatch. Alternatively, a hatch can be put over a ramp and the cart's path routed across the hatch itself. If the hatch is open, the cart will instantly dive into the hole (this is a special rule for ramps - carts will jump past ordinary open holes in most cases - but requires the cart is moving at less than derail speed), if the hatch is closed, the cart will pass over it in a straight line. Hatch covers have the same friction as not-engraved floor. Except in case of very slow-moving carts, this higher friction is irrelevant. Should the hatch open while the cart is directly on top of it, the cart will not enter the ramp in the normal way, but rather loses its entire forward momentum and "falls" into the pit. It will pick up speed from the ramp it lands upon, but may behave differently from the usual cases. A hatch cover over a ramp is also a very convenient signal-operable starting mechanism for minecarts. The cart is simply placed on top of the closed hatch cover and gets dropped onto the ramp below when the opening signal is received.

Design: from the side:

  H__
__/#

from above: closed hatch:

.¢==

open hatch:

.▼==

Doors also react instantly to signals but require an adjacent wall to be built. Constructed walls can be deconstructed after the door is built, this will not impinge the efficiency of the door. To switch tracks in combination with ramps, the only applicable use of doors consists of placing the door on the level floor right next to a ramp-hole a cart tries to emerge from. If the cart encounters a closed door while trying to ascend, it will fall back into the hole. This design works similarly to the first application of hatch covers. It can probably cause an operation error when a door receives a close signal the very same instant a cart is passing through it. I have not yet seen it happen, but if it happens, the door should get wedged open in spite of the signals indicating it should be closed and the cart should get stuck in the door, stopping it dead.

Design: from the side:

   D_
__/#

from above: closed door:

.▼D=

open door:

.▼==

Floor grates and floor bars should work similarly to hatches, flood gates, wall grates and vertical bars similarly to doors, with the notable difference that each of these buildings has an added 100-step delay before reacting to a signal. Apart from designs hinging on specific delays before releasing a cart or switching a track, those buildings are largely useless for our purposes.

Raising bridges can be used in the same way as doors, but react in opposite ways to signals: a raising bridge switched "off" will grant passage, when switched "on" it will block passage. Retracting bridges work like hatches, but can span larger gaps instead of the one-tile hatch covers and provide less friction. Bridges take 100 steps to react to a signal and will throw, hurl or crush a cart passing over them while they change state, sharply limiting their usefulness in logic.

Logic, building blocks: Operative ramps

I built most of my pathing logic with double-ramp pits, with hatches over one of the pit exits to switch the paths while providing sufficient speed to keep the carts in circulation.

The simplest design is the straight double ramp:

from the side:

__..__
##\/##

from above:

upper level:

==▼▼==

bottom level:

##▲▲##

track on the ramps: == (EW)

I'll go through the possible cases assuming first a cart coming from the west:

If the exit is open, the cart will roll down the ramp, accelerate and emerge on the other side, continuing east, at increased speed.

If the exit is closed, the cart will roll down the ramp, bump into the obstacle (hatch/door/wall/ceiling) and gain speed from a standstill on the eastern ramp. Due to ramp teleportation, that will give it enough speed to emerge from the pit again and return to the west.

If a cart falls into the pit, either coming from the north or south or dropped (say, by opening a hatch cover it was sitting on), it will accelerate on the pit it fell into and emerge from the adjacent pit. A cart falling into the western pit will try to exit to the east.

Of course there are all kinds of exceptions for particularly fast- or slow-moving carts as well as for carts that enter the pit on a diagonal trajectory.

Another very simple but somewhat less predictable design is the "loop ramp":

from above:

top level:

=▼
=▼

bottom level:

###
#▲#
#▲#
###

engraved track on the ramps

╗
╝

A cart arriving on the northern track will roll into the northern pit, gains speed on that ramp, teleport-lifts out the southern ramp and leaves on the southern track. Alternatively, it will not gain the proper kind of speed on the first ramp, thus will not get off the southern ramp but accelerates off this ramp too, lifting itself out of the northern ramp and returning along that track. I don't know at which point the behaviour switches between passage and "back-swing", but i'm certain this behaviour is caused by the fact that the ramps accelerate the cart in direction perpendicular to its entrance trajectory and cause a degree of diagonal movement. Consequently, the walls around the ramps on the bottom are required for safe operation, if there is a breech in the walls, the cart may jump through the hole. A hatch cover or other means of blocking the exit from one of the ramps will ensure a cart will return on its path, which is evidently only an actual switching method if the cart would have passed through originally.

Other means of combining pairs of ramps in a single two-by-one pit aren't functionally different from the above two.

It is possible to build functional ramped pits larger than that, although one must keep always in mind that to provide acceleration to a cart a ramp must have at least one wall connection and _exactly_ one "down" connection. Ramps with multiple wall connections work adequately, but a ramp with more than one downward connections will not accelerate carts; apparently the game needs a definite cardinal direction to accelerate a cart towards, if two or three directions are offered, the engine decides to pick "none of the above". The movement pattern inside larger pits can easily become too complicated to base logical operations on, the largest pits i worked with contain no more than three ramps. There's a lot of potential there, both for fiendishly clever devices and immense operator frustration.

Two examples for ramp oddities, out of many: The plain straight ramp can behave in unexpected ways when there's empty space above:

=▼▼╝╗
..ABC

The cart enters the pit from the west. If there is a solid ceiling above the circuit, the cart will emerge going east and take the track corner at location B. If there is empty space above the tiles A and B, the cart will jump over the first track corner and take corner C. If there is a wall in location C (e.g. in an attempt to constrain the cart's movement and force it to take the corner at B), the cart will hit the wall and stop. Unfortunately, this only happens if there is actual open space above, any buildings above the squares like hatches or floor grates will count as closed ceiling, even if the buildings are opened via lever.

The diagonal movement induced by angled track ramps can be used to throw carts through narrow wall gaps into adjacent pits:

=▼║  =▼║   ╗
=▼║  =¢║   ╝
  ▼    ¢    ║
  ▼    ▼    ║
  ║    ║

Left upper level with open, middle with closed hatches. To the right the engraved tracks on the ramps. A cart entering on the northern E-W track rolls into the northern pit of the looped pit and gains a degree of diagonal movement. If the hatch cover over the southern pit of the same ramp is open, the cart will jump through the gap onto the northern ramp of the straight pit. If the hatch cover above that pit is open, the cart swings south without leaving the pit, then back north again and out of the pit on the straight northward track. If the hatch on the straight ramp is closed, the cart first swings south and back north again, cannot leave the pit to the north because of the closed hatch and accelerates southward again and finally leaves the straight ramp towards the south. If the hatch cover above the southern ramp of the looped-ramp pit is closed, the cart does not jump through the gap into the straight pit but rather bumps against the hatch and exits the looped pit on the northern track, going back west.