Degration
A brainfuck whose program sits on the tape it works on, and the tape slowly rots.
Bertrahm · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Bertrahm made Degration as a brainfuck-like language with two twists. The program is stored as bytes at the start of the tape, right before the data, so the program can walk back and change its own code. And every 8th instruction, 1/16 of everything on the tape is changed at random, the program included. The specification says its alphabet program "atleast tries to" print the alphabet.
Read the story
This implementation leaves the decay out. The tape changes only by the program's own commands, so a run always gives the same result and the programs can be checked.
The machine
| Command | Byte | Does |
|---|---|---|
P+ P- | 1 2 | Move the data pointer |
V+ V- | 3 4 | Add or take 1 from the cell |
[ | 5 | Start a loop |
n] | 6 | End the loop when the cell holds n, else go back |
* | 7 | Print the cell |
? | 8 | Store a line of input from the cell on |
! | 9 | Exit |
The data pointer starts on the first cell after the program. A loop body always runs at least once, because the test is at the closing bracket. Its number is stored as the byte after the 6.
Example
The alphabet.
The alphabet. The first loop counts the cell up to 65, the second prints and counts on until the cell holds 90. That ends the loop before Z is printed.
A program that changes itself. The loop says 64, which would print @. Before it runs, the program moves three cells back into its own code, adds 1 to the byte that holds 64 and comes back, so it prints A.
Patterns it teaches
- Self-modifying code, as code and data share one tape.
- Nondeterminism, as the real language's tape decays at random.
Further
See also
Degration builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Degration
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: degration.
Command line
shib run degration -e '[V+65][*V+90]!'shib manual degrationSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/degration.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org