esolang

Alan's dead fish

Deadfish that never stops on its own, with a jump that works only every other time.

Bogdan192848, 2024 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 3 2 1 0

The idea

Bogdan192848 made Alan's dead fish in 2024 as a first esolang, based on Deadfish. It keeps the four commands i d s o, adds g to read a number and ! to jump, and loops back to the start whenever it runs off the end. So h is the only way out.

Read the story

The jump is the strange part. A ! jumps forward to the next ! when the accumulator is not 0, but only if a switch is on. A ! that does not jump flips the switch. The specification puts it as the even numbered ! not being run. Its interpreter is a Scratch script, and this implementation follows it step by step.

The machine

CommandDoes
i dAdd 1 to the accumulator; take 1 away
sSquare it
oOutput it
gSet it to a number read from the input
!Jump to the next ! if it is not 0 and the switch is on; else flip the switch
hHalt

The accumulator starts at 0 and the switch on. There is no wrapping at 256 or -1 as in Deadfish. The script collects its outputs in a list, and this implementation prints each one on its own line. Scratch compares letters in either case, so I works as well as i.

Example

The countdown reads a number and counts down to 0.

The countdown reads a number and counts down to 0. The first ! only flips the switch, since the accumulator is still 0. Later the ! after d jumps over oh until the count reaches 0.

The truth machine. On 0 it prints 0 and halts; on 1 it prints 1 forever.

Expected: 0

Patterns it teaches

Further

Alan's dead fish builds on Deadfish~.

Deadfish derivatives

Write your own in Run Convert a program from Alan's dead fish

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: alan-s-dead-fish.

Command line

shib run alan-s-dead-fish -e '!g!od!oh!' --input '3'
shib manual alan-s-dead-fish

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/alan-s-dead-fish.js

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

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