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 main idea is that you bounce a marble around a play area using trampolines, as the name implies. The marble can run commands to edit the stack, or print to the console. The interpreter made has a debug option which allows for the user to see the program step by step.
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.
NOTE: Any references to "the stack" will refer to the currently chosen stack.
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 left if being opposed downwards, otherwise it will send it in the opposite direction.
There are also conditional trampolines, which will invert the marble's vertical velocity if the condition is not met.
<
Invert the vertical velocity if the second last item on the stack is not less than the last item on the stack.
>
Invert the vertical velocity if the second last item on the stack is not greater than the last item on the stack.
Note that these are NOT Befunge-style arrows.
The language also has two types of pipes. Pipes can be used to move the marble across a gap or upwards in the script, but cannot contain commands.
=
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 an upwards velocity.
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. |
*
|
Pop the last two items off of the stack, and push the result of multiplying both items. |
%
|
Pop the last two items off of the stack, and push the remainder from dividing both items (where the last item is the divisor). |
+
|
Pop the last two items off of the stack, and push the result of adding both items. |
:
|
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. |
!
|
Pop the last item on the stack and push the inverse of the item. (multiplying it by -1) |
,
|
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. |
@
|
Pop the last two items on the stack, and push the result of concatenating the last item onto the second last item. |
&
|
Pop the last two items on the stack, and push the result of splitting the string at a certain point. (e.g. if the second last value was 81932 and the lsat value was 3, it would return 819) |
#
|
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, and wrap around to the right if possible. |
}
|
Move the stack pointer to the right, and wrap around to the left if possible. |
"
|
The beginning or end of a string. Usually paired with the . command at the left of the string.
|
.
|
Print the string to the right of the command. |
`
|
The beginning or end of a comment. |
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), and the marble does not trigger commands when passing between two 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 # |========================/ #