Mepytaruon

From Esolang
Jump to navigation Jump to search
Mepytaruon
Paradigm(s) imperative
Designed by User:Ardemit
Appeared in 2022
Memory system Cell-based
Dimensions two-dimensional
Computational class Turing complete
Major implementations Original
Influenced by brainfuck
File extension(s) .png

Mepytaruon is a non-textual turing tarpit programming "language" based on the Multicolor Tile Puzzle from the 2015 game Undertale. The name comes from smashing together the names of two characters from Undertale, who have employed the original puzzle, Papyrus and Mettaton.

Language overview

To ensure turing completeness, Mepytaruon took inspiration from brainfuck's instructions. Instructions in Mepytaruon are written as tiles of different colors in a png image, with each tile having specific rules for Instruction pointer (IP) movement. Additionaly, where applicable, the magnitude of a three-dimensional vector of the RGB components of the tile's color may specify a variant of the base tile. Execution starts at [0, 1] (indexed from the top-left), with the IP attempting to move to the right, but the starting point may be moved and direction changed if an interpreter supports it. Every time the IP moves (doesn't matter if it moves on its own, or is moved by another tile), the tile it steps on gets activated.

The IP can have two flavors, LEMON and ORANGE (the fruit). Flavor acts like a flag.

Like brainfuck, Mepytaruon operates with an array of memory cells, each initially set to zero. Each cell is a 16-bit signed integer. The standard number of cells is 30 000, but interpreters can include an option to specify a different count. The memory pointer (from here on simply referred to as "pointer") is initially pointing to the first cell.

Base color Tile name Movement rule General action Number of variants
#FFC0C0 Pink No effect NOP 1
#9CFF79 Green No effect Manipulates ptr 4
#FF4040 Red Can't enter Exits when attempting to enter 1
#FFFF80 Yellow Bounces the IP back to the tile it came from Changes dir 9
#FFC14A Orange Changes flavor to ORANGE if val is 0 Outputs val 4
#C000C0 Purple "Slides" the IP in the direction it entered Manipulates val 5
#4040FF Blue If next to a yellow tile or the flavor is ORANGE, acts as a yellow tile movement-wise. Acts like a pink tile otherwise. If the flavor is ORANGE, changes movement direction like a yellow tile 9
#FFFFFF White No effect Outputs contents of all memory cells 1

More in-depth description of the individual tiles is provided below.

To make this document easier to read, constant values and instruction pseudocode will be written in capital letters (RIGHT, DOWN, OUTPUT).

Abbreviations:
ptr    – Pointer
val    – Value in a memory cell selected by the pointer
dir    – The absolute direction IP attempts to move in
stdin  – Standard input
stdout – Standard output

Variants

Every tile has a different number of "shades" or variants, as seen in the "Number of variants" column in the table above, which change the tile's behavior slightly. For example, purple tiles manipulate values in cells, but one variant increments the value, while another sets it to zero.

Colors of different variants aren't fixed to the values listed below, those are only the standard colors. The exact method of calculating a variant number from the magnitude of a tile's color can be found in the source code of the original interpreter. The equations aren't listed here, because a lot of rounding and integer division takes place and thus makes making a single mathematical equation quite hard.

Directions

There are four directions in which the IP can move. Up, right, down and left. These directions are indexed clockwise as shown in the table below. The reason for two naming schemes is to distinguish when a direction is set and when the IP rotates (e.g. when "turning" REVERSE, the original absolute RIGHT becomes absolute LEFT).

Ordinal Absolute direction Relative direction
0 UP IDENTITY
1 RIGHT RIGHT
2 DOWN REVERSE
3 LEFT LEFT

In-depth look at tiles

Here, I will describe every type of tile and their variations in more depth.

Pink tile

Variant Color Action
0 #FFC0C0 NOP

The pink tile doesn't do anything and doesn't affect movement.

Green tiles

Variant Color Action
0 #9CFF79 NOP
1 #88DF69 ptr=0
2 #619F4B ptr++
3 #3A5F2D ptr--

Green tiles don't affect movement and manipulate ptr when stepped on.

Red tile

Variant Color Action
0 #FF4040 EXIT

A red tile acts like a wall, and as such, cannot be stepped on. When the IP collides with it (attempts to step on it), the program ends.

Yellow tiles

Variant Color Action
0 #FFFF80 dir=UP
1 #F0F078 dir=RIGHT
2 #D4D46A dir=DOWN
3 #B8B85C dir=LEFT
4 #9B9B4E ROTATE dir BY IDENTITY
5 #7F7F40 ROTATE dir BY RIGHT
6 #636331 ROTATE dir BY REVERSE
7 #464623 ROTATE dir BY LEFT
8 #2A2A15 dir=val

Variants 0-3 set dir to an absolute direction; variants 4-7 apply a rotation to dir; variant 8 sets dir to val. For val larger than 3, variant 8 takes the remainder after dividing val by 4 (e.g. 7 % 4 = 3).

Walking onto a yellow tile "bounces" the IP back onto the tile it's come from (triggering the source tile again).

Orange tiles

Variant Color Action
0 #FFC14A NOP
1 #DFA840 OUTPUT val AS Int
2 #9F782E OUTPUT val AS Hex
3 #5F481B OUTPUT val AS Char

The orange tile acts as an output tile. Variant 1 outputs val as an integer; variant 2 does the same, but in hexadecimal format; variant 3 converts val to a character, which then gets outputted.

Additionally, all orange tiles set the flavor to ORANGE if val is equal to zero (but don't reset it otherwise).

Purple tiles

Variant Color Action
0 #C000C0 NOP
1 #AC00AC val=0
2 #860086 val++
3 #600060 val--
4 #390039 val=stdin

Purple tiles manipulate val. Variant 4 requests an integer from stdin and halts until it receives it. Purple tiles act like "ice" tiles. They continue moving the IP in the direction they've been entered, ignoring dir.

Additionally, they set flavor to LEMON.

Blue tiles

Variant Color Action
0 #4040FF dir=UP
1 #3C3CF0 dir=RIGHT
2 #3535D4 dir=DOWN
3 #2E2EB8 dir=LEFT
4 #27279B ROTATE dir BY IDENTITY
5 #20207F ROTATE dir BY RIGHT
6 #181863 ROTATE dir BY REVERSE
7 #111146 ROTATE dir BY LEFT
8 #0A0A2A dir=val

Blue tiles are functionally the most complicated. The table above is (except for the colors) the same as the one for yellow tiles, but the actions may not be triggered based on these rules:

  1. If the flavor is ORANGE, act exactly like a yellow tile.
  2. If you neighbour a yellow tile, bounce the IP back like a yellow tile.
  3. If the flavor is LEMON, and you don't have any neighbouring yellows, act like a pink tile.

This means that blue tiles only manipulate dir when the flavor is ORANGE.

White tile

Variant Color Action
0 #FFFFFF DEBUG

The white tile is a debug tile. It has no special movement rules. When stepped on it outputs the contents of all the memory cells and ptr to stdout if debug mode is enabled in the interpreter.

Examples

Hello, World!

This program prints out the words Hello World!. It is algorithmically the same as brainfuck's Hello, world!.

Enlarged view

{{{2}}}

Actual size

{{{2}}}

Print 26

A simpler program that outputs 26. It has all the different tile variants on the bottom (that are not executed).

Enlarged view

{{{2}}}

Actual size

{{{2}}}

External resources

The original interpreter written in Kotlin can be found here