The Amnesiac From Minsk
A counter machine that forgets what it was doing. Each change to a counter decides the next change, and nothing else is remembered.
ais523, 2015 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 4 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
ais523 designed The Amnesiac From Minsk at the end of 2015, as a series of levels that get harder to program in. It starts from a Minsky machine, counters plus a program, and throws the program away. All that is left is triggers: every counter says what happens after it is incremented, after it is decremented, and after a decrement fails. Each trigger is one change to one counter, which fires that counter's trigger, and so on forever. There is no instruction pointer and no state besides the counters.
Read the story
This implementation runs level 1, the one TIO's hello world uses.
The machine
A counter holds a whole number of 1 or more. Decrementing a counter that is 1 fails and leaves it at 1.
L1 + = -
0: -0; -1; +6; @1
The first line is the header. Each other line is a counter, numbered from 0, with three triggers in the columns + (after an increment), = (after a failed decrement) and - (after a successful decrement), and @ with its starting value. A trigger is + or - and a counter number.
| Rule | |
|---|---|
| Start | Increment counter 0 |
| Halt | An increment whose trigger increments the same counter, or a failed decrement whose trigger tries the same counter again |
| Output | If exactly two counters are never decremented by any trigger, incrementing the first writes a 0 bit and the second a 1 bit, eight bits to a byte |
Example
A is the bits 01000001: a run of one 0, one 1, five 0s and one 1.
A is the bits 01000001: a run of one 0, one 1, five 0s and one 1. Counters 6 and 7 are the output. Counter 0 is a clock: its increment trigger decrements it, which writes a bit, and the output counters decrement it again, which fails and hands over to counter 1. Counter 1 starts at 2, so it can be decremented once and writes one 1 bit, then it fails and hands over to counter 2, which writes five 0s. Counter 5 halts the program, because its increment trigger increments itself.
TIO's hello world works the same way with 54 counters, one per run of equal bits in Hello, World!.
Patterns it teaches
- Counter machines: the Minsky machine with its program removed.
- Turing completeness: any Minsky machine can be built in it, with chains of counters standing in for the states it cannot remember.
- Turing tarpit: every counter's three triggers can each serve only one purpose, which makes even a decrement with two outcomes take a whole construction.
Try this
- Change the example to print
B(01000010). - Print two bytes.
- Hard: build a counter that is incremented three times and then halts the program.
Further
- esolangs.org/wiki/The_Amnesiac_From_Minsk, with levels 2 to 4
See also
Cell-based
Write your own in Run Convert a program from The Amnesiac From Minsk
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: amnesiac-from-minsk.
Command line
shib run amnesiac-from-minsk -e 'L1 + = -
0: +0; +0; +0; @1'shib manual amnesiac-from-minskSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/amnesiac-from-minsk.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org