Matrixfuck

From Esolang
Jump to navigation Jump to search

Matrixfuck is a superset of brainfuck made by User:Heptor, with the only change being the memory and tape is a 2-dimensional array.

Syntax

Instruction Description
> Move the pointer forward.
< Move the pointer backward.
* Rotate the pointer 180 degrees.
% Rotate the reader 180 degrees.
+ Increment cell at the pointer.
- Decrement cell at the pointer.
. Output the pointed cell's value as ASCII.
, Get a character as input, and set the cell at the pointer to its ASCII value.
[ Jump the reader forward to the matching ] if the cell pointed to is 0. If there is no matching ], throw an error.
] Jump the reader back to the matching [ if the cell pointed to is not 0. If there is no matching [, throw an error.
} Turn the pointer 45 degrees clockwise.
{ Turn the pointer 45 degrees counter-clockwise.
) Turn the reader 45 degrees clockwise.
( Turn the reader 45 degrees counter-clockwise.
= Reflect the pointer's rotation across the X axis.
: Reflect the pointer's rotation across the Y axis.
_ Reflect the reader's rotation across the X axis.
| Reflect the reader's rotation across the Y axis.

All other characters are no-ops.

Notes

  • The reader and pointer start facing right at the top-left.
  • Going out of the bounds of the memory board wraps the pointer on the board.
  • Matching brackets can go around turns, and will not turn the pointer. For example:
+++++[) 
      (-]
        ]

will run like this (pointer highlighted in gray):

  • The bounds of the program field are set by the amount of rows and columns in the program.
  • Going out of the bounds of the code ends the program.

Computational class

Being an extension to brainfuck, the language is Turing complete.

Implementation notes

  • Memory bounds are square.
  • Memory cells per axis are to be kept relatively low, as you'll need the square of that in bits. Just 256 per axis is more than double the amount of bits of normal brainfuck!
  • Searching ahead for a ] when the pointer value is 0 with a [, or searching behind for a [ when the pointer value isn't 0 with a ], does respect rotation and reflection.

Implementations

[Interpreter written in python]