esolang

Seclusion

A data pointer that can move in infinitely many directions, and an adder made of the bridge and torch puzzle.

Hakerh400, 2019 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 9 known programs · Test method

Run it

Expected: Hello, World!

The idea

Hakerh400 made Seclusion in 2019 as a Turing tarpit. A Turing machine's tape lets the pointer move one cell at a time. Memory is a tree, and from any node the pointer can take any of infinitely many labelled pointers. Pointer 0 always leads toward the root, and 1, 2, 3 and so on lead to children. The root R and its first neighbour R[0] point at each other through 0.

Read the story

Every node holds a number of any size. The input's length starts in R and its bytes in R[0], R[1], R[2] and on. When the program ends, the output is read back the same way. So the empty program is a cat.

The machine

InstructionDoes
5 (0,0,3)Move along these labels
+Add 1 to the current node
.vPut the xor of v into the node
!vPut v's length into the node and its elements into its 0, 1, 2 ...
?{a;b} :{a;b}Run a if the node is not 0, or odd; else b
-{a}While the node is not 0, subtract 1 and run a
/{a}While the node is odd, drop its last bit and run a
{a}Start a thread at this node
^vJump to the start of an enclosing thread block

Every value is a flat list of numbers. # is the empty list, ~v is the number in the node that v leads to, and %v is the list stored there. To put x into a node writes the distance between x and the node's number, so .~# clears a node.

*v solves the bridge and torch puzzle. The first number is how many people fit on the bridge, the rest are their crossing times. With room for two and a person who takes no time, *(2,0,a,b) is a plus b, and that is how the programs add.

Threads take turns, one instruction each. A | separates two numbers, like a space.

Example

Hello World puts the length and the bytes around the root.

Hello World puts the length and the bytes around the root. The bytes in the specification spell a capital W.

The digits count down in R[0][1] and write 48 xor n into R[n].

Expected: 0123456789

There is no loop, only a thread, an if and a jump. ^# jumps back to the start of the thread's own block, and each pass writes an A over one byte of the input.

Expected: AAA

Two threads share one counter and take turns with it. One writes zeros and the other ones, so they come out alternating. The specification uses 100 and says any number works.

Expected: 1010101010

The program that reverses its input. Its lines are 100 columns wide.

Expected: olleH

The specification also sorts characters, adds two big integers and interprets brainfuck, and all of those work.

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from Seclusion

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run seclusion -e '0|1.~(0,0)
{?{.1(0,0,~#).~#.65|0|0|1^#;}}' --input 'abc'
shib manual seclusion

Source

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

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

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