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
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 command | Does |
|---|---|
> < ^ v | Move right, left, up, down |
X O | Move 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 |
| Statement | Does |
|---|---|
~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.
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
See also
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 braincubeSource
- 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