esolang

Mazerunner

A rat solves the maze with its left hand on the wall. The instructions are what it steps on.

Error 27, 2023 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 8 known programs · Test method

Run it

Expected: maze

The idea

Error 27 made Mazerunner in 2023, after Befunge and the left-hand rule for solving mazes. A program is a path drawn on a grid from the start S to the goal C. The rat starts on S facing north. At every cell it turns left if it can, else goes straight, else turns right, else turns back. Each instruction it steps on runs.

Read the story

The rat also has to eat. It starves after 10 moves without cheese, and three meals fewer than 4 moves apart kill it as well. So every stretch of path needs a c in the right place.

The machine

CellDoes
S CStart; the goal, which ends the program
+Path with nothing on it
cCheese, which feeds the rat
a b A BAdd 1 to A or B; subtract 1
z ZSet A or B to 0
TNo left turn while B is not 0
YNo left turn while A and B differ
P o O dPush A; pop into A or into B; pop
p r RPop and print a number or a character; print the whole stack
iPush a line of input, its first character on top
^ > < vOne way, with no entry from the north, east, west or south

A space is a wall. The values are bytes, 0 to 255. T and Y are the only branches, and all they do is take away the turn to the left.

Example

A cat that ends.

A cat that ends. The rat cannot go north or west from S, so it turns right, reads a line, prints it and reaches the goal.

The compact truth machine from the specification. The column of b is a dead end, so the rat walks it up and back down and B ends at 8. Each time round the loop B takes 1 from B, and while B is not 0 T sends the rat on past seven a. Seven rounds make 49 in A, the code of 1. Then O pops the first input character into B, and Y lets the rat turn left only when A and B are equal. That way leads past P and r, which print 1, to the goal. On 0 the rat goes on into a loop that prints 0 forever.

Expected: 1

BrainFuckGirl's Hello, world! from the specification. It pushes the letters from the last to the first, and R at the end prints the stack from the top.

Expected: Hello, world!

The decimal input reads digits and leaves one number on the stack, which p prints. When the digits run out, O pops an empty stack and gets 0, and that ends its loop.

Expected: 42

Patterns it teaches

Further

Two-dimensional languages

Stack-based

Write your own in Run Convert a program from Mazerunner

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run mazerunner -e 'SiRC' --input 'maze'
shib manual mazerunner

Source

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

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

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