Trampolines
Paradigm(s) | imperative |
---|---|
Designed by | User:Aadenboy |
Appeared in | 2022 |
Memory system | Multiple stacks |
Dimensions | Two dimensional |
Computational class | Turing complete |
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 May 16th, 2024 (10:48 AM GMT-8)
A Trampolines program must be formatted correctly in order to run.
- The left side of each line must contain the
|
trampoline. - The right side of each line must contain the
#
command. - The script must contain one
o
command. - 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.
An error will occur if there is nothing left to pop from the stack, i.e when running ~
on an empty stack, or running +
on a stack with only one value.
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 reciprocal (1/x). |
,
|
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). When stack 3 is selected, push the user's input as it's individual UTF8 values to the stack in reverse order. 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: , AWAITING CHAR INPUT: and AWAITING 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
Infinite Loop
|o# | # | # |-#
| o # | # | # | \ / #
|o\# |\ #
Hello World!
|o # |."Hello World!"# |# #
FizzBuzz
| \# | H====================H# | - H# |o. H H# |1 15 0 ."FizzBuzz"H# |=H~ @ % > H# | \ - | H# | H========= H# | H H# | ^ 3% H H# | ^~ 0 ."Fizz" H# | \ > H# | | H# | H===== H# | H H# | ^ 5% H H# | ^~ 0 ."Buzz" H# | \ > H# | | H# | H===== H=======/ H# | ^ ^ H# | ^ ^ H# | ~ H# | ; H# | H========/ =========H# | H +1 0H # H -# | H1 0 @ @> ^- # | \ - \ - #
Truth Machine
|o / # |, ~; # |0 H==H# |= ^- /# | < # | ; # | #####
Cat Program
|o # |{ # |1 # |! \ # |,H===H # |=H H # | 1 ^:H # | !> H # | \ # - #
99 bottles of beer
|oH= # |9. . # |9 =/ # |@ ." bottles of beer on the wall." # |=H H ;~ # | ~ - + # | ; =/ # | ." bottles of beer on the wall," # | . H # | ~ H # | ; \= # | ." bottles of beer." # | . =/ # | ."Take one down, pass it around," # | . 1! H # | =3 ^ - # | < # | H # | ."1 bottle of beer on the wall." # | . # | . # | ."1 bottle of beer on the wall," # | . # | ."1 bottle of beer." # | . # | ."Take one down, pass it around," # | . # | ."No bottles of beer on the wall."# | # #
Exponent Calculator
Note: This example does not support non-integer exponents.
|o # |,"Value: " # |. # |$ # |,"Exponent: " # |. # |$ =H."Result: 1" # |0< # # |\ > # | # | HH # | H^ }^ # | H[ { # | H]H==================/ # | H1 ~[ {1 H =H==} # | H=H} { * ! +0< H."Result: "# | H \ - - \ > H ; # | H ====/ # # | H # | ^ }^ # | [ { # | ]H==================/ # | 1 ~[ *{ H =H==} # | =H} { ' 1 +0< H."Result: " # | \ - - \ > H ; # | ====/ # #
Deadfish Implementation
| \ # | H============H # | ^ H # | ^ H # | } H # | 1 H^^ H # | !< 0 H # | \ > H H # | H==H H H # | ^ / H H # | 2 H H # | 5 H H # | @ H H # | 6 H^^ H H # |o@< 0H H # |0\ > H H # |{H==H H H # |1^ / H H # |!H======H H # |,{ / H # |=H H # | 1 ^ H # | !> H H # | \ # H # | 1 H # | 0 H # | @ H # | 5 H}1 H # | @< + H # | \ > { H # | H==H -H # | ^ / H # | 1 H # | 0 H # | @ H\ # | 0 H}1 HH # | @< ! -H # | \ > + H # | H==H { H # | ^ / -H # | 1 /H # | 1 HH # | @ H- # | 5 H}~ H # | @< * H # | \ > { H # | H==H -H # | ^ / H # | 1 H # | 1 H # | @ H # | 1 H}~ H # | @< ; H # | \ > { H # | H==H -H # | ^ / H # | 1 H # | 0 H # | @ H # | 4 H# H # | @< H # | \ > H # | H==H H # | ~ / H # | H========H # | \ - #