The Castle Doctrine Wiki

This page is to help explain advanced electronics such as bit-storage, pulses, counters, clocks, and how electronics cycles work so that you can create your own clever electrical setup.

Related Topis[]

  • Wiring - basic concepts such as boolean logic and power propagation
  • Traps Guide - applied electronics in creative and interesting ways.


Basic electronic setups with wires and switches can be quite simple to understand and straightforward. The introduction of voltage switches complicates things as it allows for the creation of situations where there is no simple answer to the question of whether something is powered or not.

To figure out what is powered and what isn't the game runs through numerous "cycles" until the state of the electronics either stabilizes or repeats itself. This process occurs every time the player moves or uses a tool. The state of voltage triggered switches and voltage triggered inverted switches (VTIS) in each cycle is determined by whether they were powered from the tile above during the previous cycle. The state of each voltage switch at the start is determined by where they had settled the previous "turn" (that is the last time the player moved or used a tool).

The following castledraft map shows how cycles work in a number of electrical setups:

Each row in the above example represents is the steps that the game goes through in order to determine the state of the different electronic configurations after they are powered.

In the examples above the leftmost circuit of each column represents the initial state of a circuit before a pressure switch is turned on. The circuits to the right represent each cycle after the button is pressed until it repeats a state. The column to the right is shown the final state as it will appear to the player.

Advanced Electronic Components[]

Note: All of the following examples can be reproduced mirrored over the vertical axis, (e.g. flowing from left to right instead of from right to left).

Single Pulse Generator[]

Starting state:

Single Pulse Generator - Start.png


Single Pulse Generator - Cycles.png

Settled state:

Single Pulse Generator - End.png

(image to be added, see 1st example in:

A single pulse generator powers part of a wire system for a single cycle, thus sending a "pulse" through the circuitry which will not power anything overall but can be used for a number or purposes, such as sending signals from one part of the circuitry to another or incrementing a counter. After sending the initial pulse the above example will send no more until "reset" by switching the pressure switch off and on again.

Bit Storage Unit[]

Bit Storage Unit.png

Bit storage attached to a single pulse generator -

Starting State:

Bit Storage Start.png


Bit Storage Cycles.png

Final state after switch is turned off:

Bit Storage End.png

A bit storage unit allows wiring, once powered to remain powered even after the initial power source is deactivated. It can be activated by a single pulse.

The above example is of single pulse generator attached to a bit storage unit. The bit storage unit starts unpowered as the starting state of voltage triggered switches is "off" so power cannot pass through. When a pulse is sent it powers the switch which now lets power through to power itself and so will remain "on".

One way gate/delay[]

One Way Gate.png

It is often important to make sure that power can only propagate in one direction through circuitry. This simple one way gate will transmit any signal it receives from above through the wire to the right with a single cycle delay and not allow power propagation to flow back to the original source.

A delay has many uses, such as synchronising signals.

For an example of how the gate works see the following map:

The first row shows power passing through from the top. The second shows power being blocked from the right.

Paradox Circuit[]

Paradox circuit.png

A paradox circuit generates a pulse every odd cycle. As it gets caught in a loop each looping part of electronics will resolve into its "off" state (including the voltage inverted switch). If any part of the circuit is cut all wiring up until the cut will receive constant power and switch "on". Paradox circuits have a number of uses, such as in "clock signal generators" below.

Signal Filter[]

Signal Filter.png

A signal filter will shorten any series of consecutive pulses by removing the first pulse in the sequence. This will completely block any single pulse and will convert a double pulse into a single. It can also be used to completely filter out a looping signal from a paradox circuit while allowing full power to flow through. The above example filters signals passing from left to right.

Signal filters can be chained together to filter out larger pulse sequences. As such they can be used to distinguish between pulse sequences of different lengths.

Counter bit[]

(image to be added, see final example in:

A counter bit is the basic component of a counter. Counters are made by chaining counter bits together. A counter will "increment" whenever it receives a single pulse and will send a final pulse once it has fully cycled through. The number of bits in the counter determines how long it takes to cycle through - the total number of turns before it sends the final pulse will be two to the power of the number of bits. As such, an 2 bit counter will count to 4, a 3 bit counter to 8, a 4 bit to 16 an 8 bit to 256 etc.

A single bit works through alternating between "on" and "off" every time it receives a pulse. When switching from "on" to "off" it sends a pulse to the next bit in the sequence.

Clock Signal Generator[]

Paradox clock.png

A clock signal generator sends a single pulse each "turn" of the game (whenever the player moves or uses a tool). This allows for the creation of a clock when attached to a counter.

Clocks & Paradoxical Circuits[]

(You'll find a guide on how to build and use clocks here)

Using the properties of stabilization and cycles, it is possible to create a clock that repeats at a specific interval. Some circuits cannot toggle and result in a settled state.

Basic Paradox (credit: [JasonRohrer])

Paradox circuit.png

This is the simplest example is a paradox circuit. It loops forever, turning itself on and off, and never resolves. The game detects the looping behavior and has the whole thing "settle down" into it's lowest state (identical to what is pictured there), and this is not a visually consistent state (power looks like it should flow to the light, but the light is off).

Tiny Signal Generator (credit: [joshwithguitar] & [Hippasus])

Paradox clock.png

The heart of the 8-bit clock below. This circuit will toggle between states (on/off) on each step the robber takes (or each tool use).

8-bit clock chain clock[]

The following is an example of a repeating circuit with period 8. (credit: [Hippasus])

Advanced clock8.jpg

Advance Switches[]

Sticking Toggle Switch[]

The following circuit simulates a Sticking Pressure Switch with a Pressure Toggle Switch.

Sticky button.png

Tricky Toggle Switch[]

Using the Sticking Toggle Switch we can create a switch with an unexpected behavior. To enable the following circuit, the robber must toggle the switch on and then off again.

Tricky button.png

Tricky Inverted Toggle Switch[]

To disable the following circuit, the robber must toggle the switch off and then on again. This switch is useful for tricking a robber into think they have disabled a trap.

Inverted tricky.png