esolang

BrainPi

Every program is pi, recited with mistakes. The mistakes are the program.

None1, 2024 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 3.1415926

The idea

None1 made BrainPi on Pi Day 2024, 14 March, as a twin of Goldfuck with pi in place of the golden ratio. A program looks like 3.14159... and only the places where it gets a digit wrong carry information. Reading after the point, a right digit stands for ! and a wrong one for # in !!Fuck, which spells each brainfuck command as a run of ! closed by a #. So most of a BrainPi program is pi itself.

The machine

Right digits before a wrong oneCommand
0 to 4nothing
5 6 7 8> < + -
9 10, .
11 12[ ]

After decoding it is brainfuck on a million byte cells. The specification's Python interpreter decodes the whole program before running it, so right digits after the last wrong one stop the program before it starts. That interpreter also fails when it reads past the end of the input, and so does this implementation.

Example

The program for the first 7 digits of pi has 559 digits after the point.

The program for the first 7 digits of pi has 559 digits after the point. Its mistakes decode to +++++++[>+++++++<-]>++.-----.+++.+++.---.++++.++++.-------.++++., which counts up to 51, the code of 3.

The cat has 67 digits after the point and six mistakes, which decode to ,.[,.]. It echoes the input and then stops with an error at its end.

Expected: abc

The specification also has a Hello World of 547 digits that prints hello world, a truth machine and a 781 digit program that prints Nope..

Further

Ideas it shows

BrainPi builds on Brainfuck.

Brainfuck equivalents

Brainfuck derivatives

Write your own in Run Convert a program from BrainPi

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run brainpi -e '3.1415926532897932384676433832795008841971698993751058259749445923079' --input 'abc'
shib manual brainpi

Source

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

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

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