Down the Mountain

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

Down the Mountain is an esolang made by Joaozin003, in which the code is a mountain for a ski to slide down.

Syntax

There is no syntax. Indentation doesn't matter. For example, if your program looks like this:

S
x y
y.x.

or this:

Sxyy.x.

it won't matter. Just remember that the former is recommended since the code is laid out in a full binary tree[1].

Pre-execution steps

Before the code is run, these steps are performed:

  1. Remove all whitespace;
  2. Pad .s until the code has characters, where n is any integer.

Commands

All commands not listed here act as lifts.

Ski movement

By default, the ski always moves left.

S: Where the ski starts. If there are more than one of this command or 0 of this command, the program raises an exception.
#: Is used to block the current path of the ski, making it move the other way. If there are walls in both directions, the program halts.
_: If the current memory cell is 0, move right, otherwise move left. If there is a wall after this command, it is interpreted as a '.'.
^: Jump back to the beginning of the program, moving in the current direction.

Memory

The memory is a tape which is infinite in both directions. Memory cells are unbounded signed integers.

These commands interact with memory or the pointer in some way other than I/O.

+: Increments current memory cell.
-: Decrements current memory cell.
>: Moves the pointer right 1 cell.
<: Moves the pointer left 1 cell.
0: Sets current memory cell to 0.

I/O

All exceptions are output in STDERR, not STDOUT.

i: Takes a character from input and stores its codepoint in the current memory cell.
o: Outputs the current memory cell as a character. If the character is out of bounds for Unicode, then immediately halt and raise an exception.

Lifts

All commands not specified above are lifts.

When the ski reaches a lift, these steps happen:

  • Is there another lift with the same character?
    • If yes, then pick randomly from one of those lifts and go to that lift.
    • If no, then continue sliding.

Examples (TODO)

Non-terminating cat program

Sio#^^#

Ungolfed:

S
i o
#^^#

Computational class

While not proven yet, it may be possible to write a brainfuck interpreter (and probably is), making this language Turing-complete.

External resources