Skip to main content

Logic Gates

CategoryWorld
logic-gates
Category
World

Overview

Logic Gates are wire-connected entities that compute an output signal based on whether their inputs are truthy. Most Logic Gates always output either 1 or 0, representing truthy and non-truthy results respectively. The Transistor Gate is an exception: it can forward and output any signal type and produces null (not 0) when its enabling input is not truthy.

Signals have truthiness determined by their type. Null, Conflict, and Integer = 0 are not truthy. Integer ≠ 0, Shape, and Color are truthy. Logic Gates evaluate inputs using that truthiness, not by implicit numeric conversion beyond the Integer rules above.

The core gates behave as follows. The AND Gate outputs 1 only when both inputs are truthy; otherwise it outputs 0. The OR Gate outputs 1 when at least one input is truthy; if no input is truthy it outputs 0. The XOR Gate outputs 1 when exactly one input is truthy; if both or neither input is truthy it outputs 0. The NOT Gate outputs 1 when its input is not truthy and outputs 0 when the input is truthy. The Comparison Gate compares its two input signals according to a selected compare mode (Equal, NotEqual, Greater, GreaterEqual, Less, LessEqual). In Equal and NotEqual modes it works on all signal types and tests strict equality/inequality, outputting 0 or 1. In the numeric comparison modes (Greater, GreaterEqual, Less, LessEqual) it only yields a nonzero result when both signals are integers; if either input is non-integer the output is 0. The Transistor Gate forwards the signal received from its rear only when the side input is truthy; when the side input is not truthy its output is null. The Transistor Gate can output any signal type carried by its rear input, making it the only gate capable of forwarding Shape, Color, integer values other than 0, or other non-boolean signals.

Logic signals drive other entities in specific ways. The Belt Filter uses the Wire input signal to choose which output belt receives shapes: Null or Conflict block the belt entirely; Integer = 0 sends all shapes to the side output; Integer ≠ 0 sends all shapes straight through; Shape signals allow matching shapes to pass straight through while sending non-matching shapes to the side; Color signals cause the filter to send all shapes to the side. The Pipe Gate controls fluid throughput: Null, Conflict, and Integer = 0 block fluids; Integer ≠ 0 allows throughput; Color allows throughput only if the fluid matches the color signal. The Belt Reader displays the rate of shapes per minute passing through it and outputs the Shape Signal for the shapes on its Wire output.

  • Logic Gate outputs depend exclusively on input truthiness, not on implicit casting beyond the stated rules.
  • Use Transistor Gate to gate arbitrary signal types; remember it outputs null when disabled instead of 0.
  • Use Comparison Gate Equal/NotEqual for non-numeric types; use numeric compare modes only when both inputs are integers.
  • When wiring filters or pipes, verify the signal type expected (Shape, Color, integer) because behavior differs by target entity.

Other entities of this type

Related pages

Last updated: