BooleanFunge
A fungeoid where every turn leaves a boolean on the stack.
TenBillionPlusOne, 2023 · Turing complete: no · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
TenBillionPlusOne made BooleanFunge in 2023. The only data are booleans on one stack, and the commands that steer the pointer are the ones that push them. Going right pushes true, going left pushes false and going down pushes a random one. Going up pops two. So the route a program takes is also the data it builds, and a character to print has to be laid out as a path of eight pushes.
Read the story
Two commands rewrite themselves. A ^ that finds fewer than two values turns into < or >, and a & that finds fewer than eight turns into $. The specification reckons it is a push-down automaton, since its one stack can only be pushed and popped.
The machine
| Command | Does |
|---|---|
> | Go right and push true |
< | Go left and push false |
v | Go down and push a random boolean |
^ | Go up and pop two; with one value become >, with none become < |
# | Pop, then turn right if true and left if false |
& | Pop eight and print them as a character; with fewer become $ |
$ | Read a character and push its eight bits |
@ | End, if any value on the stack is true |
The grid wraps at its edges, and the pointer starts at the top left going right. $ pushes the highest bit first, so the lowest ends on top, and & reads the top as the lowest bit.
Example
The One Time Cat reads a character, prints it, pushes a true and ends.
The One Time Cat reads a character, prints it, pushes a true and ends.
This one prints a question mark, 00111111 in bits. The first < pushes false and sends the pointer left, round the edge to three more <. The ^ pops two of the four falses and goes up, round the edge to the second row, where six > push the six trues. Then & prints, and >@ ends.
The specification warns that its example programs may not work. In this implementation its truth machine prints the character with code 0 and ends when the input has an even code, and on an odd code it prints nothing in a million steps. Its Write H program ends without printing.
Patterns it teaches
- Two-dimensional control flow: the route is the data.
- Self-modifying code:
^and&rewrite their own cells. - Nondeterminism:
vpushes a random boolean. It comes from a fixed sequence, so a run replays.
Further
See also
Probabilistic
Nondeterministic
Write your own in Run Convert a program from BooleanFunge
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: booleanfunge.
Command line
shib run booleanfunge -e '$&>@' --input 'A'shib manual booleanfungeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/booleanfunge.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org