esolang

Lost

The pointer starts on a random cell, moving in a random direction. A program has to find it and lead it home.

Wheat Wizard, 2017 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 4 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: Hello, World!

The idea

Wheat Wizard made Lost in 2017, with the instruction set of his Klein. The twist is the start. Instead of the top left corner, the pointer appears anywhere on the grid going any way. A deterministic program has to work for every one of those starts.

Read the story

Two things make that possible. Streams of arrows catch the pointer and carry it to the real start. And a safety: @ only ends the run once % has turned the safety off, so a pointer that wanders onto @ early just passes over it.

The machine

The grid wraps like a torus. There is a stack and a scope, both with endless zeros at the bottom.

CharDoes
> < v ^Arrows
\ / \|Mirrors
[ ]Doors: reflect an eastbound or a westbound pointer, and flip to the other door when crossed sideways
! ?Skip the next cell; pop and skip it if not 0
: $ ( )Dup, swap, top to the scope, back from the scope
0-9 "Push a digit, toggle string mode
+ * -Add, multiply, negate
% #Safety off, safety on
@End, if the safety is off, and print the stack as text

Example

From the tutorial in the specification.

From the tutorial in the specification. The top row is a stream that carries any pointer to the start of the second. %? throws away whatever junk was picked up on the way, until it reaches the zeros at the bottom. The string holds vU instead of ! so no start inside it can get stuck, and -+ turns vU back into !.

Jo King's 38-byte Hello World, which bends the stream through three mirrors.

Expected: Hello, World!

Both print the same thing from every one of their starts.

Patterns it teaches

Further

Nondeterministic

Self-modifying

Write your own in Run Convert a program from Lost

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run lost -e 'roW"\\ dl
<@+1(\
lo, /"Hel
%<<<\?<<<'
shib manual lost

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/lost.js

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

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