Mice in a maze
Mice in a maze is another brainfuck derivative. It was invented in 2015 by an anonymous user. Mice in a maze was inspired by items called Cellular Automata, especially Conway's Game of Life and Langton's Ant.
In Mice in a maze, there is a data tape and pointer as in brainfuck. The user defines a maze and places commands around the maze. The user then puts a mouse - or mice - in the maze. As a mouse runs over a command, the command is executed.
Defining a maze
There are two types of wall that can be used to define a maze. W defines a solid wall. K defines a conditional wall, where the wall does not exist if the cell under the pointer is zero, and exists otherwise. These two symbols define a maze such as the one below:
WWWWWWWWW W W W WWW W WWW W W W W WWWWW W W W WWWWWWWWW
The empty spaces are the passageways that the mice can run along.
Mice are defined by placing numbers in the maze. 1 is the first mouse, 2 is the second, etc. Each mouse begins pointing upwards. The program progresses in timesteps called generations. Every generation the mouse can either:
- Move one space forward, if the space ahead is empty.
- Rotate 90 degrees clockwise, if the space ahead contains an existing wall.
- Disappear, if the space that it is on contains the instruction E.
The program ends when all of the mice disappear.
Instructions are placed inside the maze. An instruction is executed when a mouse is on top of it. If multiple mice are on top of instructions during a generation, the lowest numbered mouse's instruction is executed first, then the next lowest numbered, etc. Here is a list of the instructions:
- > move pointer right
- < move pointer left
- + increment the value of the current cell
- - decrement the value of the current cell
- . output the character in the current cell
- , input a character into the current cell
- E destroy mouse
- C forces mouse to rotate clockwise as next move
- A forces mouse to rotate anticlockwise as next move
The first six instructions are the same as in brainfuck. Loops can be implemented by creating a circle in the maze and using conditional walls.
This maze doesn't do anything, it's just an example.
WWWWWWWWW W1 CWC EW WWW W WWW WA CWC AW W WWWWW W WA 2 AW WWWWWWWWW
If anybody comes up with any example programs, feel free to post them here.
This Hello World! program from TomPN.
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW W>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.EW WWWWWWWWWWWWKWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW W1++++++++++ >+++++++>++++ W WWWWWWWWWWWW WWWWWWWWWWWWW+W W -<<<+++>+++++ W WWWWWWWWWWWWWWWWW
Making use of the feature that mice.py automatically surround the source code with W so the mice cannot escape, infinite loop can be done in 2 bytes. (Note the leading whitespace)
- HUNTER, which also involves mice in a maze