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 "40d:Computing"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m (typo)
m
 
(58 intermediate revisions by 35 users not shown)
Line 1: Line 1:
Computing in dwarf fortress is the practice of setting up your fortress in such a way that allows logical operations like AND, OR, NOT, and etc to exist and be used. Computing in dwarf fortress is an EXTREMELY young concept with lots of room for improvement and development. Innovation and invention is encouraged.
+
{{Quality|Exceptional}}{{av}}
 +
Computing in dwarf fortress is the practice of setting up complex constructions to perform logical operations and calculations, ideally to control some functionality of your fortress, or such a doddle. Even if it isn't a young concept anymore, there is still lots of room for improvement and development. One reason is that there are many ways to solve one problem. Innovation and invention is encouraged.
 +
== General ==
 +
''"So, what is computing? Let's pretend to be stupid ..."'' [http://en.wikipedia.org/wiki/Die_Feuerzangenbowle Die Feuerzangenbowle]
 +
 
 +
Concepts of computing in dwarf fortress are far away from what you can call a programmable computer. Even though all necessary components are proven to exist, a construction working like a real computer may be too complex to be built in dwarf fortress. Nevertheless, early computing machines and electronic devices are comparably simple. These concepts can be easily transferred into dwarf fortress. So dwarfputing is more or less a kind of electronics, casting logic in hardware.
  
 
== Basics ==
 
== Basics ==
Binary logic takes one or two inputs and creates an output based on them. The devices that perform these operations are commonly called '''logic gates'''.
+
=== Binary information ===
 +
Binary information can have one of two possible states: true or false, respectively 1 or 0. In dwarf fortress they can be represented by different entities:
 +
* on/off state or signal of a [[trigger]]
 +
* power or connection state of a [[machine component]]
 +
* open or closed state of a [[door]] or similar buildings
 +
* [[pressure plate|low/high]] or [[flow|flowing/standing]] [[water|fluid]]
 +
* present [[creature]]s and [[dwarf|borgs]]
 +
* ...
 +
Electronic devices and computers base on this elementary form of information, and if you want to go into computing, you’ll have to familiarize with it. [http://en.wikipedia.org/wiki/Propositional_calculus propositional calculus]
 +
=== Input/Output ===
 +
Input can be any trigger - [[lever]] or [[pressure plate]]. Typically your dwarves are pulling levers, creatures are walking over your pressure plates, or fluid is covering those plates to initiate computing. The bottom line is you'll always have levers, pressure plates, or a combination of both sending binary signals: on/off.
 +
 
 +
Note: Although [[pressure plate]]s can be constructed to trigger at different fluid levels, the output will always be just a binary on/off. So everything you build will have a binary base.
  
NOT takes one input and returns true if that input is false
+
Input elements
 +
* manual: [[lever]] -> binary on/off signal
 +
* triggered: [[pressure plate]] -> binary on/off signal
  
AND takes two inputs and returns true if both inputs are true
+
According to input, output can be anything that is able to react to an on/off signal. This can be doors, bridges, floodgates allowing or stopping flow, gears controlling pumps and much more. Just refer to the [[lever#On/Off states|lever]] page for a detailed list. Independent of what you finally want to control with your dwarfputer, there are always pressure plates generating this signal. In some special configurations - when [[mechanical logic]] is involved - output may not be an on/off signal but power, thus running or not running a machine component.
  
OR takes two inputs and returns true if at least one input is true
+
Output elements
 +
* signal: [[pressure plate]] -> binary on/off signal -> linkable Object(s)
 +
* power: [[gear assembly]] -> binary power on/power off -> machine
  
XOR takes two inputs and returns true if exactly one input is true
+
=== Binary logic ===
 +
Basic binary logic takes one or two input bits and creates an output based on them. The devices that perform these operations are commonly called '''logic gates'''.
  
NAND takes two inputs and returns true if either input is false
+
* NOT - takes one input and returns the opposite of the input
  
NOR takes two inputs and returns true if both inputs are false
+
{| class="wikitable" border=1
 +
|-
 +
! input A
 +
! NOT
 +
|-
 +
| 0
 +
| 1
 +
|-
 +
| 1
 +
| 0
 +
|}
  
A B  AND OR   XOR NAND NOR
+
* AND - takes two inputs and returns true if both inputs are true
0 0  0    0    0    1    1
+
* OR - takes two inputs and returns true if at least one input is true
0 1  0    1    1    1    0
+
* XOR - takes two inputs and returns true if exactly one input is true
1 0  0    1    1    1    0
+
* NAND - takes two inputs and returns true if either input is false
1 1  1    1    0    0    0
+
* NOR - takes two inputs and returns true if both inputs are false
 +
* NXOR - takes two inputs and returns true if both inputs are identical
  
The most human-understandable logic system requires NOT, AND and OR gates, but having a design for either a NAND or a NOR gate is enough to build any of the other ports.
+
{| class="wikitable" border=1
 +
|-
 +
! input A
 +
! input B
 +
! AND
 +
! OR
 +
! XOR
 +
! NAND
 +
! NOR
 +
! NXOR
 +
|-
 +
| 0
 +
| 0
 +
| 0
 +
| 0
 +
| 0
 +
| 1
 +
| 1
 +
| 1
 +
|-
 +
| 0
 +
| 1
 +
| 0
 +
| 1
 +
| 1
 +
| 1
 +
| 0
 +
| 0
 +
|-
 +
| 1
 +
| 0
 +
| 0
 +
| 1
 +
| 1
 +
| 1
 +
| 0
 +
| 0
 +
|-
 +
| 1
 +
| 1
 +
| 1
 +
| 1
 +
| 0
 +
| 0
 +
| 0
 +
| 1
 +
|}
  
Additionally, two-dimensional logic design requires a 'jumper' gate that crosses two signals without affecting their contents. This may only be an issue in DF if you are considering magma-based circuits.
+
The most human-understandable logic system requires NOT, AND and OR gates, but having a design for either a NAND or a NOR gate is enough to build any of the other gates. Some gates are easier to create or need fewer components than others depending on what discipline your logic relies on.
 +
=== Complex gates ===
 +
* [[Latch]] - storing and reading a single binary value
 +
* [[Repeater]] - sending a repeating signal
 +
* [[Counter]]/[[Adder]] - binary calculation
 +
== Disciplines ==
 +
There are 4 main disciplines of dwarfputing, depending on what will drive the dwarfputer. Each of them has its assets and drawbacks.
 +
=== Fluid logic ===
 +
[[Fluid logic]] is controlling the ''flow of fluid'' over different pressure plates. Fluid logic can be easily constructed and every known logic gate in dwarf fortress has already been built with it. On the other hand, this discipline depends on a somehow unlimited source of the used fluid to deal with its [[evaporation]] and [[Water#Water_in_Fortress_Mode|destruction]].
 +
=== Mechanical logic ===
 +
[[Mechanical logic]] uses systems of axles and [[gear assembly|gear assemblies]] to build logical gates. Mechanical logic reacts very fast and can be easily constructed. Especially the feature of gears to toggle on every signal instead of reacting different to on/off signals makes mechanical logic gates very flexible. On the other hand, this discipline depends on much mechanical power. And because of the lack of some kind of rotation sensor, you will generally need a pump, a pressure plate and any fluid to convert power into on/off signals.
 +
=== Borg logic ===
 +
[[Borg logic]] controlling the path of your dwarves to direct them over pressure plates. They will be driven by constant hauling jobs or military designations. Pressure plates are used in similar setups to those in the fluid logic method. It is theorized that Borg logic would be quicker and easier to set up than fluid logic, although it would require a very large population dedicated to nothing but borging. The tendency of dwarves to eat, sleep, drink, makes this discipline quite unreliable. There are no known examples of borg logic, and it is purely theoretical at this time. Maybe the discovery of [[one-way]] ramps will push its development.
 +
=== Animal logic ===
 +
[[Animal logic]] is like borg logic but uses animals or captured hostiles to trigger pressure plates. Animals have a natural 'follow the leader' tendency and never starve. Hostiles will always target your dwarves and will also need no food or sleep.
 +
== Examples ==
 +
There are few examples of a really useful dwarfputer and some concepts which have the potential to become useful for others. But in most cases they are made just for fun. What doesn't mean to diminish their designers achievements, because these are in general the more complex ones. At the moment there are no known examples of animal or borg logic.
 +
=== Useful ===
 +
* Magma trap
 +
** This is an example of a useful dwarfputer controlling a magma trap. It automatically floods an area with lava, cleans up and resets afterwards. The timing is perfectly adjusted to let the victims vanish only leaving their valuable metal behind.
 +
*** video: http://mkv25.net/dfma/movie-1808-perfectmagmatrap
 +
*** design: http://i576.photobucket.com/albums/ss208/kanddak/magmatrap.png
  
== Fluid Logic ==
+
=== Concepts ===
Fluid logic utilizes the tendency of fluids in dwarf fortress to, umm, flow. It takes advantage of the ability of pressure plates in the new version to be triggered by water (or magma) resting on top of them. This allows systems of pumps, floodgates, doors, bridges, and anything else operated by pressure plate to be incorporated into a machine.
+
* repeater
<!-- could someone who's used this type of logic go into further detail with it?  what kinds of circuits can be created and how?  What are the major challenges of using fluids? -->
+
** mechanical logic http://mkv25.net/dfma/movie-1370-pump-basedautorepeater
 +
* adding machine
 +
** mechanical logic, 6-bit: http://mkv25.net/dfma/movie-1561-addingmachine
 +
** fluid logic, 8-bit: http://mkv25.net/dfma/movie-1084-numberabbeydemonstration
 +
=== Such a doddle ===
 +
* decimal display for 4-bit binary input
 +
** mechanical logic, decimal with overflow-bit: http://mkv25.net/dfma/movie-1745-dwarfputerv01
 +
** probably fluid logic: http://mkv25.net/dfma/movie-1657-7segmentlcddisplay
 +
** fluid logic, hexadecimal: http://mkv25.net/dfma/movie-1092-7-segmentdisplaydemonstration
 +
* tic tac toe
 +
** mechanical logic http://mkv25.net/dfma/movie-1813-tictactoev10simple
  
To get you started, a pressure plate set to trigger on water level 0-3 and linked to a floodgate will CLOSE the floodgate when the tile has deep water.
+
== See Also ==
If the pressure plate is set for water level 4-7, then the floodgate will OPEN when the tile has deep water.
+
* [[Animal logic]]
 +
* [[Fluid logic]]
 +
* [[Mechanical logic]]
 +
* [[Repeater]]
  
== Machine Logic ==
+
== Related user pages ==
Machine logic uses the also new system of gears, axles, windmills, and waterwheels to solve problems.  Power sources (windmills and waterwheels) transfer power to machine parts (axles and gears).  If there is not enough pwoer in a system to allow all the parts to move, it will shut down entirely.  Individual gears can also be shut down by levers to interrupt or otherwise alter the transfer of power throughout the machine.  All sorts of logic gates can be created based on those rules alone.  Currently four have been created in a proof-of-concept sort of way in a relatively quick and cheap manner:
+
[[User:BaronW]] - A Full calculator
  
[[Image:Logic.gif]]
+
[[User:SL/Logic Gates]] - These use mechanisms for connecting gates and devices and so forth, but fluid for logic. They're built on top of a body of water, and require power (for a pump or two per gate).
In the above picture, the four basic logic operations are shown. Gears connected to outside power are circled in red.  Gears that can be deactivated by lever are color-coded to the lever that deactivates them.  For the purposes of binary logic, a lever is '''TRUE''' if it is pointing '''LEFT'''.  Levers pointing '''RIGHT''' are '''FALSE'''.
 
  
In AND, two adjacent gears are connected to levers. Power is only transferred to the one-tile output axle if both levers are set to true.
+
[[User:Kyace/Adder]] - A full adder built using fluid logic, with a video of a rough prototype. Trivial to combine 8 of these to make a fluid device capable of adding two 8 bit numbers together.
  
In OR, two power sources are connected to an output gear and axleIf either lever is set to true, the axle will be connected to power and also be true.
+
[[User:Soundandfury#Logic_Gates]] - These have a water supply reservoir above and a drain belowThe drained water can be pumped back to the supply reservoir.
  
In XOR, 40 units of power are transferred to a central gear. To power the output axle, it must be connected to it by switching one of the levers to true.  However, if both levers are set to true, then the machine requires 42 units of power to run, and thus shuts down due to lack of power.
+
[[User:Bidok]] - Animal logic with all gates, memory, repeater and counter. All powered by kittens.
  
in NOT, there is a powered gear connected directly to the output axle.  If the lever is set to true, the powered gear connects to 3 other unpowered gears, which causes the machine to shut down due to lack of power.
+
[[User:LordOOTFD#Animal_Logic]] - Animal logic with fast complex gates, building upon Bidok's kitten powered systems.
  
== Borg Logic ==
+
[[User:Hussell#Assorted_Devices]] - Fluid logic
Borg logic is the experimental version of fluid logic.  It consists of creating a way for your dwarves to travel constantly in a predictable way through your fortress through constant hauling jobs or military designations.  Pressure plates are used in similar setups to those in the fluid logic method.  It is theorized that Borg logic would be quicker and easier to set up than fluid logic, although it would require a very large population dedicated to nothing but borging.  The consequences of dwarves quitting to eat, sleep, drink, etc are unknown.  There are no known examples of borg logic, and it is purely theoretical at this time.  <-- Could someone with more free time than me give this a shot?  Just some proof-of-concept gates and a picture should be enough. -->
 
  
== Animal Logic ==
+
[[User:Gammon]] - Fluid logic. Very detailed CMOS gates.
Animals have a natural 'follow the leader' tendency and never starve. Pitting an animal into a maze with movable exits can force the animal to shuttle around and computate.
 
 
[[Category:Guides]]
 
[[Category:Guides]]
 +
{{Category|Computing}}

Latest revision as of 23:30, 21 June 2024

This article is about an older version of DF.

Computing in dwarf fortress is the practice of setting up complex constructions to perform logical operations and calculations, ideally to control some functionality of your fortress, or such a doddle. Even if it isn't a young concept anymore, there is still lots of room for improvement and development. One reason is that there are many ways to solve one problem. Innovation and invention is encouraged.

General[edit]

"So, what is computing? Let's pretend to be stupid ..." Die Feuerzangenbowle

Concepts of computing in dwarf fortress are far away from what you can call a programmable computer. Even though all necessary components are proven to exist, a construction working like a real computer may be too complex to be built in dwarf fortress. Nevertheless, early computing machines and electronic devices are comparably simple. These concepts can be easily transferred into dwarf fortress. So dwarfputing is more or less a kind of electronics, casting logic in hardware.

Basics[edit]

Binary information[edit]

Binary information can have one of two possible states: true or false, respectively 1 or 0. In dwarf fortress they can be represented by different entities:

Electronic devices and computers base on this elementary form of information, and if you want to go into computing, you’ll have to familiarize with it. propositional calculus

Input/Output[edit]

Input can be any trigger - lever or pressure plate. Typically your dwarves are pulling levers, creatures are walking over your pressure plates, or fluid is covering those plates to initiate computing. The bottom line is you'll always have levers, pressure plates, or a combination of both sending binary signals: on/off.

Note: Although pressure plates can be constructed to trigger at different fluid levels, the output will always be just a binary on/off. So everything you build will have a binary base.

Input elements

According to input, output can be anything that is able to react to an on/off signal. This can be doors, bridges, floodgates allowing or stopping flow, gears controlling pumps and much more. Just refer to the lever page for a detailed list. Independent of what you finally want to control with your dwarfputer, there are always pressure plates generating this signal. In some special configurations - when mechanical logic is involved - output may not be an on/off signal but power, thus running or not running a machine component.

Output elements

Binary logic[edit]

Basic binary logic takes one or two input bits and creates an output based on them. The devices that perform these operations are commonly called logic gates.

  • NOT - takes one input and returns the opposite of the input
input A NOT
0 1
1 0
  • AND - takes two inputs and returns true if both inputs are true
  • OR - takes two inputs and returns true if at least one input is true
  • XOR - takes two inputs and returns true if exactly one input is true
  • NAND - takes two inputs and returns true if either input is false
  • NOR - takes two inputs and returns true if both inputs are false
  • NXOR - takes two inputs and returns true if both inputs are identical
input A input B AND OR XOR NAND NOR NXOR
0 0 0 0 0 1 1 1
0 1 0 1 1 1 0 0
1 0 0 1 1 1 0 0
1 1 1 1 0 0 0 1

The most human-understandable logic system requires NOT, AND and OR gates, but having a design for either a NAND or a NOR gate is enough to build any of the other gates. Some gates are easier to create or need fewer components than others depending on what discipline your logic relies on.

Complex gates[edit]

Disciplines[edit]

There are 4 main disciplines of dwarfputing, depending on what will drive the dwarfputer. Each of them has its assets and drawbacks.

Fluid logic[edit]

Fluid logic is controlling the flow of fluid over different pressure plates. Fluid logic can be easily constructed and every known logic gate in dwarf fortress has already been built with it. On the other hand, this discipline depends on a somehow unlimited source of the used fluid to deal with its evaporation and destruction.

Mechanical logic[edit]

Mechanical logic uses systems of axles and gear assemblies to build logical gates. Mechanical logic reacts very fast and can be easily constructed. Especially the feature of gears to toggle on every signal instead of reacting different to on/off signals makes mechanical logic gates very flexible. On the other hand, this discipline depends on much mechanical power. And because of the lack of some kind of rotation sensor, you will generally need a pump, a pressure plate and any fluid to convert power into on/off signals.

Borg logic[edit]

Borg logic controlling the path of your dwarves to direct them over pressure plates. They will be driven by constant hauling jobs or military designations. Pressure plates are used in similar setups to those in the fluid logic method. It is theorized that Borg logic would be quicker and easier to set up than fluid logic, although it would require a very large population dedicated to nothing but borging. The tendency of dwarves to eat, sleep, drink, makes this discipline quite unreliable. There are no known examples of borg logic, and it is purely theoretical at this time. Maybe the discovery of one-way ramps will push its development.

Animal logic[edit]

Animal logic is like borg logic but uses animals or captured hostiles to trigger pressure plates. Animals have a natural 'follow the leader' tendency and never starve. Hostiles will always target your dwarves and will also need no food or sleep.

Examples[edit]

There are few examples of a really useful dwarfputer and some concepts which have the potential to become useful for others. But in most cases they are made just for fun. What doesn't mean to diminish their designers achievements, because these are in general the more complex ones. At the moment there are no known examples of animal or borg logic.

Useful[edit]

Concepts[edit]

Such a doddle[edit]

See Also[edit]

Related user pages[edit]

User:BaronW - A Full calculator

User:SL/Logic Gates - These use mechanisms for connecting gates and devices and so forth, but fluid for logic. They're built on top of a body of water, and require power (for a pump or two per gate).

User:Kyace/Adder - A full adder built using fluid logic, with a video of a rough prototype. Trivial to combine 8 of these to make a fluid device capable of adding two 8 bit numbers together.

User:Soundandfury#Logic_Gates - These have a water supply reservoir above and a drain below. The drained water can be pumped back to the supply reservoir.

User:Bidok - Animal logic with all gates, memory, repeater and counter. All powered by kittens.

User:LordOOTFD#Animal_Logic - Animal logic with fast complex gates, building upon Bidok's kitten powered systems.

User:Hussell#Assorted_Devices - Fluid logic

User:Gammon - Fluid logic. Very detailed CMOS gates.