Gravbox

From Esolang
Jump to: navigation, search

Gravbox is a stack based 2 dimensional esolang with a concept of gravity created by User:Moon. It started as a reversible language (see Billiard_ball_machine)

Note: this language is still something of a work in progress. If I ever try to implement it, I may end up changing some details to make doing so easier.

Gravbox uses one thing, a Ball ('), as the starting point on the program. you can have as many Balls as you want ,they will all move at the same time under the effect of gravity, running the commands they move onto. Gravity can be switched using a switcher (@), going counter-clockwise. the stack always starts with a single 0 and has no bounds on number size

Commands

  • `@`: Switch the direction of gravity counter-clockwise, affecting all balls.
  • `/`: A right pointing deflector, sends the ball to the side.
  • `\`: A left pointing deflector, sends the ball to the side.
  • `!`: invert the value of the first item on the stack, then push it back ( n(-1) )
  • `0-9`: pushes the respective value to the stack.
  • `+`: adds together the first two values on the stack, pushes the result
  • `-`: subtracts the first value from the second value on the stack, pushes the result
  • `*`: multiplies the first two values on the stack and pushes the result
  • `|`: divides the first value from the second value on the stack and pushes the result
  • `,`: pushes input to the stack.
  • `.`: outputs the first value on the stack, and removes it permanently
  • `^`: duplicates a value on the stack.
  • `#`: Wall, stops balls in their tracks until the gravity changes and allows them to slide off
  • `%`: cuts a value from the stack; delete
  • `a-z & A-Z`: pushes their respective letter (With capitalization) to the stack.
  • `?`: Random deflector, randomly acts as either \ or /
  • `&`: / if first value on stack is larger than 0, else \
  • `$`: pushes the amount of values on the stack to the stack.
  • `~`: abort program.
  • `:`: swap the top and bottom of the stack

Sample programs

Hello, World! using ASCII character set

 ‘
 @92+3*dlroW84*92+4*olleH...............~

Trivia

1. By removing + - * | , . % ? & $ a-z/A-Z and 0-9, the language is entirely reversible