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:Animal logic"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{av}}{{Quality|Exceptional|07:53, 2 June 2010 (UTC)}}
 
{{av}}{{Quality|Exceptional|07:53, 2 June 2010 (UTC)}}
Animal logic functions by taking advantage of the path finding algorithm in Dwarf Fortress; all animals seek to find the shortest (lowest cost) path to their desired targets (activity zone, parents, dwarfs, valuable objects, etc), this can be used to create very very complex logic gates. Animal logic has three principal advantages: speed, compactness, and simplified functions. However, animal logic is slower than mechanical logic and less reliable than either fluid or mechanical logic.
+
Animal logic functions by taking advantage of the path finding algorithm in Dwarf Fortress; all domestic animals seek to find the shortest (lowest cost) path to their desired targets (activity zone, parents, dwarves, valuable objects, etc), this can be used to create very very complex logic gates. Animal logic has three principal advantages: speed, compactness, and simplified functions. However, animal logic is slower than mechanical logic and less reliable than either fluid or mechanical logic.
  
 
==Definitions==
 
==Definitions==
Line 12: Line 12:
 
'''Path cost''': The number of steps the animal must make to reach ground
 
'''Path cost''': The number of steps the animal must make to reach ground
  
'''Fusion Gate''': Simply one or more logic gates built into the same system (this is more than simply stringing gates)
+
'''Fusion Gate''': Simply one or more logic gates built into the same system-- this efficiently replicates the functionality of stringed gates
  
 
'''Compound Gate''': Gate which uses two or more gates set to different path costs.
 
'''Compound Gate''': Gate which uses two or more gates set to different path costs.
Line 35: Line 35:
 
For a better explanation of gates see:http://en.wikipedia.org/wiki/Logic_gate
 
For a better explanation of gates see:http://en.wikipedia.org/wiki/Logic_gate
  
Notation: #:always wall ^:pressure plate X:floodgate,grate,bars,bridge,etc(explained per entry) D:door,open, but kept tightly shut(pet impassable) d:door, input value not specified Letters:doors/floodgates,grates,bar,etc Specified inputs(these are generally interchangeable, if not this will be noted in the entry) g:Ground, some entries need it for clarity. C: Either an input in diagrams, or the state Carry is refereed to as a state within an adder.
+
Notation: #:wall ^:pressure plate X:floodgate,grate,bars,bridge,etc(explained per entry) D:door,open, but kept tightly shut(pet impassable) d:door, input value not specified Letters:doors/floodgates,grates,bar,etc Specified inputs(these are generally interchangeable, if not this will be noted in the entry), generally controlled by mechanism g:Ground, some entries need it for clarity. C: Either an input in diagrams, or the state Carry is refereed to as a state within an adder.
  
 
Gates will always be capitalized in the way they are within the entry, e.g. AND, OR, ANDOR, XNOR, etc.
 
Gates will always be capitalized in the way they are within the entry, e.g. AND, OR, ANDOR, XNOR, etc.
Line 67: Line 67:
 
===NAND===
 
===NAND===
  
Reconfigured AND gate, see {{l|Animal logic#AND|AND}}.
+
Reconfigured AND gate, see [[Animal logic#AND|AND]].
 
  #########
 
  #########
 
   ABCD ^D
 
   ABCD ^D
Line 89: Line 89:
 
  Y D^ D
 
  Y D^ D
 
  N #####
 
  N #####
 +
U #####
 
  M #####
 
  M #####
 
  #######
 
  #######
Line 95: Line 96:
 
===NOR===
 
===NOR===
  
Basically a reconfigured OR gate
+
Basically a reconfigured OR gate.
 
  #####
 
  #####
 
  AD ^D
 
  AD ^D
Line 112: Line 113:
 
==Compound Gates==
 
==Compound Gates==
  
Basically two or more gates arranged with different path costs to ground. These gates can be configured in a number of different ways, these being the simplest. It may be possible to make these gates as single gates but that would require inverting some of the input. Simple compound gates use two simple gates and handle two inputs, complex compund gates have more then two simple gates and need more than two inputs. a Complex compound gate might be used to convert decimal numbers into binary using And gates.
+
Basically two or more gates arranged with different path costs to ground. These gates can be configured in a number of different ways, these being the simplest. It may be possible to make these gates as single gates but that would require inverting some of the input. Simple compound gates use two simple gates and handle two inputs; complex compound gates have more then two simple gates and need more than two inputs. A complex compound gate might be used to convert decimal numbers into binary using And gates.
  
 
===XOR===
 
===XOR===
Line 189: Line 190:
 
===ANDOR===
 
===ANDOR===
  
This gate will evaluate if either of x AND statements are TRUE. This gate is built as a straight line similar to the And gate
+
This gate will evaluate if either of x AND statements are TRUE. This gate is built as a straight line similar to the AND gate.
 
  ######
 
  ######
 
  #C####
 
  #C####
Line 199: Line 200:
 
===NANDOR===
 
===NANDOR===
  
Reconfigured ANDOR gate, see {{l|Animal logic#ANDOR|ANDOR}}.
+
Reconfigured ANDOR gate, see [[Animal logic#ANDOR|ANDOR]].
 
  ######
 
  ######
 
  #C####
 
  #C####
Line 207: Line 208:
  
  
===OrandOr===
+
===ORANDOR===
  
This gate returns true if either A or B and either C or D is true.
+
This gate returns true if either A or B and either C or E is true.
  
 
  ######
 
  ######
Line 217: Line 218:
  
  
===OrandAnd===
+
===ORANDAND===
  
 
This gate returns true if either A or B is true, and E and C are true.
 
This gate returns true if either A or B is true, and E and C are true.
Line 225: Line 226:
 
  BCED^ D
 
  BCED^ D
 
  #######
 
  #######
 
  
  
 
==Complex Gates==
 
==Complex Gates==
  
The development of more complex gates requires carful calibration of the path cost of each path to allow the gate to switch states correctly and display the correct result.
+
The development of more complex gates requires careful calibration of the path cost of each path to allow the gate to switch states correctly and display the correct result.
  
 
==Adders==
 
==Adders==
A Full adder can be made as a Compound Fusion gate, by combining, And, AndOr, and Or gates
+
A full adder can be made as a Compound Fusion gate, by combining AND, ANDOR, and OR gates
  
  
 
===Binary Adder===
 
===Binary Adder===
  
A binary adder is constrcuted of two or three "sum" gates and a purge path. a half adder only adds two numbers and only needs two sum gates, 1 and 2. Full adders using carry to allow chaining require three sum gates, 1,2 and 3. Because binary is base two that translates to 01,10,11 as the sums, when the second bit is a 1, the gate is "carrying" the value up to the next level.
+
A binary adder is constructed of two or three "sum" gates and a purge path. A half adder only adds two numbers and only needs two sum gates, 1 and 2. Full adders using carry to allow chaining require three sum gates, 1,2 and 3. Because binary is base two that translates to 01,10,11 as the sums, when the second bit is a 1, the gate is "carrying" the value up to the next level.
 +
 
 +
When building the adder, the highest path must have the most preferential path to ground or it will not properly function.
 +
 
 +
Standalone adders (they don't carry into another adder) require 22 mechanisms, and 14 doors.
 +
Start adders (They feed into the next adder and include a carry) require 32 mechanisms, and 14 doors.
 +
Chain adders (The receive Carry, and pass a Carry bit up) require 32 mechanisms, and 14 doors
 +
The gates only take up 13x9 tiles each.
  
An building the adder the highest path must have the most preferential path to ground or it will not properly function.
+
==Hatch-based logic==
  
Standalone Adders (they don't carry into another adder) require 22 mechanisms, and 14 doors.
+
Hatches can be used in many logic designs for alternate designs. A hatch over a ramp serves as a door that cannot be wedged open; a hatch over a channel functions as a naturally inverted door, blocking pathing when open rather than when closed. Although the designs on this page all use doors to restrict path, careful use of hatches can be more effective for some circuits.
Start Adders (They feed into the next Adder and include a carry) require 32 mechanisms, and 14 doors.
 
Chain Adders (The receive Carry, and pass a Carry bit up) require 32 mechanisms, and 14 doors
 
While Materials intensive the gates only take up 13x9 urists, ideal for chaining along mining tunnels.
 
  
  
Line 283: Line 287:
  
  
===Kittens===
+
===Cats===
  
While kittens are the most reliable cores for logic gates because of their three pathing goals they're also problematic as they grow into cats which only have two, and may cause catsplosions inside your logical cores. Ideally kittens should be replaced yearly or biyearly as their growth defines.
+
Unfortunately, cats are both too small to trigger pressure plates.
Kittens path to the activity zone, their parents, and vermin.
 
  
  
 
===Puppies===
 
===Puppies===
  
Puppies are quite reliable with Two pathing goals, but retain the problem of maturation.
+
Puppies are quite reliable with two pathing goals, which is presumed to lead to faster response times than animals with only a single pathing goal, but tend to spit out babies upon maturation.
 
Puppies path to the activity zone, and their parents.
 
Puppies path to the activity zone, and their parents.
 
===Animal Children===
 
 
Using the non matured animals for something useful before butchering may be quite effective, however they still must be flushed when they mature.
 
Animal children path to the activity zone, and their parents.
 
 
 
===Cats===
 
 
Aggravating animals, throw them into the computer and get some worth out of them. Otherwise useless cats become useful when used for logic, with two pathing goals they're responsive, and multiply quickly. Watch out for catsplosions while using these critters
 
Cats path to the activity zone, and Vermin.
 
  
 
===Dogs===
 
===Dogs===
  
While dogs may seem an attractive option for logic cores, they will be far more useful as wardogs or hunting dogs to protect dorfs.  
+
While dogs may seem an attractive option for logic cores, they will be far more useful as wardogs or hunting dogs to protect dwarves.  
 
Dogs path to the activity zone.
 
Dogs path to the activity zone.
 
===Cattle===
 
 
Large lumbering bovines, the advantage of Cattle is you can tell the sexes apart, they also make the pressure plates continue to work even if you forget to reassign the trigger weight.
 
Cattle path to the activity zone.
 
  
 
===Other animals===
 
===Other animals===
  
Any animals work, but the above are probably your best choice, excluding any modded animals. however if you have a GCS handy a GCS powered computer would be awesome, so take this as you will.
+
Many animals work, but the above are probably your best choice, excluding any modded animals. However if you have a GCS handy, a GCS powered computer would be awesome, so take this as you will.
Other animals have different pathing goals, but most only path to the activity zone.
+
Other animals have different pathing goals, but most only path to the activity zone.  Children are presumed superior to adults due to an extra pathing goal (to their parents).  Some animals may be too small to trigger pressure plates; grazers may starve before you get any logic out of them; flyers may ignore hatch-based logic blocks.
  
===Goblins===
+
===Invaders===
  
Goblin powered logic is highly ironic, especially if it involves controlling your goblin killing magma trap.  
+
Invaders such as elves or goblins will not work with any of the designs on this page, not unless you managed to dehand them before capture-- securely closed doors are no barrier to them.  Any mounts or warbeasts, on the other hand, might work, and exotics are unlikely to bear any children, and can be extraordinarily long-lived.  Job cancellation may be a problem with more complicated designs.  Invader animals path to the map edge following capture.  Be careful of any flyers or building destroyers.
  
  
 
==Putting it all together==
 
==Putting it all together==
  
 +
When it comes time to automate your systems the first thing you need to know is what needs to be automated and what should remain manual. An obsidian farm with completely autonomous control of the casting process is all well and good, until it drowns all your legendary miners when it prematurely triggers. All systems should have manual controls and failsafes to help avoid [[Fun]] (but because we all love Fun sometimes you forget to fully connect that emergency drain, or that failsafe system you built somehow failed.)
  
When it comes time to automate your systems the first thing you need to know is what needs to be automated and what should remain manual. An obsidian farm with completely autonomous control of the casting process is all well and good, until it drowns all your legendary miners when it prematurely triggers. All systems should have manual controls and failsafes to help avoid {{l|Fun}} (but because we all love Fun sometimes you forget to fully connect that emergency drain, or that failsafe system you built somehow failed.)
+
Once you know the steps you need in your system, it comes time to select the parts you need to automate, whether it be basic logic gates or more sophisticated multiple trigger systems.
  
Once you know the steps you need in your system, it comes time to select the parts you need to automate, whether it be basic logic gates or more sophisticated multiple trigger systems.
+
{{Category|Computing}}

Latest revision as of 23:16, 18 February 2012

This article is about an older version of DF.

Animal logic functions by taking advantage of the path finding algorithm in Dwarf Fortress; all domestic animals seek to find the shortest (lowest cost) path to their desired targets (activity zone, parents, dwarves, valuable objects, etc), this can be used to create very very complex logic gates. Animal logic has three principal advantages: speed, compactness, and simplified functions. However, animal logic is slower than mechanical logic and less reliable than either fluid or mechanical logic.

Definitions[edit]

For clarity, definitions of the terms used in animal logic are listed here:

Ground: for simplicity the thing the animal is pathing to is referred to as ground as that is the ground state which it wishes to reach. Ground is always the left unless otherwise noted.

Purge: Path to ground with no inputs

Path cost: The number of steps the animal must make to reach ground

Fusion Gate: Simply one or more logic gates built into the same system-- this efficiently replicates the functionality of stringed gates

Compound Gate: Gate which uses two or more gates set to different path costs.

AND Gate: AND takes 2 or more inputs and returns TRUE if ALL are TRUE.

NAND Gate: NAND takes 2 or more inputs and returns TRUE if ANY are FALSE.

ANDOR Gate: ANDOR takes 2 ore more inputs and returns TRUE if X-Y are TRUE. (this gate is exclusive to animal logic, and is a single step fusion of AND and OR)

OR Gate: OR takes 2 or more inputs and output TRUE if ANY are TRUE.

NOT Gate: NOT takes a single input and inverts it to the opposite state.

XOR Gate: XOR takes 2 or more inputs and output TRUE if ANY are TRUE but NOT ALL are TRUE.


NOR Gate: NOR takes 2 or more inputs and returns TRUE if ALL inputs are FALSE.

XNOR Gate: XNOR takes 2 or more inputs and returns TRUE if ALL are TRUE, or ALL are FALSE.

For a better explanation of gates see:http://en.wikipedia.org/wiki/Logic_gate

Notation: #:wall ^:pressure plate X:floodgate,grate,bars,bridge,etc(explained per entry) D:door,open, but kept tightly shut(pet impassable) d:door, input value not specified Letters:doors/floodgates,grates,bar,etc Specified inputs(these are generally interchangeable, if not this will be noted in the entry), generally controlled by mechanism g:Ground, some entries need it for clarity. C: Either an input in diagrams, or the state Carry is refereed to as a state within an adder.

Gates will always be capitalized in the way they are within the entry, e.g. AND, OR, ANDOR, XNOR, etc.


The basics of construction for an animal logic takes advantage of an animal's tendency to continue to path through tightly closed doors, despite them not being able to pass. It goes without saying that all doors not wired to mechanisms need to be tightly closed.


There are three principal logic gates in any logic system, AND, OR, and NOT. Animal logic can easily create all logic gates and is able to handle multi input-output, and fusion gates. The principal reason for this is pathfinding always prefers the shortest path to ground, and by controlling this path you can control the animal within the gate. The advantage of animal pathing is that the gate can have multiple states allowing more than a single ON or OFF signal. For simplicity and streamlining these systems only use binary information, but theoretically they could be made to compute in decimal or some other system; however, such gates are maddeningly complex and very hard if not impossible to build.

SIMPLE GATES[edit]

There are two primary ways to make a gate, single path and dual path, the single path gate only allows the animal a single exit and this forces it into a non pathing state until there is input at which point it will "wake up" and move; however, this kind of gate is slow and unreliable. Dual path gates always have an open path keeping the animal constantly pathing out of its enclosure. This constant pathing allows the gate to respond more quickly and retain higher reliability; however, the constant pathing may cause noticeable frame rate drops with large logic sets. I will only be discussing the dual path gates, as they're more effective for general use.


AND[edit]

This simple gate is made by confining the animal into a straight coridor; the ground path will have two or more doors which are connected to the input, while the second longer path remains clear. The gate can be configured as an NAND gate by simply moving the pressure plate. If the plate is by the ground path it functions as an AND gate returning TRUE if the ground path is open, and if the plate is by the purge path it will return FALSE when the inputs are TRUE.

#########
 ABCD^ D
#########


Multi AND[edit]

############
 ANYNUMD^ D
############


NAND[edit]

Reconfigured AND gate, see AND.

#########
 ABCD ^D
#########


OR[edit]

Basic gate, returns TRUE if either input is TRUE.

#####
AD^ D
B####
#####


Multi OR[edit]

#######
A #####
N #####
Y D^ D
N #####
U #####
M #####
#######


NOR[edit]

Basically a reconfigured OR gate.

#####
AD ^D
B####
#####


NOT[edit]

The simplest gate, it takes a single input and inverts it. FALSE -> TRUE, TRUE -> FALSE.

#######
 AD ^D
#######


Compound Gates[edit]

Basically two or more gates arranged with different path costs to ground. These gates can be configured in a number of different ways, these being the simplest. It may be possible to make these gates as single gates but that would require inverting some of the input. Simple compound gates use two simple gates and handle two inputs; complex compound gates have more then two simple gates and need more than two inputs. A complex compound gate might be used to convert decimal numbers into binary using And gates.

XOR[edit]

Compound of AND and OR, when ONLY ONE is TRUE returns TRUE If A and B are FALSE the animal moves to the FALSE position by Purge, if A or B is TRUE, the animal moves to the TRUE position at the OR gate, if both A and B are true the animal moves to the FALSE position by the AND gate.

#g########
# ABD  D #
# ####^# #
# ####D# #
# ###BA# #
#        #
##########

AND path cost: 4 OR path cost: 10 Purge path cost: 14


XNOR[edit]

Inverse of XOR: Return TRUE if BOTH are TRUE or FALSE If A and B are FALSE the animal moves to the TRUE position by Purge, if A or B is TRUE, the animal moves to the FALSE position at the OR gate, if both A and B are true the animal moves to the TRUE position by the AND gate.

#g#########
#         #
##B###### #
###A## DA # 
####D^##B #
#####D### #
######    #
###########

AND path cost: 4 OR path cost: 10 Purge path cost: 15


Complex Compound gate, Octal display ALU[edit]

Inputs are 1,2,4 these correspond to the binary values of the inputs, outputs are A,B,C,D,E,F,G,H being 0,1,2,3,4,5,6,7 respectively in the output display. I used octal for sanity, but this could be easily scaled to work for decimal (up to 10, beyond that you need a converter not an if switch) or hexadecimal(hex will be easy to handle, and probably easier to convert down to decimal)

#################
                #
# # # # # # #1# #
# # #1# #1#2#2# #
#1#2#2#4#4#4#4# #
#D#D#D#D#D#D#D#D#
#               #
#################
# ######
# 1  D #
# #### #
# 2  D #
# #### #
# 12 D #
# #### #
# 4  D #
# #### #
# 14 D #
# #### #
# 24 D #
# #### #
# 124D #
# #### #
#    D #
########


Fusion gates[edit]

These are gates which are constructed by physically combining the two gates to get a specific output.


ANDOR[edit]

This gate will evaluate if either of x AND statements are TRUE. This gate is built as a straight line similar to the AND gate.

######
#C####
ABD^ D
C#####
######


NANDOR[edit]

Reconfigured ANDOR gate, see ANDOR.

######
#C####
ABD ^D
C#####
######


ORANDOR[edit]

This gate returns true if either A or B and either C or E is true.

######
AC####
BED^ D
######


ORANDAND[edit]

This gate returns true if either A or B is true, and E and C are true.

#######
A######
BCED^ D
#######


Complex Gates[edit]

The development of more complex gates requires careful calibration of the path cost of each path to allow the gate to switch states correctly and display the correct result.

Adders[edit]

A full adder can be made as a Compound Fusion gate, by combining AND, ANDOR, and OR gates


Binary Adder[edit]

A binary adder is constructed of two or three "sum" gates and a purge path. A half adder only adds two numbers and only needs two sum gates, 1 and 2. Full adders using carry to allow chaining require three sum gates, 1,2 and 3. Because binary is base two that translates to 01,10,11 as the sums, when the second bit is a 1, the gate is "carrying" the value up to the next level.

When building the adder, the highest path must have the most preferential path to ground or it will not properly function.

Standalone adders (they don't carry into another adder) require 22 mechanisms, and 14 doors. Start adders (They feed into the next adder and include a carry) require 32 mechanisms, and 14 doors. Chain adders (The receive Carry, and pass a Carry bit up) require 32 mechanisms, and 14 doors The gates only take up 13x9 tiles each.

Hatch-based logic[edit]

Hatches can be used in many logic designs for alternate designs. A hatch over a ramp serves as a door that cannot be wedged open; a hatch over a channel functions as a naturally inverted door, blocking pathing when open rather than when closed. Although the designs on this page all use doors to restrict path, careful use of hatches can be more effective for some circuits.


Reference pictures


Decimal Adder[edit]

While it can be done, it's significantly more complex than simply making a set of decimal converters working with binary adders.


Hexadecimal Adder[edit]

A hexadecimal adder works on a similar level to the binary adder, however it uses 64 sum gates ranging from 0 to 31. User:LordOOTFD is developing a prototype adder which utilizes a floating carry bit to function as a full adder.

Subtractors[edit]

Inverse adder, simple but not yet tested.


Animals[edit]

Choosing the animal which works as the logic core for an animal logic systems is somewhat important, depending on your needs and the available animals. However pretty much anything will do as long as you can remember which animal fits into which gate (to avoid designating the same animal for more than one pit).


Cats[edit]

Unfortunately, cats are both too small to trigger pressure plates.


Puppies[edit]

Puppies are quite reliable with two pathing goals, which is presumed to lead to faster response times than animals with only a single pathing goal, but tend to spit out babies upon maturation. Puppies path to the activity zone, and their parents.

Dogs[edit]

While dogs may seem an attractive option for logic cores, they will be far more useful as wardogs or hunting dogs to protect dwarves. Dogs path to the activity zone.

Other animals[edit]

Many animals work, but the above are probably your best choice, excluding any modded animals. However if you have a GCS handy, a GCS powered computer would be awesome, so take this as you will. Other animals have different pathing goals, but most only path to the activity zone. Children are presumed superior to adults due to an extra pathing goal (to their parents). Some animals may be too small to trigger pressure plates; grazers may starve before you get any logic out of them; flyers may ignore hatch-based logic blocks.

Invaders[edit]

Invaders such as elves or goblins will not work with any of the designs on this page, not unless you managed to dehand them before capture-- securely closed doors are no barrier to them. Any mounts or warbeasts, on the other hand, might work, and exotics are unlikely to bear any children, and can be extraordinarily long-lived. Job cancellation may be a problem with more complicated designs. Invader animals path to the map edge following capture. Be careful of any flyers or building destroyers.


Putting it all together[edit]

When it comes time to automate your systems the first thing you need to know is what needs to be automated and what should remain manual. An obsidian farm with completely autonomous control of the casting process is all well and good, until it drowns all your legendary miners when it prematurely triggers. All systems should have manual controls and failsafes to help avoid Fun (but because we all love Fun sometimes you forget to fully connect that emergency drain, or that failsafe system you built somehow failed.)

Once you know the steps you need in your system, it comes time to select the parts you need to automate, whether it be basic logic gates or more sophisticated multiple trigger systems.