Ball Pit

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.
Ball Pit
Paradigm(s) imperative
Designed by User:Aadenboy
Appeared in 2025
Memory system Multiple stacks
Dimensions Two dimensional
Computational class Turing complete
Reference implementation Unimplemented
Influenced by Trampolines, Befunge
Influenced None
File extension(s) .bp, bpit

Ball Pit is an extension of Trampolines that allows for there to be multiple marbles within a single program.

Language overview

A Ball Pit program, much like Trampolines, 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 at least one o command.
  4. Each line is uniform in length. (Note: trailing spaces are not allowed.)

Each step, every marble gains 0.5 vertical velocity. Positive vertical velocity is descent, and the opposite for negative vertical velocity.

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

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

Marble collisions

Marbles are able to collide with one another much like trampoline characters, however the rules are dependent on both the position and velocity of the marbles. Collisions happen before commands are executed.

Before moving the marbles, find all marbles that coexist on the same space. For each marble in these groups, add up the initial velocities of all the other marbles, setting the new velocity to the result clamped to [-1, 1]. Next, find all marbles whose paths intersect or is opposite of another. Repeat the process for each marble in these groups.

After the velocities have been updated, move the marbles.


New trampolines

Pipes now disallow collisions based on their orientation. Vertical pipes H only allow vertical collisions, and horizontal pipes = only allow horizontal collisions. A new bi-way pipe X disables both horizontal and vertical collisions, allowing pipes to cross.

The flip-flop switch, represented with T redirects marbles left and right. On every odd-numbered use, marbles are sent to the left (-1, 0). On every odd-numbered use, marbles are sent to the right (1, 0).

Potholes, represented with Q, will trap any marble that moves into it until another marble pushes it out to take its place. The variant C will not trap the second marble.

W can be used to create a new, fresh marble after another marble moves off of it.

Memory

Each marble has its own independent set of three stacks. Commands usually operate on each marble independently even if multiple execute the command at once.

New commands

CMD Description
a Check if the marble has any values left in its selected stack, and act as a - trampoline if it does.
p Pop the last value from the selected stack, and set the marble's priority to its value.
t Pop the last value from the selected stack of whichever marble has the highest priority (picking at random if there's a tie), then push the value to the selected stack of whichever marble is next in line.
d Like t, but the value is distributed to all the other marbles instead.
...

}}