Trampolines

From Esolang
Jump to navigation Jump to search
Trampolines
Paradigm(s) imperative
Designed by User:Aadenboy
Appeared in 2022
Memory system Multiple stacks
Dimensions Two dimensional
Computational class Unknown
Major implementations [1]
Influenced by Befunge
Influenced None
File extension(s) .tramp .txt

Trampolines is a physics-based two-dimensional esoteric programming language made by User:Aadenboy. The program is ran with a single "marble", directed through the "course" with a set of pre-defined physics. See below for info on the physics.

Language Overview

A Trampolines program must be formatted correctly in order to run.

  1. The left side of each line must contain the | trampoline.
  2. The right side of each line must contain the # command.
  3. The script must contain one o command.
  4. Each line is uniform in length.

Each step the marble gains 0.5 vertical velocity. Do note that a positive vertical velocity is used to descend, and the opposite for ascending.

The horizontal and vertical velocity is rounded away from zero, and then is used to set the new position of the marble.

The symbol that is on the marble after the marble is repositioned is then ran.


Trampolines and pipes are not commands, and are instead used to redirect the marble.

| - \ /

These are trampolines. | and - invert the marble's horizontal and vertical velocity respectively. \ sets the marble's horizontal and vertical velocity to (1, -1) if it is being approached from either the top or the right. The opposite is true (-1, 1) from the bottom and left. / is similar to \, only that the new values are (-1, -1) from top and left, and (1, 1) from bottom and right.

H =

These are pipes. The H pipe will set the marble's vertical velocity to 0, effectively nullifying any vertical velocity it previously had. If horizontal velocity is zero, it will default to a horizontal velocity of 1. The = pipe acts similarly, but nullified the horizontal velocity rather than vertical velocity, and will set the vertical velocity to 1 if it was 0 before.

Trampolines uses three stacks, with a stack pointer to pick which stack to manipulate.

CMD Description
< Check the last two values of the selected stack, if A < B, allow the marble to pass, otherwise, act as a `-` trampoline.
> Check the last two values of the selected stack, if A > B, allow the marble to pass, otherwise, act as a `-` trampoline.
0-9 Push the corresponding number onto the selected stack.
^ Pop the last value from the selected stack, discarding the value.
~ Duplicate the last item on the selected stack.
? Push a random float from 0.000-1.000 to the selected stack.
$ Pop the last value from the selected stack, and push the result of rounding it.
( Pop the last value from the selected stack, and push the result of flooring it.
) Pop the last value from the selected stack, and push the result of ceiling it.
* Pop two values from the selected stack, A and B, and push the result of A * B.
% Pop two values from the selected stack, A and B, and push the result of A % B.
+ Pop two values from the selected stack, A and B, and push the result of A + B.
: Pop the last value from the selected stack, and print it's corresponding ASCII character.
; Pop the last value from the selected stack, and print it.
! Pop the last value from the selected stack, and push it's negative counterpart.
' Pop the last value from the selected stack, then push it's value divided by 10.
, When stack 1 is selected, push the user's input as a number.
When stack 2 is selected, push the user's input as an ASCII value.
Stack 3 causes a warning to print when this is ran.
_ Swap the last two items on the selected stack.
@ Pop two values from the selected stack, A and B, and push the result of concatenating B to A.
& Pop two values from the selected stack, A and B, and push the result of the left-half of splitting A at B. (e.g if A was 182 and B was 2, the value 18 would be pushed)
# End the program.
[ Move the last item from the selected stack to the previous stack. (stack 3 precedes stack 1)
] Move the last item from the selected stack to the next stack. (stack 1 follows stack 3)
{ Select the previous stack. (stack 3 precedes stack 1)
} Select the next stack. (stack 1 follows stack 3)
" Declares a string, assuming it is closed.
. Prints any string that exists to the right.
` Declares a comment, assuming it is closed.

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#
|=  ^-  /#
|  <     #
|   ;    #
|    #####

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   #
|========================/  #

Number Guessing Game

note: the answer is accurate up to the thousandths, you must guess less than 0.01 away from the chosen number

|o `just initializing stuffs`                     #
|?                                                #
|1                                                #
|0                                                #
|@                                                #
|0                                                #
|@                                                #
|*                                                #
|?                                                #
|+                                                #
|1                                                #
|!                                                #
|+                                                #
|1                                                #
|?                                                #
|$                                                #
|!                                                #
|2                                                #
|*                                                #
|+                                                #
|*  `actual game`                                \#
|H===============================================H#
|1                                               H#
|0                                               H#
|@                                               H#
|:                                               H#
|                          #                     H#
|, 1'   +]   {~   '+   =  ."You win!"            H#
|]~  ' !  } ^  1 '  ] }  >                       H#
|\    -    <    -    -    ."Guess lower!"        H#
|           ."Guess higher!"                     H#
|            ===============================^ =^ H#
|                                            -  {H#
|   `I honestly thought this would be harder`    H#
|   `lol`                                        -#