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.

Difference between revisions of "v0.34:Minecart logic"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
(Advertising my own stuff.)
(Removed many examples, added diagrams and key; WIP)
Line 5: Line 5:
 
The addition of [[minecart]]s to Dwarf Fortress has opened up new and exciting logic and computing options for the ambitious fortress manager. Minecart-based logic gates and memory cells are easy to build (arguably easier than [[fluid logic]] systems), they are easy to reconfigure, and react quickly.
 
The addition of [[minecart]]s to Dwarf Fortress has opened up new and exciting logic and computing options for the ambitious fortress manager. Minecart-based logic gates and memory cells are easy to build (arguably easier than [[fluid logic]] systems), they are easy to reconfigure, and react quickly.
  
== Binary Memory Cells ==
+
==Techniques and Circuits==
Binary Memory Cells store binary data as a 1 or 0 (on or off). For minecarts this means a minecart occupies a pressure plate to create a 1 and by some means removed to make a 0.
 
  
 +
There exist a great number of different techniques by which a minecart can receive input, compute, and deliver output.  This article does not aim for a comprehensive list of techniques and circuits; the interested reader is encouraged to investigate further.  The following examples were chosen to demonstrate both a variety of techniques and a few commonly used gates.
  
=== Load adjusted memory cell ===
+
====Key====
 +
Adequately diagramming minecart logic devices can be difficult; each tile on each z-level might need to display up to four slices (track, ramp, furniture, minecart) that can lay on top of each other.  Ramps are displayed on the furniture layer for the sake of simplicity, and some slices may be omitted when unnecessary.  Components of each lower slice are displayed on the higher slice when unchanged by new components to give the reader a sense of placement.  Wall {{Raw Tile|O|#FFF|#000}} is typically displayed only where it is essential to the operation of the circuit.  Unengraved floor {{Raw Tile|;|#FFF|#000}} is sometimes needed for other components, but of course can be smoothed as desired.  Track direction is laid out with {{Raw Tile|║|#FFF|#000}}{{Raw Tile|═|#FFF|#000}}{{Raw Tile|╗|#FFF|#000}}{{Raw Tile|╝|#FFF|#000}}{{Raw Tile|╚|#FFF|#000}}{{Raw Tile|╔|#FFF|#000}} and ends in a tile with {{Raw Tile|╨|#FFF|#000}}{{Raw Tile|╥|#FFF|#000}}{{Raw Tile|╡|#FFF|#000}}{{Raw Tile|╞|#FFF|#000}}.  Minecarts {{Raw Tile|■|#FFF|#000}}are accelerated by rollers to the east {{Raw Tile|╟|#FFF|#000}} west {{Raw Tile|╢|#FFF|#000}} north {{Raw Tile|╧|#FFF|#000}} or south {{Raw Tile|╤|#FFF|#000}} and decelerated by track stops {{Raw Tile|≡|#FFF|#000}}.  Rollers are controlled via gear assemblies, either engaged {{Raw Tile|☼|#FFF|#000}} or disengaged {{Raw Tile|☼|#777|#000}}, typically connected to sufficient power {{Raw Tile|P|#0F0|#000}}.  Pressure plates {{Raw Tile|^|#FFF|#000}} provide output and, in some cases, modulate the circuit itself; in such cases, they are typically colored to make it clear to which components they are linked.  Up {{Raw Tile|▲|#FFF|#000}} and down {{Raw Tile|▼|#FFF|#000}} ramps may be necessary to travel z-levels or alter minecart velocity.  Doors {{Raw Tile|┼|#FFF|#000}} and hatches {{Raw Tile|¢|#FFF|#000}} are commonly used to control the path of minecarts.
  
[[File:3tdcbm.png]]
+
===Power to signal===
 +
{{diagram|spaces=yes|\
 +
  O      O
 +
  ╥;      ╤☼
 +
  ║      [#F0F]^[#0F0]P
 +
  ╨;      ╧☼
 +
  O      O
 +
track furniture}}
  
The image is split into three versions to show where the minecarts go, what's beneath the minecarts and what's beneath the rollers and pressure plates.
 
  
The load adjusted memory cell utilizes a pressure plates' load adjusting feature to only trigger at certain weights. In this example the pressure plate is set to trigger at a weight of 350. The iron minecart occupying the plate weighs less then that so it doesn't trigger while the copper cart (being the heavier of the two at 357) would trigger it. Sending power to the northern roller (which pushes south) will push the copper cart into the iron cart, sending it to the southern roller (which pushes north but is currently inactive) before being pushed itself onto the pressure plate, triggering it. The reverse is done to turn the memory cell off.
+
In this simplest of all designs, the output plate sends an '''on''' signal when the gear assemblies {{Raw Tile|☼|#FFF|#000}} are powered {{Raw Tile|P|#0F0|#000}}. When power is lost, the minecart settles onto either the northern or southern roller spaces, and the output plate sends an '''off''' signal.
 +
 +
This device is very general purpose.  Left as an exercise for the reader, alternate construction can result in a [[repeater]] or edge detection.
  
This design is the most space-efficient of the memory cells but lacks the activation speed of the next design due to the first cart having to push the second cart before being allowed to trigger the pressure plate.
+
===Newton's Cradle Memory===
 +
{{diagram|spaces=yes|\
 +
  O      O        O
 +
  ╥;      ╤[#0C0]☼[#0F0]P      ╤[#0C0]☼[#0F0]P
 +
  ║      ║        [#0F0]■
 +
  ║      [#F0F]^        [#F0F]^
 +
  ╨;      ╧[#0CC]☼[#0F0]P      [#0FF]■[#0CC]☼[#0F0]P
 +
  O      O        O
 +
track furniture minecart}}
  
A modular example of this design, accounting for extra gears to allow complex logic gates:
 
  
[[File:Modular3tdcbm.png]]
+
TinyPirate's Newton's Cradle [[Memory (Computing)|memory]] cell is notable both for it's tiny footprint and for demonstrating an important principle of minecarts. When the southern gear assembly {{Raw Tile|☼|#0CC|#000}} is briefly engaged, the southern roller {{Raw Tile|╧|#FFF|#000}} becomes powered, launching the southern minecart {{Raw Tile|■|#0FF|#000}} onto the output plate {{Raw Tile|^|#F0F|#000}}. But rather than continuing past the output plate, the southern minecart collides with the northern minecart {{Raw Tile|■|#0F0|#000}}, sending it onto the northern (unpowered) roller. When the northern gear assembly is briefly engaged, the situation reverses: the northern minecart knocks the southern minecart off of the output plate.
 
 
Compared to the [http://dwarffortresswiki.org/index.php/DF2012:Latch#Mechanical_Logic fluid-mechanical hybrid memory cell] it's nearly 3x smaller and functions just the same without the hassle of getting water to where you need it.
 
 
 
=== Newton's cradle memory cell ===
 
 
 
[[File:Tpmch.png]]
 
 
 
This design has the advantage of activating the pressure plate almost immediately upon power being sent, on par with the [http://dwarffortresswiki.org/index.php/DF2012:Latch#Mechanical_Logic fluid-mechanical hybrid] equivalent. Power is sent to the light green gear, pushing the top cart into the second cart. Like a Newton Cradle,  the first cart transfers its momentum to the second cart, knocking it to the other end while the first cart rests on the pressure plate to send an on signal. The gear is then turned off. To turn it off power is sent to the dark green and the reverse happens. The modular design of the load adjusted memory cell can be applied to this as well to save space.
 
 
 
== Power-to-Signal Converters ==
 
 
 
A power-to-signal converter sends an on signal when power is applied and an off signal when power is cut.
 
 
 
=== 2x2 power-to-signal converter ===
 
 
 
[[File:2x2pts.png]]
 
 
 
When power is sent to the gear, the roller sends the cart around in a loop, passing over the pressure plate repeatedly to maintain on on signal. When power is cut the cart returns to the starting position and disengages the pressure plate. The roller in this example pushes the cart from E->W. Pay close attention to the track layout to make sure it works properly. The 2 walls at the top are all that's needed to keep it from derailing.
 
 
 
A modular layout:
 
 
 
[[File:Modular2x2pts.png]]
 
 
 
=== Single-carted power-to-signal converter ===
 
 
 
[[File:Scpts.png]]
 
 
 
The rollers are directed towards the center, so when power is applied to any of the gears the minecart continuously passes over the pressure plate to maintain an on signal, reverting to an off signal when the power is cut.
 
 
 
A modular layout:
 
 
 
[[File:Modularscpts.png]]
 
 
 
More gears than necessary were added to the example above to show how complex you can make the logic gates while maintaining a compact layout.
 
 
 
=== Ramp-based power-to-signal converter ===
 
 
 
[[file:Pscdesign.png]]
 
 
 
Arguably the most efficient design, a PSC that relies on a ramp to return the cart to the start position cuts out the need for a second set of rollers and the power and resource requirements therein.
 
 
 
The roller pushes the cart around the loop, over the pressure plate and on to the ramp, whereupon the minecart rolls back down and on to the rollers again. Rinse and repeat. When the rollers are deactivated the minecart rolls back on to them, allowing the pressure plate to reset. This design does not rely on the floor above being accessible to the minecart (no need to channel anything), the track ramp can be built with floor directly above it.
 
 
 
Obviously, this design could be set to be straight, or curved (as this one is). Straight-line ramp-based PSCs are probably easier to pack together in large numbers if required.
 
 
 
== Other Examples ==
 
 
 
Other components useful for computing in DF
 
 
 
=== Modified load adjusted memory cell ===
 
 
 
[[File:Dcpts.png]]
 
 
 
Perhaps a power-to-signal converter, but perhaps not. I'll put it under other since i'm unsure.
 
 
 
This functions much like the memory cell, but with different linkages (and an axle). Both gears are off by default and power is connected to the dark green gear. Be it by lever or pressure plate, both gears are switched, sending power to both rollers (directed to the center). The copper cart pushes the iron one to the other side, but before the southern roller has time to push it back north the copper cart is rolled onto the pressure plate which is linked to the dark green gear, turning it (and the souther roller) off instantly. The light green gear is still engaged but no power is being sent to it.
 
 
 
Both gears are switched again when you want to turn it off, activating the dark green gear and disengaging the light green, sending both carts back to their starting points, deactivating the pressure plate which turns the dark green off again (but keeps the roller on long enough to push the iron cart thanks to the pressure plates 'off' delay).
 
 
 
With the other examples of power-to-signal converters, only 1 gear is needed to be switched to turn them on and off. If you treat both of these gears as you would a single gear then I guess you could also call it a power-to-signal converter, and would be the only one that has no moving water or minecarts when it's in the on position. Useful if you have a whole bunch of them and want to minimize lag.
 
  
 
== Potential as an independent logic discipline ==
 
== Potential as an independent logic discipline ==

Revision as of 20:53, 21 February 2014

This article is about an older version of DF.

The addition of minecarts to Dwarf Fortress has opened up new and exciting logic and computing options for the ambitious fortress manager. Minecart-based logic gates and memory cells are easy to build (arguably easier than fluid logic systems), they are easy to reconfigure, and react quickly.

Techniques and Circuits

There exist a great number of different techniques by which a minecart can receive input, compute, and deliver output. This article does not aim for a comprehensive list of techniques and circuits; the interested reader is encouraged to investigate further. The following examples were chosen to demonstrate both a variety of techniques and a few commonly used gates.

Key

Adequately diagramming minecart logic devices can be difficult; each tile on each z-level might need to display up to four slices (track, ramp, furniture, minecart) that can lay on top of each other. Ramps are displayed on the furniture layer for the sake of simplicity, and some slices may be omitted when unnecessary. Components of each lower slice are displayed on the higher slice when unchanged by new components to give the reader a sense of placement. Wall O is typically displayed only where it is essential to the operation of the circuit. Unengraved floor ; is sometimes needed for other components, but of course can be smoothed as desired. Track direction is laid out with and ends in a tile with . Minecarts are accelerated by rollers to the east west north or south and decelerated by track stops . Rollers are controlled via gear assemblies, either engaged or disengaged , typically connected to sufficient power P. Pressure plates ^ provide output and, in some cases, modulate the circuit itself; in such cases, they are typically colored to make it clear to which components they are linked. Up and down ramps may be necessary to travel z-levels or alter minecart velocity. Doors and hatches ¢ are commonly used to control the path of minecarts.

Power to signal

O O
;
^ P
;
O O
t r a c k f u r n i t u r e


In this simplest of all designs, the output plate sends an on signal when the gear assemblies are powered P. When power is lost, the minecart settles onto either the northern or southern roller spaces, and the output plate sends an off signal.

This device is very general purpose. Left as an exercise for the reader, alternate construction can result in a repeater or edge detection.

Newton's Cradle Memory

O O O
; P P
^ ^
; P P
O O O
t r a c k f u r n i t u r e m i n e c a r t


TinyPirate's Newton's Cradle memory cell is notable both for it's tiny footprint and for demonstrating an important principle of minecarts. When the southern gear assembly is briefly engaged, the southern roller becomes powered, launching the southern minecart onto the output plate ^. But rather than continuing past the output plate, the southern minecart collides with the northern minecart , sending it onto the northern (unpowered) roller. When the northern gear assembly is briefly engaged, the situation reverses: the northern minecart knocks the southern minecart off of the output plate.

Potential as an independent logic discipline

Minecarts can also be set in motion by ramps and switched between different paths by buildings, opening the path for a powerless logic discipline. The basic binary logic gates can be built in this fashion and combined to perform other operations like counting or basic algebra. The circuits tend to look quite complicated, especially if they stretch over multiple levels.

Äquivalenz-Differenz.png

This kind of minecart logic is primarily an alternative to creature logic. Since minecarts move relatively quickly and completely deterministically, simple minecart logic gates can be relatively small and quick. Since a minecart only reacts to the conditions of its current tile and the tile it tries to move into, creature logic will have an advantage when looking at multiple and long logic paths, where a creature instantly detects and chooses the open path, while the minecart has to check every tile and building separately.

For signal generation, memory cells, repeaters and adders, this kind of minecart logic offers a variety of options.

See Also