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

This language was last updated on Jan 30, 2024 (12:13 PM GMT-8)

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. (Note: trailing spaces are not allowed.)

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 horizontal velocity to 0, effectively nullifying any horizontal velocity it previously had. If vertical velocity is zero, it will default to a vertical velocity of -1. The = pipe acts similarly, but nullifies the vertical velocity rather than horizontal velocity, and will set the horizontal 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 write it's corresponding UTF8 character.
; Pop the last value from the selected stack, and write 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 it's UTF8 value (base 10).
Stack 3 causes a warning to print when this is ran.
You can optionally place a string to the right of the command to have a custom prompt message. By default, it says AWAITING NUMBER INPUT:  and AWAITING CHAR INPUT: .
_ 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.
. Writes any string that exists to the immediate right. If there is none, write a newline.
` 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 #
|\----------- .                                  H #
|           |  ."Take one down, pass it around, "H #
|           |   1 =! =+ =2 =^ =~                 H #
|           |-------------<---===================H #
|                          =|                    - #
|    H======================                       #
|    H                                             #
|    ."1 bottle of beer on the wall."              #
|    .                        `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   #
|========================/  #

Exponent Calculator

note: powers below 2 will be assumed as 2, i.e 3^1 and 3^0 will result in 9 (3^2)

|o                 #
|,                 #
|,                 #
|]                 #
|~ ^===========_   #
|[{~]   }1   2_ | ;#
|H{  } *  ! +  > { #
|\    -    -    -  #
|###################