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.31:Fluid logic"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m
m
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{av}}
+
{{quality|Exceptional|19:04, 16 April 2011 (UTC)}}{{av}}
{{Quality|Tattered}}
+
Fluid logic is a form of [[computing]] which uses a fluid (generally [[water]]) controlled by various means, to trigger [[pressure plate]]s and hopefully accomplish some desirable result.
 +
 
 +
==Infinite Flow Gates==
 +
<!--[[Talk:Fluid_logic#Image_improvement]]-->
 +
These logic gates are relatively simple and cheap to make, but require an infinite amount of water and infinite drainage to operate. You can build a circuit system to prevent the loss of water, but closing constructions like floodgates will always destroy water, so you'll always have to replace it somehow. The following examples use raising bridges and floodgates, as they have the same delay of 100 steps when reacting to on/off signals. The bridges work as inverted input as they block passage when receiving an on signal while floodgates open in that case. The channel in the gates stands for the drainage.
 +
 
 +
There are two versions of these gates here.<br clear="all"/>
 +
 
 +
<div style="position:relative; float:none;">
 +
'''AND'''
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; border-style:solid; border-width:thin; border-color:#000000;"
 +
|
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; padding:0; margin:0; vertical-align:middle;"
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#A00|X|#444}}
 +
|{{RTL|#0A0|X|#444}}
 +
|{{RTL|#00A|^|#DDD}}
 +
|{{RTL|#222|·|#BBB}}
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|}
 +
|}
 +
</div>
 +
An AND gate is simply created by putting two floodgates ''in a row'', each one connected to one of the input triggers: {{Raw Tile|X|#A00|#444}}{{Raw Tile|X|#0A0|#444}}. When both floodgates recieve an on signal, they will open and let the water from the left side pass. The pressure plate behind the floodgates has to be constructed to react on 4-7 water.
 +
* If you use two 1x1 raising bridges, you'll get a NOR opeation instead.
 +
* The output can also be inverted by using a 0-3 pressure plate.
 +
* You can add more floodgates to process more than two signals in the conjunction.
 +
* You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time.
 +
* You can use a single floodgate and a 0-3 pressure plate to get a NOT gate.
 +
* You can use a single 1x1 raising bridges and a 4-7 pressure plate to get a NOT gate, too.
 +
 
 +
<div style="position:relative; float:none;">
 +
'''OR'''
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; border-style:solid; border-width:thin; border-color:#000000;"
 +
|
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; padding:0; margin:0; vertical-align:middle;"
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#A00|X|#444}}
 +
|{{RTL|#DDD}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#222}}
 +
|{{RTL|#00A|^|#DDD}}
 +
|{{RTL|#222|·|#BBB}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#0A0|X|#444}}
 +
|{{RTL|#DDD}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|}
 +
|}
 +
</div>
 +
An OR gate is simply created by putting two floodgates ''parallel'', each one connected to one of the input triggers: {{Raw Tile|X|#A00|#444}}{{Raw Tile|X|#0A0|#444}}. When one of the floodgates recieves an on signal, it will open and let the water from the left side pass. The pressure plate behind the floodgates has to be constructed to react on 4-7 water.
 +
* If you use two 1x1 raising bridges, you'll get a NAND opeation instead.
 +
* The output can also be inverted by using a 0-3 pressure plate.
 +
* You can add more floodgates to process more than two signals in the conjunction.
 +
* You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time.
 +
 
 +
<div style="position:relative; float:none;">
 +
'''XOR'''
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; border-style:solid; border-width:thin; border-color:#000000;"
 +
|
 +
{| cellpadding="0" cellspacing="0" style="border-spacing:0; padding:0; margin:0; vertical-align:middle;"
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#A00|X|#444}}
 +
|{{RTL|#0A0|╬|#444}}
 +
|{{RTL|#DDD}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#00A|^|#DDD}}
 +
|{{RTL|#222|·|#BBB}}
 +
|-
 +
|{{RTL|#00A|≈|#DDD}}
 +
|{{RTL|#A00|╬|#444}}
 +
|{{RTL|#0A0|X|#444}}
 +
|{{RTL|#DDD}}
 +
|{{RTL|#222}}
 +
|-
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|{{RTL|#222}}
 +
|}
 +
|}
 +
</div>
 +
A XOR gate is created by putting 1x1 raising bridges and floodgates together. The red Bridge and floodgate {{Raw Tile|X|#A00|#444}}{{Raw Tile|╬|#A00|#444}} are linked to the same input and the green bridge and floodgate {{Raw Tile|X|#0A0|#444}}{{Raw Tile|╬|#0A0|#444}} are both linked to the other input. When one of the inputs sends an on signal, the bridge will raise/close and the appropriate door will be opened. Only when the floodgate and the bridge at one passage are open, what happenes when exactly one input singal is on, the water will flow to the right. The pressure plate behind the bridges has to be constructed to react on 4-7 water.
 +
* If you exchange bridge and floodgate for one of the two inputs, you'll get a XNOR opeation instead.
 +
* The output can also be inverted by using a 0-3 pressure plate.
 +
* You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time
 +
* Processing more input signals is possible but requires an exponentially growing amount of bridges, floodgates and therefore mechanism. It is easier to link the output to another XOR gate.
 +
 
 +
 
 +
As mentioned, you can just add more floodgates and bridges and even pressure plates to expand your gates to process more input signals and process more complex operations at once. You can combine floodgates and bridges as you need them. Putting them in a row will connect them as AND. Everytime you add a new prarallel passage with floodgates and bridges this will work as an OR for each other passage. The XOR gate for example is nothing else than combined logic: A XOR B = (A AND NOT B) OR (NOT A AND B).
 +
But sometimes it is easier to use more but simpler gates.
 +
 
 +
==Fluid Preserving Gates==
 +
At the moment there doesn't exist a full concept of fluid preserving Fluid Logic Gates. Each concept working with floodgates or equivalent components in the gates will have to deal with the destruction of the fluid. A way to handle this can be the usage of [[Hatch cover|hatches]]. Also evaporation is a known problem.
 +
<!--
 +
==Mechanical-Fluid Gates==
 +
These gates aren`t [[Fluid logic]]. The ''logic'' lies within the arrangement of the (mechanical) gears. You can find it here: {{subst:subl|Mechanical_logic}}. The Water is just used to convert the power into a trigger signal. (A general concept you need for {{subst:subl|Mechanical_logic}})
 +
 
 +
[[File:Logic2.gif|thumb]]
 +
The water sources in these diagrams are located 1 z-level below the pumps and gear assemblies.
 +
 
 +
These gate designs have the advantage of destroying no water and requiring no drainage off the map, making them suitable for maps where infinite water and/or drainage may be a problem.  The only fluid lost will be to evaporation.  However, there are a number of disadvantages.  They require significantly more materials and time to make, they require {{subst:subl|power}}, and a {{subst:subl|flood}} could have disasterous consequences, as it would cover all the plates at once.
 +
 
 +
For the XOR-Gate it is assumed that the gear is powered by a windmill on a map with strong wind (40 power). If both gears are active the XOR-Gate would need more than 40 power and will stop working. If you use a different source of power - a waterwheel with axles or combined windmills 20 power each - you´ll have to add or remove some gears or axles to calibrate it.<br clear="all"/>
 +
-->
 +
==CMOS Transmission Gate and Inverter Logic==
 +
<!--[[File:Inverter.gif|thumb]]-->
 +
Perhaps the closest to utilizing water as a stand-in for electricity, transmission gate logic can be accomplished by simply having an infinite water source in place of all +Vs, and infinite drainage for all grounds.  Simple floodgates behave as standard transmission gates, while bridges are inverted gates.  However, unlike the other forms of fluid logic, but like a real world electrical circuit, a dedicated inverter is required, which must be hooked up to +V and ground.
 +
 
 +
==Advanced CMOS Gates==
 +
This type of logic uses the same concept as real CMOS circuits do, which causes them to minimalize power (in this case, water) consumption. The idea is that water should only flow when there is a state change.
 +
 
 +
===Basic Design===
 +
Let's say we want to evaluate the logical expression ''f''. It can be a simple '''and''' or '''or''' gate, or anything more complicated. Follow the following scheme:
 +
 
 +
{| style="border-spacing: 0"
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|-
 +
|{{RTF|╗}}
 +
|{{RTF|A}}
 +
|{{RTF|╔}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT0|^|#808}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|B}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|}
 +
 
 +
Here, {{Tile|A|#FFF|#000}} is a set of floodgates and/or drawbridges that let water flow exactly when ''f'' evaluates to true, {{Tile|B|#FFF|#000}} is the same except that it lets water flow when ''f'' evaluates to false, {{Tile|^|#808|#000}} is a pressure plate set to activate on water levels 4-7, and {{Tile|#|#FFF|#000}} is the drain.
 +
 
 +
===Examples===
 +
In the following examples, {{Tile|X|#000|#888}} is a floodgate, and {{Tile|╬|#FFF|#000}} is a drawbridge. Red ones are connected to input A, green ones to input B and blue ones to input C.
 +
 
 +
====NOT====
 +
{| style="border-spacing: 0"
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|-
 +
|{{RTF|╗}}
 +
|{{RT|╬|#F00|#000}}
 +
|{{RTF|╔}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT0|^|#808}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|}
 +
 
 +
====AND====
 +
{| style="border-spacing: 0"
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|-
 +
|{{RTF|╗}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{RTF|╔}}
 +
|{{RTF|═}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|X|#FFF|#080}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT0|^|#808}}
 +
|{{RTF|╚}}
 +
|{{RTF|╗}}
 +
|-
 +
|{{RTF|║}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#F00|#000}}
 +
|{{RT|╬|#0F0|#000}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|}
 +
 
 +
====OR====
 +
{| style="border-spacing: 0"
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|-
 +
|{{RTF|╗}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{RT|X|#FFF|#080}}
 +
|{{RTF|╔}}
 +
|-
 +
|{{RTF|║}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT0|^|#808}}
 +
|{{RTF|╔}}
 +
|{{RTF|╝}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#F00|#000}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#0F0|#000}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|}
 +
 
 +
====XOR====
 +
This is not as straightforward as the previous ones. The ''true'' expression is the following: (A '''and not''' B) '''or''' ('''not''' A '''and''' B). The ''false'' expression: (A '''and''' B) '''or''' ('''not''' A '''and not''' B).
 +
 
 +
So the gates look like the following:
 +
 
 +
{| style="border-spacing: 0"
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|{{H2O}}
 +
|-
 +
|{{RTF|╗}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{RTF|║}}
 +
|{{RT|X|#FFF|#080}}
 +
|{{RTF|╔}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#0F0|#000}}
 +
|{{RTF|║}}
 +
|{{RT|╬|#F00|#000}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{000}}
 +
|{{RT0|^|#808}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#F00|#000}}
 +
|{{RTF|║}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RT|╬|#0F0|#000}}
 +
|{{RTF|║}}
 +
|{{RT|X|#FFF|#080}}
 +
|{{RTF|║}}
 +
|-
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|}
 +
 
 +
===Advantages And Disadvantages===
 +
The basic advantage of this design is that it uses much less water than infinite flow gates. A river is enough to supply even the more complex systems, maybe with an added reservoir to neutralise flow irregularities. Similarly, for the drain, it is enough to excavate a cavern where the water can evaporate.
 +
 
 +
The disadvantage is that it requires much more resources and time to construct, especially more mechanisms. And more planning, since floodgates tend to block paths when constructed.
 +
 
 +
===Faster Version===
 +
The main factors that affect the speed of these gates are the delays of floodgates and bridges, and the switch-off delay of pressure plates. These cannot be eliminated.
 +
 
 +
Another factor is the flowing speed of the water. It can be improved. First, the water should flow in from a reservoir a few z-levels higher then the gates themselves (the more the better). This way, water will flow in much faster. Next, replace the pressure plates with up stairs, and make a 2x1 room one z-level above. On one tile is a down stair, and on the other is the pressure plate. Now the water will also flow out faster, or at least the pressure plate will switch off sooner.
 +
 
 +
This increases the water consumption a bit, but it still remains relatively low.
 +
 
 +
==Edge Detector==
 +
In some situations, it is beneficial to have logic that triggers during a state ''transition'' rather than based on steady states - for example, turning a lever "on" could trigger one brief event while turning the lever "off" would trigger a different event (or possibly the same event).
 +
 
 +
{| style="border-spacing: 0"
 +
|colspan="7"| Z+0
 +
|-
 +
|{{H2O}}
 +
|{{RTF|╠}}
 +
|{{RTF|═}}
 +
|{{RTF|═}}
 +
|{{RTF|═}}
 +
|{{RTF|╗}}
 +
|{{000}}
 +
|-
 +
|{{H2O}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{000}}
 +
|{{RT|╬|#800}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|-
 +
|{{H2O}}
 +
|{{RTF|╚}}
 +
|{{RTF|═}}
 +
|{{RTF|╦}}
 +
|{{RTF|═}}
 +
|{{RTF|╣}}
 +
|{{000}}
 +
|-
 +
|{{H2O}}
 +
|{{RT|╬|#800}}
 +
|{{H2O}}
 +
|{{RT|X|#FFF|#800}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|{{000}}
 +
|-
 +
|{{H2O}}
 +
|{{RTF|╔}}
 +
|{{RTF|═}}
 +
|{{RTF|╩}}
 +
|{{RTF|═}}
 +
|{{RTF|╝}}
 +
|{{000}}
 +
|-
 +
|colspan="7"| Z=-1
 +
|-
 +
|{{000}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|╔}}
 +
|{{RTF|═}}
 +
|{{RTF|═}}
 +
|{{RTF|╗}}
 +
|-
 +
|{{000}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|{{RT|^|5:1}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|-
 +
|{{000}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|╠}}
 +
|{{RTF|═}}
 +
|{{RTF|═}}
 +
|{{RTF|╣}}
 +
|-
 +
|{{000}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|║}}
 +
|{{RT|^|5:1}}
 +
|{{RTF|#}}
 +
|{{RTF|║}}
 +
|-
 +
|{{000}}
 +
|{{000}}
 +
|{{000}}
 +
|{{RTF|╚}}
 +
|{{RTF|═}}
 +
|{{RTF|═}}
 +
|{{RTF|╝}}
 +
|}
 +
 
 +
Both pressure plates should trigger on depth 2-6. Link the bottom pressure plate to machines you wish to activate on ''positive'' transitions (e.g. stepping onto a pressure plate, or pulling a lever) and the upper pressure plate to machines you wish to activate on ''negative'' transitions (e.g. stepping off of the pressure plate, or pulling the lever again), then link the trigger itself (a lever or pressure plate) to both floodgates and both raising bridges.
 +
 
 +
Each time the input trigger is toggled, the appropriate pressure plate will activate, remain active until the water finishes flowing, then deactivate after about 100 steps.
 +
 
 +
{{Category|Constructions}}
 +
{{Category|Computing}}

Latest revision as of 03:51, 14 December 2011

This article is about an older version of DF.

Fluid logic is a form of computing which uses a fluid (generally water) controlled by various means, to trigger pressure plates and hopefully accomplish some desirable result.

Infinite Flow Gates[edit]

These logic gates are relatively simple and cheap to make, but require an infinite amount of water and infinite drainage to operate. You can build a circuit system to prevent the loss of water, but closing constructions like floodgates will always destroy water, so you'll always have to replace it somehow. The following examples use raising bridges and floodgates, as they have the same delay of 100 steps when reacting to on/off signals. The bridges work as inverted input as they block passage when receiving an on signal while floodgates open in that case. The channel in the gates stands for the drainage.

There are two versions of these gates here.

AND

X
X
^
·

An AND gate is simply created by putting two floodgates in a row, each one connected to one of the input triggers: XX. When both floodgates recieve an on signal, they will open and let the water from the left side pass. The pressure plate behind the floodgates has to be constructed to react on 4-7 water.

  • If you use two 1x1 raising bridges, you'll get a NOR opeation instead.
  • The output can also be inverted by using a 0-3 pressure plate.
  • You can add more floodgates to process more than two signals in the conjunction.
  • You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time.
  • You can use a single floodgate and a 0-3 pressure plate to get a NOT gate.
  • You can use a single 1x1 raising bridges and a 4-7 pressure plate to get a NOT gate, too.

OR

X
^
·
X

An OR gate is simply created by putting two floodgates parallel, each one connected to one of the input triggers: XX. When one of the floodgates recieves an on signal, it will open and let the water from the left side pass. The pressure plate behind the floodgates has to be constructed to react on 4-7 water.

  • If you use two 1x1 raising bridges, you'll get a NAND opeation instead.
  • The output can also be inverted by using a 0-3 pressure plate.
  • You can add more floodgates to process more than two signals in the conjunction.
  • You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time.

XOR

X
^
·
X

A XOR gate is created by putting 1x1 raising bridges and floodgates together. The red Bridge and floodgate X are linked to the same input and the green bridge and floodgate X are both linked to the other input. When one of the inputs sends an on signal, the bridge will raise/close and the appropriate door will be opened. Only when the floodgate and the bridge at one passage are open, what happenes when exactly one input singal is on, the water will flow to the right. The pressure plate behind the bridges has to be constructed to react on 4-7 water.

  • If you exchange bridge and floodgate for one of the two inputs, you'll get a XNOR opeation instead.
  • The output can also be inverted by using a 0-3 pressure plate.
  • You can use a 0-3 and a 4-7 pressure plate at the same time to get the result and it's inversion at the same time
  • Processing more input signals is possible but requires an exponentially growing amount of bridges, floodgates and therefore mechanism. It is easier to link the output to another XOR gate.


As mentioned, you can just add more floodgates and bridges and even pressure plates to expand your gates to process more input signals and process more complex operations at once. You can combine floodgates and bridges as you need them. Putting them in a row will connect them as AND. Everytime you add a new prarallel passage with floodgates and bridges this will work as an OR for each other passage. The XOR gate for example is nothing else than combined logic: A XOR B = (A AND NOT B) OR (NOT A AND B). But sometimes it is easier to use more but simpler gates.

Fluid Preserving Gates[edit]

At the moment there doesn't exist a full concept of fluid preserving Fluid Logic Gates. Each concept working with floodgates or equivalent components in the gates will have to deal with the destruction of the fluid. A way to handle this can be the usage of hatches. Also evaporation is a known problem.

CMOS Transmission Gate and Inverter Logic[edit]

Perhaps the closest to utilizing water as a stand-in for electricity, transmission gate logic can be accomplished by simply having an infinite water source in place of all +Vs, and infinite drainage for all grounds. Simple floodgates behave as standard transmission gates, while bridges are inverted gates. However, unlike the other forms of fluid logic, but like a real world electrical circuit, a dedicated inverter is required, which must be hooked up to +V and ground.

Advanced CMOS Gates[edit]

This type of logic uses the same concept as real CMOS circuits do, which causes them to minimalize power (in this case, water) consumption. The idea is that water should only flow when there is a state change.

Basic Design[edit]

Let's say we want to evaluate the logical expression f. It can be a simple and or or gate, or anything more complicated. Follow the following scheme:

A
^
B
#

Here, A is a set of floodgates and/or drawbridges that let water flow exactly when f evaluates to true, B is the same except that it lets water flow when f evaluates to false, ^ is a pressure plate set to activate on water levels 4-7, and # is the drain.

Examples[edit]

In the following examples, X is a floodgate, and is a drawbridge. Red ones are connected to input A, green ones to input B and blue ones to input C.

NOT[edit]

^
X
#

AND[edit]

X
X
^
# #

OR[edit]

X X
^
#

XOR[edit]

This is not as straightforward as the previous ones. The true expression is the following: (A and not B) or (not A and B). The false expression: (A and B) or (not A and not B).

So the gates look like the following:

X X
^
X
X
# #

Advantages And Disadvantages[edit]

The basic advantage of this design is that it uses much less water than infinite flow gates. A river is enough to supply even the more complex systems, maybe with an added reservoir to neutralise flow irregularities. Similarly, for the drain, it is enough to excavate a cavern where the water can evaporate.

The disadvantage is that it requires much more resources and time to construct, especially more mechanisms. And more planning, since floodgates tend to block paths when constructed.

Faster Version[edit]

The main factors that affect the speed of these gates are the delays of floodgates and bridges, and the switch-off delay of pressure plates. These cannot be eliminated.

Another factor is the flowing speed of the water. It can be improved. First, the water should flow in from a reservoir a few z-levels higher then the gates themselves (the more the better). This way, water will flow in much faster. Next, replace the pressure plates with up stairs, and make a 2x1 room one z-level above. On one tile is a down stair, and on the other is the pressure plate. Now the water will also flow out faster, or at least the pressure plate will switch off sooner.

This increases the water consumption a bit, but it still remains relatively low.

Edge Detector[edit]

In some situations, it is beneficial to have logic that triggers during a state transition rather than based on steady states - for example, turning a lever "on" could trigger one brief event while turning the lever "off" would trigger a different event (or possibly the same event).

Z+0
X
X
Z=-1
^ #
^ #

Both pressure plates should trigger on depth 2-6. Link the bottom pressure plate to machines you wish to activate on positive transitions (e.g. stepping onto a pressure plate, or pulling a lever) and the upper pressure plate to machines you wish to activate on negative transitions (e.g. stepping off of the pressure plate, or pulling the lever again), then link the trigger itself (a lever or pressure plate) to both floodgates and both raising bridges.

Each time the input trigger is toggled, the appropriate pressure plate will activate, remain active until the water finishes flowing, then deactivate after about 100 steps.