Besiege Wiki
Advertisement
Besiege Wiki

The Logic Gate is a machine block which takes two keys as input and emulates another key based on the selected boolean operation.

Settings[]

Parameter Default Value Range Conditions
Input A [U] Keys -
Input B [I] Keys Operation has two inputs
Condition AND AND, OR, NOR, NAND, XOR, XNOR, Random, SR Latch, D Latch, Counter, NOT -
Toggle Mode False Boolean Operation is not SR Latch, D Latch, or Counter
Emulate [C] Keys -

Usage[]

The Logic Gate presses and holds a key if the two input keys satisfy the set boolean condition (see #Truth Tables and Boolean Algebra).

The two levers on the face display the current inputs - red for inactive, green for active.

An indicator light on the face of the block turns on when the block is emulating a keypress.

It is not necessary to attach the logic gates to the machine; they will work just fine left lying on the ground. Especially considering their mass and how many you may need.

Logic gates cannot activate themselves.

Applications[]

A T flip flop (or toggleable memory cell) can be created by setting the condition to OR and enabling Toggle Mode. NOT can be used instead to make it active by default.
These can be combined with auto-return Steering Hinges or Toring for single-press retract/extend landing gear/flaps/doors/other mechanisms.

Another important use is combining the outputs of multiple other automation blocks. A simple example would be automatic landing gear which only extends below a certain speed and altitude, which could be created with an AND gate.

By routing controls through AND gates, it is possible to create multiple control mappings for the same keys.
For example, if you wanted to use only thrusters for VTOL control and only control surfaces for normal flight, this could be achieved by having multiple AND gates with the pitch, roll, and yaw controls as Input A, a single separate key as Input B, and the keys for the control surfaces set as the output.
Input B could then be set as the output of a T flip-flop; when toggled, that particular control mapping will be toggled on or off.

Truth Tables and Boolean Algebra[]

For these tables, 🟥 is Inactive/False, 🟢 is Active/True, and 'Keep' means it keeps the last actual setting:

A B AND OR NOR NAND XOR XNOR SR Latch D Latch
🟥 🟥 🟥 🟥 🟢 🟢 🟥 🟢 Keep Keep
🟥 🟢 🟥 🟢 🟥 🟢 🟢 🟥 🟥 🟥
🟢 🟥 🟥 🟢 🟥 🟢 🟢 🟥 🟢 Keep
🟢 🟢 🟢 🟢 🟥 🟥 🟥 🟢 🟥 🟢
A NOT Random Counter
🟥 🟢 Keep Keep
🟢 🟥 ???? 🟥🟥🟥🟢

Some operations are the inverse of other operations:

  • NAND = NOT(AND)
  • NOR = NOT(OR)
  • XNOR = NOT(XOR)

SR Latch (set-reset) and D Latch (clocked) are memory; they are used to store information. OR gates with Toggle Mode on is a T flip-flop (which you might have used if you ever played Minecraft).
The Counter mode is a weird form of binary counter - it only activates if the total amount of keypresses is divisible by 4.

OR gates can be used to mix down six or more keys to a single key (which is great if mods or file editing aren't available). For three or less keys, just set the keys on the output block directly to get the same effect.

Random chooses a random state when pressed.

To get the most out of Logic Gates, it is essential to learn at least the basics of Boolean algebra - about how to formulate, express, and simplify boolean expressions. Particularly for complex machines, simplification is important - beyond bringing down the block count, each 'connection' between logic gates and other automation blocks requires an entire key, and keys are usually more limited than block count (particularly if you can't set them to non-keyboard keys!).

For those who do know their way around boolean algebra, Karnaugh_maps are one way to simplify expressions.

Technology[]

Some examples of logic gate applications:

  • Some types of mechanical Engines use logic gates.
  • Digital Swashplates can be built using logic gates.
  • Walkers can use logic gates in place of mechanical systems for walk cycles.
  • Autopilot systems can use logic gates to combine inputs from other automation blocks.

The Logic Gate is one of the most potent blocks in the game; on its own it might not be useful, but it allows so much more to be done with other blocks.

See Also[]


Blocks

Starting Block-thumb Starting Block • Wooden (Small Wooden Block-thumb Small Block / Wooden Block-thumb Block / Wooden Pole-thumb Pole / Log-thumb Log) • Brace-thumb BraceSmooth Surface Block-thumb Smooth Surface Block

Joints (Swivel Joint-thumb Swivel / Ball Joint-thumb Ball / Hinge-thumb Hinge / Axle Linkage-thumb Axle) • Steering (Steering Hinge-thumb Hinge / Steering Block-thumb Block) •
Wheels (Powered Wheel-thumbPowered Large Wheel-thumb Powered / Unpowered Wheel-thumbUnpowered Large Wheel-thumb Unpowered / Small Wheel-thumb Small) • Cogs ((Unpowered Cog-thumb Unpowered / Powered Cog-thumb Powered) / Unpowered Large Cog-thumb Large)

Decoupler-thumb DecouplerContractible Spring-thumb Contractible SpringSuspension-thumb SuspensionSlider-thumb SliderPiston-thumb PistonSpinning Block-thumb Spinning BlockGrabber-thumb GrabberWinch-thumb Winch

Metal Spike-thumb Metal SpikeMetal Blade-thumb Metal BladeCircular Saw-thumb Circular SawDrill-thumb DrillMetal Jaw-thumb Metal JawCannon-thumb CannonShrapnel Cannon-thumb Shrapnel CannonWater Cannon-thumb Water CannonCrossbow-thumb CrossbowVacuum-thumb VacuumFlamethrower-thumb FlamethrowerTorch-thumb TorchBomb-thumb BombRemote Grenade-thumb Remote GrenadeExplosive Rocket-thumb Explosive RocketFlaming Ball-thumb Flaming BallBoulder-thumb Boulder

Timer-thumb TimerLogic Gate-thumb Logic GateSensor-thumb SensorAltimeter-thumb AltimeterAnglometer-thumb AnglometerSpeedometer-thumb SpeedometerLength Detector-thumb Length DetectorPin Block-thumb Pin BlockCamera Block-thumb Camera Block

Flying Block-thumb Flying BlockPropeller-thumbSmall Propeller-thumb PropellersWing-thumb WingWing Panel-thumb Wing PanelBallast-thumb BallastBalloon-thumb Balloon

Armor Plate (Small)-thumbArmor Plate (Large)-thumbArmor Plate (Round)-thumb Armor PlatesWooden Panel-thumb Wooden PanelBuild Surface-thumb Build SurfaceGrip Pad-thumb Grip PadPlow-thumb PlowHalf Pipe-thumb Half PipeHolder-thumb HolderSpike Ball-thumb Spike Ball

Advertisement