Broken Gdy Brainfuck
Gdy Brainfuck that may break down at any step. In practice it always breaks at the same one.
2023 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Broken Gdy Brainfuck is Gdy Brainfuck from 2023 with the ability to generate random errors and force termination. Before every step the specification's C++ interpreter draws a random number, and about one time in 270 it clears the screen, turns it red, prints <?> a thousand times and stops. It also gains a line of input.
Read the story
The interpreter never seeds its random numbers. On Windows, where it runs, rand() then starts from 1 on every run, and the first hit always falls on step 638. Programs up to 637 steps never break, and every longer one breaks at exactly that point.
The machine
| Command | Does |
|---|---|
a b | Add or take 1 |
A B | Move right or left |
cX | Add the character X to the buffer |
d C | Print the buffer; empty the buffer and the line |
h D | Read a line of input; print it |
e | Print the cell as a number |
f F g | Put the sum, product or difference of the left cell and this one in the cell to the right |
Nothing runs before the text gbf2 and a line feed, and the letters of that header run too. The cells are 32-bit floats. i and I are listed in the specification, but in the interpreter they make a variable that is gone at once, so they do nothing. There are no loops.
Example
The hey program asks a name with d, reads it with h and greets it with D.
The hey program asks a name with d, reads it with h and greets it with D.
As in Gdy Brainfuck, the 1+1=2 comes out right because b and f in the header leave -1 in the first two cells.
The header and 631 a and one e make 637 steps and print 630. One more a and the run stops at the e with 3,000 characters of <?>.
Patterns it teaches
- Hostile design, as the language takes the run away from you.
- Nondeterminism, random by design and fixed by an unseeded generator.
See also
Broken Gdy Brainfuck builds on Brainfuck.
Nondeterministic
Brainfuck derivatives
Write your own in Run Convert a program from Broken Gdy Brainfuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: broken-gdy-brainfuck.
Command line
shib run broken-gdy-brainfuck -e 'gbf2
c1c+c1c=dC
aaAaafAe'shib manual broken-gdy-brainfuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/broken-gdy-brainfuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org