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
(oops)
(roller derailer NOR->roller swtiched AND; +continuous roller OR; bridge derailer AND->resettable bridge derailer AND; +MPL NOT; +integration; cleanup as always; not quite done with it yet)
Line 30: Line 30:
 
   O      O        O
 
   O      O        O
 
   ╥,      ╤[#0C0]☼[#0F0]P      ╤[#0C0]☼[#0F0]P
 
   ╥,      ╤[#0C0]☼[#0F0]P      ╤[#0C0]☼[#0F0]P
   ║      ║        [#000][#0f0]■
+
   ║      ║       
   ║      [#F0F]^        [#F0F]^
+
   ║      [#F0F]^        [#000][#0f0]
 
   ╨,      ╧[#0CC]☼[#0F0]P      [#000][#0ff]■[#0CC]☼[#0F0]P
 
   ╨,      ╧[#0CC]☼[#0F0]P      [#000][#0ff]■[#0CC]☼[#0F0]P
 
   O      O        O
 
   O      O        O
Line 37: Line 37:
  
  
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.
+
TinyPirate's Newton's Cradle [[Memory_(computing)|memory]] cell is notable both for its small 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|■|#000|#0FF}} into the northern minecart {{Raw Tile|■|#000|#0F0}}. The northern minecart then leaves the pressure plate and settles on 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.
  
===Roller derailer NOR===
+
===Continuous roller OR===
 +
{{diagram|spaces=yes|\
 +
╔═╗═╗  ╔═╗═╗
 +
║ ║O║  ║ [#F0F]^O║
 +
║ ║O║  ╤[#0F0]☼╧O║
 +
║ ║O║  [#0F0]P╤[#0FF]☼╧O║
 +
╚═╩═╝  ╚═╧═╝
 +
track  furniture}}
 +
Veylon's roller OR continuously evaluates two operands via a minecart traveling counter-clockwise using principles of power transmission through single tile rollers.  Should either input {{Raw Tile|☼|#0F0|#000}} or {{Raw Tile|☼|#0FF|#000}} be engaged, power {{Raw Tile|P|#0F0|#000}} is transmitted to the southernmost, S->N roller {{Raw Tile|╧|#FFF|#000}}.  Although the minecart is left with diagonal velocity, walls prevent derailment.  When neither input is engaged, the minecart continues over the T-junction to the east, missing the output plate {{Raw Tile|^|#F0F|#000}}.
 +
 
 +
===Roller switched AND===
 
{{diagram|spaces=yes|\
 
{{diagram|spaces=yes|\
 
   ║      ║
 
   ║      ║
   ║╗O    [#0F0]P[#0F0]╟╗O
+
   ╔╗    [#0F0]P[#0F0]╧╗
   ║║O    ║║O
+
   ║║      ║║
   ║╗O    [#0F0]P[#0FF]╟║O
+
   ╔╗    [#0F0]P[#0FF]╧╗
   ║║O    [#F0F]^║O
+
   ║║      [#F0F]^
 
   ╚╗      ╚╗
 
   ╚╗      ╚╗
 
track  furniture}}
 
track  furniture}}
In this gate, a minecart entering from the south is diverted by W->E rollers {{Raw Tile||#0F0|#000}} and {{Raw Tile||#0FF|#000}} onto an alternate pathway whenever either is active (that is, when neither has received an '''on''' signal).  A slight redesign could easily evaluate power rather than signal; small changes would make this an OR, AND, NAND, or NOT gate.
+
Larix's roller-switched AND takes advantage of the behavior of rollers to avoid troublesome diagonal velocity, but is confusing both for the counter-intuitive direction of its rollers as well as the way that rollers respond to signals.  When the minecart encounters either activated (that is, the last signal received was an '''off''') S->N roller {{Raw Tile||#0FF|#000}} or {{Raw Tile||#0F0|#000}}, its velocity is completely rewritten and reversed, sending it onto the alternate (clockwise) path.  Should neither roller be activated (that is, the last signal received by both was an '''on'''), the track bends will be ignored and the minecart will travel directly south, over the output plate {{Raw Tile|^|#F0F|#000}}.
  
===Bridge drop/bridge derailer AND===
+
===Resetting bridge-derailment AND===
 
{{diagram|spaces=yes|\
 
{{diagram|spaces=yes|\
  ║    ║      ║
+
O[#0FF].[#0FF]. O▼═▼  O[#0FF]¢═▼
  [#0FF].   ▼      [#000][#0f0]
+
     
  ║    ║      ║
+
     
  ║    ║      ║
+
     
  [#0FF].    ▼      ▼
 
  O    O      O
 
 
track ramp furniture
 
track ramp furniture
      Z+1
+
z+1
   O    O      O
+
O╔O╗ O▲O▲   O▲O▲
   ║    ▲      ▲
+
   ╚═╚  ╚═▲   [#000][#0f0][#F0F]^
  ╚╗   ╚╗    [#000][#0ff]╬╗
+
   ╚═╝  ╚═╝   ╚═╝
O╗║  O▲║    O▲[#F0F]^
 
   ╔╝   ╔╝    ╔╝
 
 
track ramp furniture
 
track ramp furniture
      Z+0}}
+
z+0}}
  
While impractical, this AND gate demonstrates a few useful principles.  If the green retractable bridge {{Raw Tile|╬|#000|#0F0}} is closed, a minecart entering from the north travels over it, eventually dropping one z-level at the southernmost ramp before continuing southward.  If that bridge is open but the cyan retractable bridge {{Raw Tile||#000|#0FF}} is closed, the minecart drops into the northern ramp and continues straight south, since the bridge covers the trackOnly should both bridges be open will the minecart drop, then divert onto the eastern path, triggering its output plate {{Raw Tile|^|#F0F|#000}}.
+
When both the cyan hatch {{Raw Tile|¢|#0FF|#000}} and the green retractable bridge {{Raw Tile|╬|#000|#0F0}} are open, minecarts on this circuit make a continuous loop, triggering the output plate {{Raw Tile|^|#F0F|#000}}.  If either is closed, the plate is never activated.  If the bridge is closed, the minecart derails to the southern path, avoiding the plateIf the hatch is closed, the minecart is unable to drop into the northwest ramp, and so sits on the upper, northwestern tile until the hatch opens.
  
Note that using bridges in this manner can be very tricky.  When bridges change state, minecarts traveling over them are liable to be thrownBridges can still be useful in some circuits where the player is certain of the timing involved.  For instance, in this circuit, if the player knows that the green bridge and the cyan bridge will only ever change state at the same time, and the minecart travelling the circuit rests atop the green bridge rather than entering the circuit at unpredictable times, the above circuit is safe.
+
There are many concerns when using a gate like this.  Minecarts can be flung when a bridge changes state underneath them.  Additionally, because your minecart never evaluates both operands at the exact same moment, it's possible for this gate to output when neither operand is actually true at the same moment.
  
Also note that should the cyan input change very soon after the green input, there is the potential for this circuit to output when the inputs are not actually true at the same exact instant.  This problem is common in AND gates.  Should this be important to your design, it is possible to work around it, paradoxically, with another AND gate, by ANDing your inputs with a regularly pulsed [[Repeater|clock]] signalThe bridge-drop (or its superior variant, the hatch-drop), linked to a clock, can be used to create circuits where all of your inputs change state at the same time.
+
It's not always a problem, but this behavior is common to AND gates.  Paradoxically, one solution is to moderate your inputs via an extra AND gate; this design shows how that can be doneWhen a large number of circuits such as that shown are created and the hatches of all of them are linked to a single lever, a quick flick (on and off) of that lever can guarantee that all of your circuits fire at the same time-- that is, that all of your inputs for the next computation change state simultaneously.  The minecarts then return to their position atop the hatches, ready for another flick of your clock lever.
  
== Potential as an independent logic discipline ==
+
Worth noting, as well, is the central eastern impulse ramp that allows the minecart to maintain enough velocity to complete this circuit.  Impulse ramps like this can be used to make unpowered gates.  However, their behavior is unintuitive, and they should only be used with extreme caution.  For example, in the diagram above, such a device used for continuous AND evaluation (rather than the resetting AND suggested in the text) is likely to accelerate the minecart on each pass, such that the minecart will stop moving after some number of circuits.
 +
 
 +
===MPL NOT===
 +
{{diagram|spaces=yes|\
 +
 +
O,      O,
 +
track    ramp
 +
z+2
 +
  ╔═╗      ╔═╗      ╔═╗
 +
O══[#0FF].[#0FF].╝  O▲═▼▼╝  O▲[#F0F]^▼[#0F0]¢╝
 +
track    ramp  furniture
 +
z+1
 +
 +
OOO══O  OOO▲▲O
 +
track    ramp
 +
z+0
 +
}}
 +
 
 +
Larix's powerless logic gates avoid the reliability and latency issues that plague many minecart designs through the use of paired impulse ramps and hatches that control not just path, but direction of movement.  A minecart traveling the pictured circuit while the input hatch {{Raw Tile|¢|#0F0|#000}} is open will settle into a counter-clockwise path, regardless of the direction of its initial velocity.  Yet when the hatch becomes closed, the minecart cannot travel counter-clockwise, but instead is accelerated in the clockwise direction, onto the output plate {{Raw Tile|^|#F0F|#000}}.  It will then oscillate between the far east and far west ramps until the hatch is opened, at which point it will resume counter-clockwise motion.
 +
 
 +
Use of ramps with high-velocity minecarts may necessitate ceilings as demonstrated on z+2.  The exact nature of the ceiling (floor, wall) is unimportant.  Some diagrammed walls are unnecessary for the design and are drawn to help the reader in orientation.
 +
 
 +
==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.
 
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.
Line 83: Line 111:
  
 
For signal generation, memory cells, repeaters and adders, this kind of minecart logic offers a variety of options.
 
For signal generation, memory cells, repeaters and adders, this kind of minecart logic offers a variety of options.
 +
 +
==Integration with other disciplines==
 +
 +
There's no reason minecart logic needs to be used in isolation.  Integration of disciplines allows one to use each where it is strong, and avoid each where it is weak.
 +
 +
===Mechanical logic===
 +
This is the most obvious choice.  Mechanical logic offers the potential for incredible speed, yet requires integration to generate useful signals or to create delay (hence repeaters and clocks), and has trouble creating usable memory cells without integration.  Minecart logic excels at precisely these tasks.  Minecart power-to-signal cells and latches are tiny and fast.  Minecart repeaters are precisely tunable.  The superiority of minecart logic has made water obsolete for these purposes.
 +
 +
===Creature logic===
 +
Minecart logic, particularly Larix's powerless MPL logic, has replaced creature logic as the logic-of-last-resort (for when power and fluid are unavailable) or first-resort (for when computation is desired before power can be set up or fluid accessed).  However, for the borg logic hobbyist, integration with minecarts suggests interesting possibilities.  It is difficult to imagine a simpler clock or repeater than a minecart with a "push always after x days" condition, and guided minecarts offer unprecedented control over the path of dwarves.
 +
 +
===Fluid logic===
 +
Minecart logic outperforms fluid logic sufficiently to have mostly replaced it.  However, the problem of automated fluid delivery may be best solved through some fluid logic integration, and may suggest some stupid dwarf tricks for those that want to use the fluid capacity of minecarts to compute.
  
 
== See Also ==
 
== See Also ==

Revision as of 22:20, 25 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; they may be roofed or covered with empty space . in some views. Doors , hatches ¢, and retractable bridges are commonly used to control the path of minecarts. Where necessary, clarification can be found in the descriptions of each circuit.

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 its small 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 into the northern minecart . The northern minecart then leaves the pressure plate and settles on 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.

Continuous roller OR

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

Veylon's roller OR continuously evaluates two operands via a minecart traveling counter-clockwise using principles of power transmission through single tile rollers. Should either input or be engaged, power P is transmitted to the southernmost, S->N roller . Although the minecart is left with diagonal velocity, walls prevent derailment. When neither input is engaged, the minecart continues over the T-junction to the east, missing the output plate ^.

Roller switched AND

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

Larix's roller-switched AND takes advantage of the behavior of rollers to avoid troublesome diagonal velocity, but is confusing both for the counter-intuitive direction of its rollers as well as the way that rollers respond to signals. When the minecart encounters either activated (that is, the last signal received was an off) S->N roller or , its velocity is completely rewritten and reversed, sending it onto the alternate (clockwise) path. Should neither roller be activated (that is, the last signal received by both was an on), the track bends will be ignored and the minecart will travel directly south, over the output plate ^.

Resetting bridge-derailment AND

O . . O O ¢
t r a c k r a m p f u r n i t u r e
z + 1
O O O O O O
^
t r a c k r a m p f u r n i t u r e
z + 0

When both the cyan hatch ¢ and the green retractable bridge are open, minecarts on this circuit make a continuous loop, triggering the output plate ^. If either is closed, the plate is never activated. If the bridge is closed, the minecart derails to the southern path, avoiding the plate. If the hatch is closed, the minecart is unable to drop into the northwest ramp, and so sits on the upper, northwestern tile until the hatch opens.

There are many concerns when using a gate like this. Minecarts can be flung when a bridge changes state underneath them. Additionally, because your minecart never evaluates both operands at the exact same moment, it's possible for this gate to output when neither operand is actually true at the same moment.

It's not always a problem, but this behavior is common to AND gates. Paradoxically, one solution is to moderate your inputs via an extra AND gate; this design shows how that can be done. When a large number of circuits such as that shown are created and the hatches of all of them are linked to a single lever, a quick flick (on and off) of that lever can guarantee that all of your circuits fire at the same time-- that is, that all of your inputs for the next computation change state simultaneously. The minecarts then return to their position atop the hatches, ready for another flick of your clock lever.

Worth noting, as well, is the central eastern impulse ramp that allows the minecart to maintain enough velocity to complete this circuit. Impulse ramps like this can be used to make unpowered gates. However, their behavior is unintuitive, and they should only be used with extreme caution. For example, in the diagram above, such a device used for continuous AND evaluation (rather than the resetting AND suggested in the text) is likely to accelerate the minecart on each pass, such that the minecart will stop moving after some number of circuits.

MPL NOT

O , O ,
t r a c k r a m p
z + 2
O . . O O ^ ¢
t r a c k r a m p f u r n i t u r e
z + 1
O O O O O O O O
t r a c k r a m p
z + 0

Larix's powerless logic gates avoid the reliability and latency issues that plague many minecart designs through the use of paired impulse ramps and hatches that control not just path, but direction of movement. A minecart traveling the pictured circuit while the input hatch ¢ is open will settle into a counter-clockwise path, regardless of the direction of its initial velocity. Yet when the hatch becomes closed, the minecart cannot travel counter-clockwise, but instead is accelerated in the clockwise direction, onto the output plate ^. It will then oscillate between the far east and far west ramps until the hatch is opened, at which point it will resume counter-clockwise motion.

Use of ramps with high-velocity minecarts may necessitate ceilings as demonstrated on z+2. The exact nature of the ceiling (floor, wall) is unimportant. Some diagrammed walls are unnecessary for the design and are drawn to help the reader in orientation.

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.

Integration with other disciplines

There's no reason minecart logic needs to be used in isolation. Integration of disciplines allows one to use each where it is strong, and avoid each where it is weak.

Mechanical logic

This is the most obvious choice. Mechanical logic offers the potential for incredible speed, yet requires integration to generate useful signals or to create delay (hence repeaters and clocks), and has trouble creating usable memory cells without integration. Minecart logic excels at precisely these tasks. Minecart power-to-signal cells and latches are tiny and fast. Minecart repeaters are precisely tunable. The superiority of minecart logic has made water obsolete for these purposes.

Creature logic

Minecart logic, particularly Larix's powerless MPL logic, has replaced creature logic as the logic-of-last-resort (for when power and fluid are unavailable) or first-resort (for when computation is desired before power can be set up or fluid accessed). However, for the borg logic hobbyist, integration with minecarts suggests interesting possibilities. It is difficult to imagine a simpler clock or repeater than a minecart with a "push always after x days" condition, and guided minecarts offer unprecedented control over the path of dwarves.

Fluid logic

Minecart logic outperforms fluid logic sufficiently to have mostly replaced it. However, the problem of automated fluid delivery may be best solved through some fluid logic integration, and may suggest some stupid dwarf tricks for those that want to use the fluid capacity of minecarts to compute.

See Also