- 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.
Difference between revisions of "v0.31:Creature logic"
m |
(Identity/NOT and simple delay; creature choice; alternative furniture; ordinal compare via XOR/XNOR) |
||
Line 19: | Line 19: | ||
==Gates== | ==Gates== | ||
Creature logic relies on the ability or inability of a creature to path through a specific area. In general, reliability can only be guaranteed when a creature always has one and only path, or is completely incapable of movement. Because of that, the following logic gates are shown in pairs to guarantee a path to the creature. | Creature logic relies on the ability or inability of a creature to path through a specific area. In general, reliability can only be guaranteed when a creature always has one and only path, or is completely incapable of movement. Because of that, the following logic gates are shown in pairs to guarantee a path to the creature. | ||
+ | |||
+ | Most of these gates can be easily altered to take more than two operands. | ||
====Key==== | ====Key==== | ||
In all of the following diagrams, # is wall, d is mechanism-operated door, h is mechanism-operated hatch over channel, ^ is a pressure plate, and empty space is floor space. The creature is presumed to enter from the left in an attempt to path to the right. | In all of the following diagrams, # is wall, d is mechanism-operated door, h is mechanism-operated hatch over channel, ^ is a pressure plate, and empty space is floor space. The creature is presumed to enter from the left in an attempt to path to the right. | ||
+ | |||
+ | ===Identity with NOT gate=== | ||
+ | |||
+ | #### | ||
+ | ##d^## | ||
+ | ## | ||
+ | ##h ## | ||
+ | #### | ||
+ | |||
+ | This function takes a single operand. If the operand is true, the creature travels through the upper path (identity); otherwise, the creature takes the lower path (NOT). The pressure plate is triggered when the operand is true. This gate is the basis of all to follow. | ||
+ | |||
+ | Identity is also a simple delay. When the path receives a signal, it propagates it after a short period. That period depends on the speed of the creature moving through the gate. | ||
===AND gate with NAND gate=== | ===AND gate with NAND gate=== | ||
Line 46: | Line 60: | ||
===XOR gate with XNOR gate=== | ===XOR gate with XNOR gate=== | ||
− | This is the most complicated combination; maybe as compensation, it can double as an ordinal comparison. 2 arms are required for each each gate. | + | This is the most complicated combination; maybe as compensation, it can double as an ordinal comparison-- XNOR implies equality, while the two arms of XOR, from north to south, imply that the first operand is greater than or less than the second operand. 2 arms are required for each each gate. Unlike the other gates, XOR cannot easily be altered to take more than two operands-- evaluation of three operands, for instance, would require tripling its size. |
#### | #### | ||
Line 83: | Line 97: | ||
==Clock Generation== | ==Clock Generation== | ||
Probabilistic movement rates combined with attribute rust make perfect clock generation impossible. Without rust, however, its possible to design a device that will measure the speed of a given creature to any arbitrary level of confidence (less than total). | Probabilistic movement rates combined with attribute rust make perfect clock generation impossible. Without rust, however, its possible to design a device that will measure the speed of a given creature to any arbitrary level of confidence (less than total). | ||
+ | |||
+ | ==Alternative Design== | ||
+ | Multiple choices of furniture are available for the doors or hatches in the above diagrams. Various reasons exist for substitution. | ||
+ | |||
+ | ====Doorless Design==== | ||
+ | Of all alternative designs, doorless design is the most practical. All doors are replaced with hatches over stairs or ramps, and the path continues one z-level down or up. This makes it more difficult to visualize the effect of the circuit at a glance, and some very efficient designs may require more significant changes, but every circuit possible can be created without doors. Use of hatches instead of doors protects against the effects of doors being blocked open by unexpected creatures or objects-- the original bug, after all, took the form of vermin remains. Retracting bridges can be used the same way, but lead to problematic delays. | ||
+ | |||
+ | ====Hatchless Design==== | ||
+ | Hatchless design is much more difficult and of very limited use. Signal inversion can make a door act like a hatch; a raising bridge acts like a hatch. Both of these institute delays in processing that require large expansion of logic circuits and limit the effectiveness of memory, but they may be necessary when using submerged logic or flyers-- bragging rights for a logic system submerged in magma that processes via fire imps may be worth the headache. | ||
+ | |||
+ | ====Floodgate Design==== | ||
+ | Floodgates can be used instead of any of the doors pictured; with signal inversion, they can also be used instead of hatches. Floodgates respond much more slowly than doors, but if obstructed, they return to their proper state as soon as the obstruction is removed. This can be important, for instance, if your creatures give birth inside of your logic circuit. | ||
+ | |||
+ | ====Bridge Design==== | ||
+ | Bridge design uses bridges instead of both doors and hatches. Doors are replaced with retracting bridges over ramps or staircases; hatches are replaced with raising bridges, or with retracting bridges over channels. Bridge design causes frustrating delays, but it is the only way to use building destroyers in a logic circuit. The irony of making your minotaur run an impossible labyrinth may be worth the design headache. | ||
+ | |||
+ | ==Creature Choice== | ||
+ | Multiple choices exist for creatures to run logic circuits. Each has its own advantages and disadvantages. | ||
+ | |||
+ | ====Domestic Animals==== | ||
+ | Domestic animals are valid choices for creature logic, but come with a host of disadvantages. Many females are capable of giving birth inside of your logic gates; their children can block the closing of doors or set off pressure plates. Grazers, of course, will starve inside most logic circuits, although some special designs may be capable of supporting a grazer. Some domestics are too small to set off pressure plates; some are capable of flight, requiring hatchless design. All domestic animals will die of old age, requiring periodic replacement; most domestic animals have relatively short lifespans. Logic involving domestic animals must be built with pressure plates that can be triggered by citizens; building these circuits may turn into a nightmare of job cancellations and stranded, starving dwarves. Domestic animals have one huge advantage, however: the location of their pathing goal can be altered with direct action of the player, without any building required, by placement of a meeting zone. | ||
+ | |||
+ | ====Invaders==== | ||
+ | Invaders are readily available on most maps, rarely or never give birth, and require no sustenance. Pressure plates don't need to be built triggerable by citizens. Elves and goblins will never die of old age. However, invaders cause their own problems. Invaders can cause job cancellations, and in some circuits may escape, wreaking havoc deep in your fortress. Dwarves armed with bolts and crossbows will take potshots at your computers periodically. Finally, invader-based logic must have a path to the map edge for predictable pathing. If your logic circuit is inside of your fortress, walling off, even through something as simple as raising a bridge at your entrance, will lead to unpredictable pathing. | ||
+ | |||
+ | ====Dwarves==== | ||
+ | Dwarves themselves can be used to run logic circuits, and are perhaps the most interesting choice. While longer-lived than most domestics, dwarves starve and dehydrate easily, requiring frequent, careful maintenance. Idle dwarves path unpredictably; dwarves are vulnerable to drowsiness, leading to the potential for very high latency. Married female dwarves are fecund. At the same time, dwarves are excellent choices for logic circuits because of their varied pathing goals that can be altered through direct interaction by the player. Dwarves can trigger events both through the use of pressure plates and through the use of levers. In fact, one can see the entire game of Dwarf Fortress as one big logic circuit with dwarves as the driving creature. | ||
+ | |||
+ | ====Other Choices==== | ||
+ | There are a few things to stay away from, but in general, any sufficiently understood creature can be used for creature logic. Building destroyers are problematic, but full-bridge design is possible. Likewise, flyers and swimmers cause difficulty, but nothing that can't be worked around. Creatures with trapavoid are unfortunately useless (with the possible exception of gremlins, who might be able to output via levers), as are creatures with a size less than 10000, as they're too small to set off pressure plates. The essence of creature logic, however, is predictable pathing. This may or may not exclude the use of certain types of wildlife. | ||
==Animal logic== | ==Animal logic== | ||
− | {{L|Animal logic}} relies on a special case of creature logic that is specific to animals that are unable to | + | {{L|Animal logic}} relies on a special case of creature logic that is specific to animals that are unable to open doors, by pathing them through tightly closed doors. Animal logic can be very space efficient and easy to build. |
{{Category|Computing}} | {{Category|Computing}} |
Revision as of 22:40, 2 September 2011
Creature logic functions by taking advantage of creature's natural path-finding goals to trigger pressure plates. Creature logic is complete-- you can build memory, repeaters, or any sort of logical circuit.
Creature logic vs mechanical or fluid logic
Pro:
- Creature logic requires no fluid or wind. In dry, windless environments, creature logic is the only kind of logic you can use.
- Creature logic is relatively fast. Although it can never reach the speed of mechanical logic, it can operate more quickly than fluid logic.
- All creature logic circuits can be designed with only stone and a pick-- although you're free to use wood or metal if you prefer!
- Creature logic doesn't need anything but creatures to send or receive signals. There's no need to translate signals as with with mechanical logic.
- Creature logic can be very intuitive-- it can even work in decimal systems without conversion.
- It's fun to watch the creatures run around!
Con:
- Reliable creature logic requires a lot of space, a lot of hatches and doors, and a lot of mechanisms. There are tricky things to do that can reduce this, but they're best avoided in favor of good design principles.
- Creature logic requires creatures-- sometimes, a great number of creatures. Sometimes, those creatures die or have babies. Sometimes, they interrupt your dwarves. Sometimes, your dwarves fill them full of crossbow bolts.
- Creature logic is vulnerable (surprise) to the presence of unexpected creatures in the logic circuits. Because creature logic circuits require a path either to the map edge or to the meeting hall (in most cases), this is a real possibility.
- Creature logic can require large amounts of space. A creature logic XOR is vastly larger than a mechanical logic XOR.
- It is not possible to design perfect delays with creatures in an unmodded game. Any timing devices will always be vulnerable to error, although some techniques can lower this potential to a minimum.
Gates
Creature logic relies on the ability or inability of a creature to path through a specific area. In general, reliability can only be guaranteed when a creature always has one and only path, or is completely incapable of movement. Because of that, the following logic gates are shown in pairs to guarantee a path to the creature.
Most of these gates can be easily altered to take more than two operands.
Key
In all of the following diagrams, # is wall, d is mechanism-operated door, h is mechanism-operated hatch over channel, ^ is a pressure plate, and empty space is floor space. The creature is presumed to enter from the left in an attempt to path to the right.
Identity with NOT gate
#### ##d^## ## ##h ## ####
This function takes a single operand. If the operand is true, the creature travels through the upper path (identity); otherwise, the creature takes the lower path (NOT). The pressure plate is triggered when the operand is true. This gate is the basis of all to follow.
Identity is also a simple delay. When the path receives a signal, it propagates it after a short period. That period depends on the speed of the creature moving through the gate.
AND gate with NAND gate
##### ##dd^## ### ## h ## ##h## ###
The doors at the top are both open if both operands are true (AND); the hatches at the bottom permit path if either operand is false (NAND). The pressure plate will be triggered when both operands are true.
NOR gate with OR gate
##### ##hh^## ### ## d ## ##d## ###
The hatches at the top permit path only if neither operand is true (NOR); the doors at the bottom permit path if either operand is true (OR). The pressure plate will be triggered when neither operand is true.
XOR gate with XNOR gate
This is the most complicated combination; maybe as compensation, it can double as an ordinal comparison-- XNOR implies equality, while the two arms of XOR, from north to south, imply that the first operand is greater than or less than the second operand. 2 arms are required for each each gate. Unlike the other gates, XOR cannot easily be altered to take more than two operands-- evaluation of three operands, for instance, would require tripling its size.
#### ##dh## # ## ## ## hd ^### ##### ## dd ### # ## ## ##hh## ####
The two paths at the top permit path if either operand is true but not both are true (XOR); the doors at the bottom permit path if both operands are true or if both operands are false (XNOR). The pressure plate will be triggered when either operand is true but not both are true.
Multiple use
The gates above are single use gates; the creatures will escape after pathing through each gate. Circuits which return the creature to the beginning of the path are possible via altering the path in-route.
##h# h^## ##d#
This is one version of such a device. Upon stepping on the pressure plate, the creature opens two hatches, thus blocking retrograde motion as well as access to its pathing goal, and opens a door, thus opening access to a new pathing goal. This new pathing goal can lead back to the original position of the creature.
Creature Memory and Repeater
###### h^hh^h ######
This is the simplest version of creature-based memory. Each pressure plate is linked to each adjacent hatch. Memory state is toggled by sending a close signal to the two central hatches.
Note that in this diagram, both ends need to lead to the pathing goal. The creature can enter by either side, but will be constrained to either pressure plate during normal operation.
By leaving the central hatches unlinked, or by leaving the central area floored, you have a small creature-based repeater. Small repeaters like this tend not to fire frequently, but are unpredictable. Larger repeaters, with more frequent and predictable firing, are possible.
Clock Generation
Probabilistic movement rates combined with attribute rust make perfect clock generation impossible. Without rust, however, its possible to design a device that will measure the speed of a given creature to any arbitrary level of confidence (less than total).
Alternative Design
Multiple choices of furniture are available for the doors or hatches in the above diagrams. Various reasons exist for substitution.
Doorless Design
Of all alternative designs, doorless design is the most practical. All doors are replaced with hatches over stairs or ramps, and the path continues one z-level down or up. This makes it more difficult to visualize the effect of the circuit at a glance, and some very efficient designs may require more significant changes, but every circuit possible can be created without doors. Use of hatches instead of doors protects against the effects of doors being blocked open by unexpected creatures or objects-- the original bug, after all, took the form of vermin remains. Retracting bridges can be used the same way, but lead to problematic delays.
Hatchless Design
Hatchless design is much more difficult and of very limited use. Signal inversion can make a door act like a hatch; a raising bridge acts like a hatch. Both of these institute delays in processing that require large expansion of logic circuits and limit the effectiveness of memory, but they may be necessary when using submerged logic or flyers-- bragging rights for a logic system submerged in magma that processes via fire imps may be worth the headache.
Floodgate Design
Floodgates can be used instead of any of the doors pictured; with signal inversion, they can also be used instead of hatches. Floodgates respond much more slowly than doors, but if obstructed, they return to their proper state as soon as the obstruction is removed. This can be important, for instance, if your creatures give birth inside of your logic circuit.
Bridge Design
Bridge design uses bridges instead of both doors and hatches. Doors are replaced with retracting bridges over ramps or staircases; hatches are replaced with raising bridges, or with retracting bridges over channels. Bridge design causes frustrating delays, but it is the only way to use building destroyers in a logic circuit. The irony of making your minotaur run an impossible labyrinth may be worth the design headache.
Creature Choice
Multiple choices exist for creatures to run logic circuits. Each has its own advantages and disadvantages.
Domestic Animals
Domestic animals are valid choices for creature logic, but come with a host of disadvantages. Many females are capable of giving birth inside of your logic gates; their children can block the closing of doors or set off pressure plates. Grazers, of course, will starve inside most logic circuits, although some special designs may be capable of supporting a grazer. Some domestics are too small to set off pressure plates; some are capable of flight, requiring hatchless design. All domestic animals will die of old age, requiring periodic replacement; most domestic animals have relatively short lifespans. Logic involving domestic animals must be built with pressure plates that can be triggered by citizens; building these circuits may turn into a nightmare of job cancellations and stranded, starving dwarves. Domestic animals have one huge advantage, however: the location of their pathing goal can be altered with direct action of the player, without any building required, by placement of a meeting zone.
Invaders
Invaders are readily available on most maps, rarely or never give birth, and require no sustenance. Pressure plates don't need to be built triggerable by citizens. Elves and goblins will never die of old age. However, invaders cause their own problems. Invaders can cause job cancellations, and in some circuits may escape, wreaking havoc deep in your fortress. Dwarves armed with bolts and crossbows will take potshots at your computers periodically. Finally, invader-based logic must have a path to the map edge for predictable pathing. If your logic circuit is inside of your fortress, walling off, even through something as simple as raising a bridge at your entrance, will lead to unpredictable pathing.
Dwarves
Dwarves themselves can be used to run logic circuits, and are perhaps the most interesting choice. While longer-lived than most domestics, dwarves starve and dehydrate easily, requiring frequent, careful maintenance. Idle dwarves path unpredictably; dwarves are vulnerable to drowsiness, leading to the potential for very high latency. Married female dwarves are fecund. At the same time, dwarves are excellent choices for logic circuits because of their varied pathing goals that can be altered through direct interaction by the player. Dwarves can trigger events both through the use of pressure plates and through the use of levers. In fact, one can see the entire game of Dwarf Fortress as one big logic circuit with dwarves as the driving creature.
Other Choices
There are a few things to stay away from, but in general, any sufficiently understood creature can be used for creature logic. Building destroyers are problematic, but full-bridge design is possible. Likewise, flyers and swimmers cause difficulty, but nothing that can't be worked around. Creatures with trapavoid are unfortunately useless (with the possible exception of gremlins, who might be able to output via levers), as are creatures with a size less than 10000, as they're too small to set off pressure plates. The essence of creature logic, however, is predictable pathing. This may or may not exclude the use of certain types of wildlife.
Animal logic
Template:L relies on a special case of creature logic that is specific to animals that are unable to open doors, by pathing them through tightly closed doors. Animal logic can be very space efficient and easy to build.