esolang

Deadfish TM

A Turing machine whose state is a Deadfish accumulator, changed by Deadfish code on every step.

BoundedBeans, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello world!

The idea

BoundedBeans made Deadfish TM in 2022, after Deadfish PDA. The state of the machine is a number from 0 to 255, and each transition changes it with a line of Deadfish. i adds one, d takes one away and s squares. If the state ever leaves 0 to 255, the machine halts. A tape that is endless both ways holds symbols, which are any printable characters except whitespace and #.

Read the story

The specification argues it is Turing complete. Five states and the symbols !abcd are already enough to run any Turing machine on a suitable input.

The machine

The first line is the default transition. After it come pairs of lines, a case and its transition.

PartForm
CaseStates and symbols, as 8 J, 17-29 N{>q or 81,155 AB
TransitionDeadfish code, the symbol to write, L or R, and a halt code
CodeDoes
i d sIncrement, decrement or square the state
o aPrint the state as a number or as a character
cRead a character into the cell
#Nothing

The halt code is 0 to go on, 1 to halt, 2 to print the tape and halt, 3 to print it and go on. The first line of input goes on the tape from cell 0 and every other cell holds !. Each step takes the first case that matches the state and the symbol under the head, or else the default.

Example

Hello world walks left over blank cells.

Hello world walks left over blank cells. Each case matches the state the step before left behind, and its code moves the state to the next letter and prints it.

The truth machine. On 0 it prints the state, which is 0, and halts. On 1 it climbs to 49, the code of 1, and prints it with a on every step for ever.

Expected: 0

The unary adder adds two numbers of 1s with a 0 between them. It moves each 1 of the second number over the 0 and prints the tape at the end. The specification does not say how much of the endless tape to print; it is the stretch from the first to the last cell that is not !.

Expected: 11110

Patterns it teaches

  • Turing completeness: a Turing machine written down almost directly, with 256 states and thousands of symbols.

Further

Cell-based

Write your own in Run Convert a program from Deadfish TM

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: deadfish-tm.

Command line

shib run deadfish-tm -e '# ! L 1
0 0
o 0 L 1
0 1
iisiiiisddddddddddddddd 1 L 0
49 !
a ! L 0' --input '0'
shib manual deadfish-tm

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/deadfish-tm.js

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

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