The Maze

From Esolang
Jump to navigation Jump to search

The Maze is a programming language made in 2022 by User:LEOMOK. It is a 2D esolang inspired by Maze, Mice in a maze and Gerbil.

Concept and commands

There are three kinds of instruction pointers - mice, dogs and cats. When two mice of opposite genders meet, two turns later, a male baby and a female baby will be born. Dogs and cats do not reproduce or grow, but any one of them that does not eat a mouse for five turns will die. Any creature that dies will leave its dead body. If a tile has a dead body, it will not be executed until the body is removed.

The physics is the same as Mice in a maze.

Each creature has its own floating-point stack, but there is also a global stack.


Commands

When I say 'the stack', I mean the local stack. All commands push error code and kill creature on error. Creatures to be placed

   M -  places a newborn male mouse
   F -  places a newborn female mouse
   P -  places a dog
   C -  places a cat

Types of walls/obstacles

   W, X, Y, Z -  Blocks everything, mice only, dogs only and cats only respectively.
   w, x, y, z -  Same as above, but only blocks creatures with a nonzero value on top of their stack.
   H, V - Blocks all creatures coming horizontally and vertically respectively.
   h, v - Same as above, but only blocks if top of stack is nonzero.
   ` - When passed through, becomes a wall. Forever. (Who uses that key anyway?)

Movement

   ( - move clockwise
   ) - move counterclockwise
   K - poison that kills anything stepping over it.
   k - this poison only kills mice.
   <, >, ^, ~ - forces creature to move right/left/forward/backward.
   \ - Reflect.
   & - Random direction.
   @ - Skip next instruction.
   # - clears all dead bodies adjacent to this tile. 
   | - Pop x and y, teleport to (x, y).

Literals

   12.4 -  Any consecutive string of digits and decimal point is pushed to the stack as a floating-point number
   ' -  Pushes the unicode of the next character.
   " -  String mode. Pushes the unicode of every character until the next ", reversed for easy printing.

Operators

   + - Pop a, b, push b+a.
   - - Pop a, b, push b-a.
   * - Pop a, b, push b*a.
   , - Pop a, b, push b/a (float division).
   % - Pop a, b, push b%a (remainder). 
   : - Pop a, b, push b to the power of a.
   ; - Pop a, b, push log base b of a.
   _ - Pop a, push -a. 
   ! - Pop a, b, push 1 if 0 and 0 otherwise.
   = - Pop a, b, push 1 if b=a, 0 otherwise.
   [ - Pop a, b, push 1 if b<a, 0 otherwise.
   ] - Pop a, b, push 1 if b>a, 0 otherwise.
   { - Pop a, b, push null-terminated string representation of a in base b.
   } - Pop string s and integer b, parse s to floating-point number in base b.
   ? - Push random floating-point number from 0 to 1.

Input and output

   I - input character and push. -1 on EOF.
   i - input number and push. 0 on EOF.
   O - output character and pop.
   o - output number and pop.

Stack operations

   D - duplicate top of stack.
   d - Pop x, y, push x y times. (default 2)
   S - swap top two items.
   s - Pop x, reverse top x items (default the whole stack)
   G - Pop and discard.
   g - Pop x, discard the top x items (default the whole stack again)
   U - Over. Duplicate the second stack item.
   u - Pop x, duplicate the nth stack item. (default the bottom)
   R - Rotate top three items clockwise (x, y, z -- y, z, x)
   r - Rotate top three items counterclockwise (x, y, z -- z, x, y)
   L - Push the length of the stack.
   l - Clear the stack.
   T - Move top value down.
   t - Move bottom value up.
   N - Pop from the local stack to be pushed to the global stack.
   n - Pop from the global stack to be pushed to the local stack.
   Q - Stops the next command from popping the stack.
   q - Stops commands from popping the stack until another q is found.

Others

   A - Put. Pop x, y, z, set command at (x, y) to z.
   a - Get. Pop x, y, push value of command at (x, y). Empty cells are equal to 0.
   

Examples

Hello World!

   WWWWWWWWWWWWWWWWWWWWWW
   WM0"Hello World!"`OwKW 
   WWWWWWWWWWWWWWWWWWWWWW

Fibonacci (Warning - infinite loop!)

   WWWWWWWWWWWW
   WM1 0`Q+Do~W
   WWWWWW WWW W
   WWWWWW     W
   WWWWWWWWWWWW