esolang

BrainCube

Brainfuck with a cube of cells instead of a tape, as many pointers as you name, and real blocks.

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

Tested with 2 known programs · Test method

Run it

Expected: Hi

The idea

BrainCube came out in 2017 as a brainfuck derivative. The tape becomes a cube, so a pointer moves left and right, up and down, and into and out of the cube. There is no single pointer either. A program declares its own with ~name~, and every command says which pointer it works with.

Read the story

Brainfuck's one loop becomes three blocks. An if, a while, and a repeat that runs a fixed number of times, counted from a cell or written as a number.

The machine

Pointer commandDoes
> < ^ vMove right, left, up, down
X OMove into the cube, back out of it
+ -Change the cell by 1; cells wrap at 256
. ' :Print the cell as a character, in binary, in decimal
, " ;Read a character, a binary line, a decimal line
StatementDoes
~p~Declare the pointer p
p(+>)Run pointer commands with p
(p){...}Run once if p's cell is not 0
(p)[...]Repeat while it is not 0
(p)(...) (12)(...)Repeat as many times as the cell held, or 12 times
!Stop

? asks for a garbage collection and # is a breakpoint; neither does anything. Comments are written /* like this */. The specification gives the cube no size, so this implementation gives it no edges.

Example

Repeat 72 times, print H, repeat 33 more times, print i.

Repeat 72 times, print H, repeat 33 more times, print i.

Expected: 42
Expected: 101
Expected: cube

The Hello World program first fills the 256 cells of one row with 0 to 255. Then for each letter it walks right as many cells as the letter's code, prints and walks back.

Patterns it teaches

  • Turing tarpit: brainfuck's machine, given more room and more hands.

Further

BrainCube builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from BrainCube

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run braincube -e '~my_ptr~'
shib manual braincube

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/braincube.js

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

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