Beetle
Beetle is an esoteric programming language with a 2-dimensional array of cells inspired by Langton's Ant. It was created by k with the goal of being at least somewhat original.
Requirements
Each cell can be in 1 of 2 states : on or off. Beetle also has 2 external 8-bit variables that acts as input and outputs queues.
Commands
Beetle has the following commands :
Symbol | Description |
---|---|
> | Moves the pointer (beetle) right by one and swap the cell it lands on. |
v | Moves the pointer (beetle) down by one and swap the cell it lands on. |
^ | Moves the pointer (beetle) up by one and swap the cell it lands on. |
< | Moves the pointer (beetle) left by one and swap the cell it lands on. |
{ | If the current cell the beetle is sitting on is off, skip every instruction until corresponding '}'. |
} | Acts as a marker for the corresponding '{'. |
@ | Flips the direction the program is currently being run. |
] | Prevents the next instruction from being ran if the program pointer is going right. |
[ | Prevents the next instruction from being ran if the program pointer is going left. |
, | Breaks from the current loop. |
. | Restarts the current loop. |
( | Starts an unconditional brainfuck-style loop. |
) | Marks the end of a loop. |
' | Gets user input and deposits it into the input queue. |
\ | Allows the next bit from the input queue into the current cell. |
/ | Deposits the current bit at the end of the output queue. |
| | Outputs the output queue and clears it. |
Computational class
Beetle is Turing complete by translation from Boolfuck. Apply these replacements in order to translate any IO-less Boolfuck program to Beetle:
Boolfuck | Beetle |
---|---|
> |
>+
|
< |
<+
|
[ |
{(
|
] |
{.},)}
|
+ |
^v
|
I/O is less directly translatable.
This translation uses two rows of the infinite 2D grid. One row is used for storing data, and the other is used to perform bit flips. Since cells are inverted upon arriving, by going up, then down, we have the effect of inverting the cell we were on. We can use this to undo the inversion with left and right moves. For looping, we use the unconditional loop wrapped with an if block. This allows for the loop to be skipped entirely if the current cell is 0 before entering. If inside the loop, we need to conditionally break. At the end of the loop there is a skip block containing a continue, and a break following it. If the current cell is one, then it will loop back, otherwise it will break from the loop.
Examples
NAND Gate
><{>><{^/|>><<}}
'Hello, World!' Program using 2 cells of memory
{><}/{><}></{><}/{><}/{><}></{><}/{><}/{><}/|{><}/{><}></{><}></{><}/{><}/{><}></{><}/{><}></|{><}/{><}></{><}></{><}/{><}></{><}></{><}/{><}/|{><}/{><}></{><}></{><}/{><}></{><}></{><}/{><}/|{><}/{><}></{><}></{><}/{><}></{><}></{><}></{><}></|{><}/{><}></{><}/{><}></{><}></{><}/{><}/|{><}></{><}/{><}/{><}/{><}/{><}/|{><}/{><}></{><}/{><}></{><}/{><}></{><}></{><}></|{><}/{><}></{><}></{><}/{><}></{><}></{><}></{><}></|{><}/{><}></{><}></{><}></{><}/{><}/{><}></{><}/|{><}/{><}></{><}></{><}/{><}></{><}></{><}/{><}/|{><}/{><}></{><}></{><}/{><}/{><}></{><}/{><}/|{><}/{><}></{><}/{><}/{><}/{><}/{><}></|