From Esolang
Jump to navigation Jump to search

MarioLANG is a two-dimensional esoteric programming language made by User:Wh1teWolf, based on Super Mario. The source code's layout is similar to a Super Mario world, however the programs written in MarioLANG look like a completely normal application when compiled. It is even Turing-complete! This language was inspired by RubE On Conveyor Belts.

There is no official interpreter for MarioLANG and neither is a detailed specification on the exact behavior of items and instructions. However, User:myname made an interpreter mostly based on his own interpretation of unclear behaviors in Ruby [1]. There is also an interpreter written in C++ by User:T.J.S.1 which, besides just interpreting it like a normal interpreter does, can also simulate the evaluation of the code in a graphical animation using ANSI colours in the terminal. It can be found here.


Source code is comprised of parts, items, and instructions.


The world is built up by four different pieces:

  • = : Ground. If Mario has no ground below his feet he falls until he lands on either ground or EOF.
  • | : Wall
    • These two are essentially equivalent, as both the ground and the wall act as solid blocks from the top as well as the sides.
  • # : Elevator starting point (can be both the highest or the lowest point on the elevator, however this is where Mario jumps onto the elevator.)
  • " : Elevator ending (can not be right or left from the starting position)
    • When there are multiple elevators on the same X axis, the elevator always moves Mario to the exit immediately above the entrance.


When Mario finds one of the following items he executes its corresponding command.

  • ) : Move memory pointer right
  • ( : Move memory pointer left
  • + : Add one to the memory cell under the pointer
  • - : Subtract one from the memory cell under the pointer
  • . : Output ascii character from current memory cell
  • : : Output numeric value from current memory cell
  • , : Input ascii character to current memory cell
  • ; : Input numeric value to current memory cell

Instructions to Mario

  • > : Go right
  • < : Go left
  • ^ : Jump. Mario can only jump 1 block, and stops walking while jumping.
  • ! : Stop walking
  • [ : Skip next command if current memory cell is zero
  • @ : Start walking the other way

Anything not recognized as a command is a comment.


Commands Explained

++++:       >       >  +:+:+:+:+:+:+:::::
====+      >^===    """=================
    +:-):(:^=   =                       !
    =========    =                      #
                  = !             .+.,:-<
                   =###           ======"

Output: 4 6 0 5 6 7 8 9 10 11 12 12 12 12 12 11

After this the user is asked to input a letter and the program outputs it and the next letter in the alphabet.

Now I am going to try to explain how the example level works:

++++:  This code outputs '4'.

This gets done because there is floor underneath. When Mario reaches the ':', he executes it before he starts falling.


Here Mario falls down and hits the '+'s on his way, making cell0 6. When he hits the floor he immediately starts walking to the right again and hits a ':' and outputs. Next item is a '-' decreasing the value of the current cell. The ')' moves to the next memory cell (cell1). ':(:' should be obvious by now.


As Mario hits the '^' he jumps up and hits the '>' making him go right while in the air, and landing on the '=' one step up, hitting the other '^' and repeating the procedure once more, landing on the top.


Here he goes down the stairs, ending up on the '=' at the bottom.

 >  +:+:+:+:+:+:+:::::
 !             .+.,:-<
=###           ======"

When Mario hits the '!' he stops walking, but now he is on an elevator. Now he is lifted up to the '"'s, hitting a '>' making him walk right. After he has gone over to the solid ground he meets some '+'s and some ':'s doing some plusing and some output. When he goes over the edge he falls down to elevator and stops. The elevator takes him down to the bottom where he starts walking left. The current cell is subtracted and outputted, then the user is asked to input a character by the ',' command. Output this character and the next in the alphabet.

Fibonacci sequence

 :+:)+:     <
   >        !

Truth machine


The ; causes Mario to read 1 numeric value, which : causes him to directly output. The extra > after that will make it possible to loop infinitely.

The [ checks if that value is zero.

If the value is zero, the following < is skipped, causing Mario to continue until the ! halts him. (You may omit that and stop the program by making Mario fall off a ledge, but that's unethical.)

If it is nonzero, the following < causes him to turn around. After that, the > and < repeatedly cause Mario to run into the same :, causing him to output the value indefinitely.

Cat program

!. -<

The , gets one ascii character as input and saves it to memory. Then we check if it is EOF (-1) by increasing the memory cell by one, checking if its zero, then if its not decreasing the cell by one (because the < will take mario towards the -). But that < won't activate if the cell is zero because of the [, and mario failed.