Mazerunner
Paradigm(s) | imperative |
---|---|
Designed by | User:Error 27 |
Appeared in | 2023 |
Memory system | stack-based |
Dimensions | two-dimensional |
Computational class | Unknown |
Reference implementation | Mazerunner |
Influenced by | Befunge |
File extension(s) | .rat |
Mazerunner is an esolang made by User:Error 27 in 2023. It was made based on the left-hand rule for solving mazes, where a rat traverses the program by always turning left when given the option. Programs are in the form of paths from a start to a goal, and the rat executes instructions as it passes them on the way to the goal. During the program the rat must also be regularly fed in order to keep it alive.
Language overview
Mazerunner programs are on a 2-dimensional grid and form a path from the start to the goal. A rat starts facing north on the start and traverses the path by turning left whenever possible, until it reaches the goal. As the rat passes over an instruction, that instruction is executed. The rat must be fed every 10 steps or it dies, but will also die if overfed. Overfeeding happens when the rat eats 3 pieces of food with less than 4 steps between each. Data is stored in the stack and accumulators A and B. All data values are 8-bit unsigned integers and only count from 0 to 255.
Instruction set
Instruction | Description |
---|---|
+ |
Empty path that does not execute an instruction |
S |
Program starting point |
c |
Cheese that feeds the rat |
C |
Goal that ends the program when reached |
a |
Add 1 to accumulator A |
b |
Add 1 to accumulator B |
A |
Subtract 1 from accumulator A |
B |
Subtract 1 from accumulator B |
z |
Set accumulator A to 0 |
Z |
Set accumulator B to 0 |
T |
Stop the rat from moving left if accumulator B is not 0 |
Y |
Stop the rat from moving left if accumulators A and B are not equal |
P |
Push accumulator A to the stack |
p |
Pop from the stack and output as a number |
r |
Pop from the stack and output as a character |
R |
Pop the whole stack and output as a string |
o |
Pop from the stack and copy to accumulator A |
O |
Pop from the stack and copy to accumulator B |
d |
Pop from the stack and discard the value |
i |
Take in input and push each character to the stack |
^ |
The rat cannot reach this instruction from the north |
> |
The rat cannot reach this instruction from the east |
< |
The rat cannot reach this instruction from the west |
v |
The rat cannot reach this instruction from the south |
Inaccessible text can be considered a comment, although using S
in these comments can cause a start position to be selected in the comment.
Code examples
Hello World!
Prints "HELLO WORLD!" by adding ASCII values to the stack and outputting all of them at the end.
A c A A A ++++c++++c+++P+ + caaaPRC +c++PPAAA+Pc+ A bbbcbbbbbc>+Tacaaaaa z + c + +c++Baaaa + c++++++c+++++++c+++++PAcA A cbbbbb+c>+Tacaaaa+ c z + + c a + c++++Bcaa a a + a a + a a + aPc++PAcAAP++Pc a caaaaaaP+ac a cbbbbbbc>+Tacaaaaa + + c + + caBaaaa + +c++++++z+Pc+ + Sbbb+++++c>+Tacaaaaa + c +c+Baaaaa
Cat
Write the input to the output.
S>ciR+ ++++
Truth machine
Take in input. If the input is 1, output 1 and end the program. Else, output 0 forever.
rC P iORcY+Ac>Pr++ + +++c c Sbbbbbbb+c>+Tacaaaaa + c +c+B++++a