An inverter is a single-input gate where the output is the complement of the input.
The code below makes an inverter by sandwiching an O-tetromino between horizontal L- and J-tetrominoes.
not.t lu 0 o 0 4 1 jd 0 in i -1..1 0 out o -1..1 5
Note: While workspace coordinates are always ≥ 0 due to the floor and the discards pile, structure definitions may contain negative column indices because the coordinates are relative to where the structure is built.
The following animation shows what happens for both input values.
When the input is 0, the L-tetromino lands low. That enables the O-tetromino to shift upon the L-tetromino's protuberance. The J-tetromino, in turn, lands high, producing an output of 1.
When the input is 1, the L-tetromino lands high. That causes it to act a barrier that obstructs the horizontal movement of the O-tetromino. Consequentially, the J-tetromino lands low, generating an output of 0.
In both cases, the output is the opposite of the input.
A horizontally reflected version exists purely for aesthetics reasons. The image below shows notLeft (an alias for not) and its reflection, notRight.
© 2023 meatfighter.com |