esolang

2DFuck

Brainfuck on an endless grid of bits, with one command that runs a step of the Game of Life.

TheWastl · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hi

The idea

TheWastl made 2DFuck as another two-dimensional relative of brainfuck. The memory is a grid of bits that goes on in every direction, and the pointer moves up and down as well as left and right. There is no + or -. All work goes through a one-bit accumulator. r reads the bit under the pointer into it, x XORs it into the bit, and ! flips it. Loops test the accumulator, not the cell.

Read the story

Input and output come one bit at a time, eight to a byte. And l treats the whole grid as Conway's Game of Life and runs one generation.

The machine

CommandDoes
^ v < >Move the pointer up, down, left, right
rAccumulator = bit
xBit = bit XOR accumulator
!Flip the accumulator
.Write the accumulator as an output bit
,Read an input bit into the accumulator (0 at the end)
[If the accumulator is 0, jump past the matching ]
]If the accumulator is 1, jump back to the matching [
lOne generation of the Game of Life on the grid

Bits go most significant first. Every other character is a comment.

Example

The first writes 01001000 01101001 with only the accumulator.
Expected: 0

The first writes 01001000 01101001 with only the accumulator. . writes it, ! flips it. The second is a truth machine. It stores the eight bits of the input in a row and prints them back. The last bit of 0 is 0, so the loop never starts; for 1 it would print forever.

Patterns it teaches

Further

2DFuck builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from 2DFuck

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: 2dfuck.

Command line

shib run 2dfuck -e '!x>x>x<l^r.vr.vr.!.....'
shib manual 2dfuck

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/2dfuck.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org