esolang

Uzumaki

Every program is a square, and the code runs round it in one spiral towards the middle.

Zero player rodent, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, World!

The idea

Zero player rodent made Uzumaki in 2022, after Junji Ito's horror manga of the same name. A program has to be exactly as wide as it is tall. The instruction pointer starts in the top-left corner, runs clockwise round the edge and curls inward, one cell apart from the layer outside it, until it reaches the middle. There the program ends.

Read the story

The only way to steer is to jump between layers. B jumps inward and H outward, and J and K skip one cell. A loop is a jump back out to a layer the pointer has already passed.

The machine

Memory is a queue of whole numbers that starts as one 0, and an accumulator that starts at 0.

CommandDoes
Q S GEnqueue 0, an input byte, or a number read from a line
I D P MAdd 1, take 1, add 10, take 10 from the front
X Z RDequeue; enqueue a copy of the front; reverse the queue
A VCopy the front into the accumulator; add the accumulator to the front
O C EPrint the front as a number or a character; print the whole queue
#text#Print the text between the marks
J KSkip the next cell if the front equals the accumulator, or if it does not
B HJump inward or outward and run the cell it lands on
WJump outward to layer 1

Inward is a right turn from the way the pointer moves, outward a left turn. A jump passes over the gaps between layers, where comments may stand, to the next cell of the spiral. Any other character on the spiral is an error, a space too.

Example

Hello, World! in a square of 5 by 5.

Hello, World! in a square of 5 by 5. Along the spiral it reads #Hello, World!#DD.

The truth machine reads a number with G and prints it with O. On 1 the B in the bottom row jumps up over the empty middle to the O in the top row, which prints again, forever. On 0 the J skips the B.

Expected: 0

The reverse cat keeps 10 in the accumulator, enqueues bytes until one equals it, and then prints the queue backwards.

Expected: desserts

The Collatz program, on 6. It prints every number after the first, down to 1.

Expected: 3 10 5 16 8 4 2 1

The specification also has a Fibonacci printer and a 99 bottles of beer in a square of 18, which are included too.

Patterns it teaches

Further

Queue-based

Two-dimensional languages

Write your own in Run Convert a program from Uzumaki

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: uzumaki.

Command line

shib run uzumaki -e 'XGOR
   R
R  R
RRBJ' --input '0'
shib manual uzumaki

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/uzumaki.js

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

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