Trampolines

From Esolang
Jump to navigation Jump to search
Trampolines
Paradigm(s) imperative
Designed by User:Aadenboy
Appeared in 2022
Memory system Cell-based
Dimensions two dimensional
Computational class Unknown
Major implementations V1, V2, V3
Influenced by Befunge
Influenced None
File extension(s) .tramp .txt

Trampolines is a two-dimensional esoteric programming language made by User:Aadenboy. It involves basic physics and comes with a handful of ways to move a marble around. The marble can run commands to edit the stack, or print to the console. The interpreter made had a debug option which allows for the user to see the program going step by step in real time.

Language Overview

A basic program requires a starting point marked with a o command, and the left and right sides having a | trampoline, and a # command.

The programming language has three usable stacks, which can be moved to interchangibly.

The language does not have Befunge-style arrows, instead it has trampolines and pipes.

Trampolines will bounce the marble in the opposing direction they're facing.

All of these are considered trampolines.

|

This will invert the horizontal velocity of the ball.

-

This will invert the vertical velocity of the ball.

\

This will send the marble upwards to the right if being opposed downwards, otherwise it will send it in the opposite direction.

/

This will send the marble upwards to the right if being opposed downwards, otherwise it will send it in the opposite direction.

There is also conditional trampolines that act the same as a - trampoline, only if the second last item and the last item on the stack is not greater/

<
>

Note that these are NOT Befunge-style arrows.

The language also has two types of pipes.

=

By default this pipe will move the marble right unless being opposed by a leftwards velocity.

H

By default this pipe will move the marble down unless being opposed by a upwards velocity.

Any references to "the stack" will refer to the currently chosen stack.

Stack-based commands are commands that edit the stack. If an operation does not have access to the right amount of items (such as a + command not having two stack items), the program will error.

Cmd Description
0-9 Push the corresponding number onto the stack.
^ This is NOT a Befunge-style arrow. Pop the last value from the stack.
~ Duplicate the last item on the stack.
* Multiply the last two items on the stack (last item goes on the right).
% Perform modulus on the last two items on the stack (last item goes on the right).
+ Add the last two items on the stack (last item goes on the right).
: Pop the last item on the stack and print it as an ASCII character.
; Pop the last item on the stack and print it as a number.
! Multiply the last item on the stack by -1. Because there is no subtraction command available (due to the minus symbol being taken by a trampoline), you can use this to subtract.
, If the current selected stack is Stack 1, get input from the user as a number. If the current selected stack is Stack 2, get input from the user as an ASCII character. If the current selected stack is Stack 3, do nothing.
_ Swap the last two items on the stack.
@ Concatenate the last two items on the stack (the last item gets put to the right of the second last item).
& Split the second last item on the stack at the character chosen by the last item in the stack into two items. (Negative numbers are treated as the right side of the number.)
# End the program
[ Transfer the last item on the stack to the previous stack (wrapping around to the right if possible).
] Transfer the last item on the stack to the following stack (wrapping around to the left if possible).
{ Move the stack pointer to the left.
} Move the stack pointer to the right.

There is also a . command which prints the string next to it. If it has no string to print, it will print a newline.

Marble Physics

From now on, the marble's horizontal and vertical velocity will be referred to as it's X and Y velocities.

When the program starts, the marble starts off with 0 X and Y velocity.

Until the program ends, the program runs in this order.

First: check for any tiles directly on the marble. If it is not a command, and not a string, run the command.

Then: Change the marble's X and Y positions according to it's X and Y velocities. Since it would be impossible for the marble to be between two or more characters at once, the velocities are rounded away from zero before adding onto it.

Last: Increase the Y velocity of the marble by 0.5, maxing out at 1. Since text starts at the top line, and ends at the bottom line, the marble has to go to the next line, instead of the previous (done with an increasing Y position).

The marble is unable to run more than one command at once (there would need to be two characters occupying the same space, which is impossible), so the marble does not trigger commands when passing through them diagonally.

Example Programs

Hello World!

|o              #
|."Hello World!"#
|#              #

FizzBuzz

|o H===            1= ^================= ###
|1 .   -=============-===3   55   1!  H|# ##
|  +   H   H         H|H| 5 *  + *  + H|##/#
| ==~ 3=% 0=  ."Fizz"H|H|------------>-/####
|\----------->-------^|H|###################
|             H  = ^=^|H|#   #   #   #   ###
|   ~=============-===|H|# #### #### ### ###
|  H     H   H   ^^  -/H|#  ### ## ### #####
|   ==5 %=0  =."Buzz"==H|# ###   #   #   ###
|--\------->-----------H| 00  0 0 000 000 ##
|H==========|==  =^ =^ H| 0 0 0 0   0   0 ##
|^ 3%      -/H-->------H| 00  0 0 0   0   ##
|^~  0 ======H   ^ =^ \=/ 000 00  000 000 ##
|\------------------\~ ;|###################
|###################| =H|###################
|###################\---/###################

Truth Machine

|o          #
|,          #
|0     ;    #
|\---->-----#
|      H    #
|      ^    #
|      H H  #
|      ~;~  #
|      \ /  #

99 bottles of beer song

|o                                                #
|9                                        ~       #
|9H========================================/      #
|@." bottles of beer on the wall."        H;      #
| .                                       -       #
|                                            -    #
|                                               =/#
|     ." bottles of beer on the wall, "         H #
|~=~ ;  ; ." bottles of beer. "                 H #
|\----------- ."Take one down, pass it around, "H #
|           |  1 =! =+ =2 =^ =~                 H #
|           |------------<---===================H #
|                         H                     - #
|    H====================H                       #
|    H                    /                       #
|    ."1 bottle of beer on the wall."             #
|    9                                            #
|    1                        [Last lyrics :)]    #
|    +                                            #
|    :                                            #
|    ."1 bottle of beer on the wall, "            #
|    ."1 bottle of beer. "                        #
|    ."Take one down, pass it around. "           #
|    ."No more bottles of beer on the wall."      #
|    #                                            #

Basic Calculator

|o                          #
|."Calculator!"             #
|H=======================   #
|                      #H ^ #
|.                     #H  /#
|."Input operation 1-4"#H   #
|,5    #               #H   #
|\<<<<<#               #H   #
|      H               #H   #
|H======|              #H   #
|.     -               #H   #
|^    !+   !+   !+  #  #H   #
| =3 1    1    1    #  #H   #
|\-->---->---->---->#  #H   #
|    H    H    H    H  #H   #
|    ,    ,    ,    ,  #H   #
|    ,    ,    ,    ,  #H   #
|    _    _    _    _  #H   #
|    ~    ~    ~    ~  #H   #
|    ;    ;    ;    ;  #H   #
|    ." % "    ." + "  #H   #
|    _    _    _   -_  #H   #
|    ~    ~    ~   H~  #H   #
|    ;         ;    /  #H   #
|    ." = "    ." = "  #H   #
|H   %         +       #H   #
|H   ;         ; -   H #H   #
|H   /         \ H  \  #H   #
|         ." * "       #H   #
|         ;        /   #H   #
|         ." = " ." - "#H   #
|         *      ;     #H   #
|         ;      !     #H   #
|                +     #H   #
|                ." = "#H   #
|                ;     #H   #
|========================/  #