THROBOL

From Esolang
Jump to navigation Jump to search

THROBOL is an esolang by User:BoundedBeans inspired by bowling.

Syntax

It is laid out in a 2d grid, much like Befunge.

Mechanics

Ball

A ball is defined using 'o'. A ball starts moving up. A ball may have a return system written like:

%
|

with the ball directly left of the vertical bar.

Balls have two unbounded non-negative accumulators, power and velocity, a scoreboard, and a pointer to the scoreboard. If the ball does not have a return system, it starts with power 3 and velocity 100, and is deleted once it runs for the first time. A ball with a return system starts with power 2 and velocity 4, and continues doing rounds until both velocity and power are zero.

The pointer always starts at the first scoreboard cell. The ball must run a game before the scoreboard will contain anything, and the second game will always use the first score. Beyond that, the pointer can actually be used. Attempts to move the pointer out of bounds will silently fail, unless the scoreboard contains nothing.

You can have multiple balls for multithreading. They will have different power, momentum, and pointer, but will share the same scoreboard.

Power

Power determines how many pins to each side the ball will score, if they exist, when the ball goes into a tile containing a pin ('A').

Velocity

Velocity determines how many times it can cross a tile with a pin before it no longer scores.

Scoreboard and rounds

The scoreboard contains pairs of unbounded nonnegative integers The ball moves two times each round. The second time, the power is decreased by 1 and the velocity is increased by 1. It then appends the two scores to the scoreboard. The ball then reads the two scores at the pointer, and changes power to the first, and velocity to the second. (If the scoreboard is empty and it is not the first round, the program halts.) It then repeats the process, unless both scores are zero, in which the ball halts.

A ball can run through various commands, allowing things to actually happen.

Commands

> Move the ball right x cells, where x is the velocity of the ball. If there is '|'s along the way, go directly to the left of the nearest. Remember: the ball always moves up; this only changes the column.
< Move the ball left x cells, where x is the velocity of the ball. If there is '|'s along the way, go directly to the right of the nearest. Remember: the ball always moves up; this only changes the column.
. print the power as an unicode character
: print the power as a number
, input an unicode character into the velocity
; input a number into the velocity
- stop the roll if the number of pins it can hit and score for the roll is zero
= stop the roll no matter what
) move the pointer right
( move the pointer left
] move the ball right one column, no matter the velocity
[ move the ball left one column, no matter the velocity
^ increments the power
v decrements the power
n increments the velocity
u decrements the velocity
" forgets the scoreboard entry at the pointer. Normally changes the current cell to be the one originally more recent, but if the current cell is the last, moves the pointer to the previous score.
? discards the round if the power is zero. The scoreboard will not be added to, but any manual deletion of scoreboard entries will remain.

Additional command guidelines

Any custom commands added by an implementation should be taken from extended ASCII or other Unicode, not 7-bit code points. If two commands absolutely need to share the same character, the implementation should look at whether the character below it is 'W' (the escape character, with no particular significance) to decide which command to use. 'W' does not escape commands unless the ball specifically goes over it; it puts the next command into a different "mode". 'W' can also be layered; for example, you could have four commands, ¥, W¥, WW¥ and WWW¥. 'W' should not be used for any other purpose. Custom escaped 'W' commands should not use 7-bit code points as the non-'W' part.

Examples

Print 'A'

=======
 .
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
 ^
     <%
     o|


Computational class

We can initialize the first score to 2 2 with a lane that looks like:


    =
  ] AA
>    |
 %
o|

Then in the next round, the lane will always be in the same column regardless of whether the velocity is 2 or 3, and we can continue the lane upwards.

We can then input a numerical command each round from the console. First we'll check that the velocity is 2 (making sure it's the first roll), and make sure it's two for the next round if it's not.

   =
   A
   A
>   |

We'll then do the actual inputting using ;

Then we check if 1 was inputted (dequeue):


 =
 "
>  |


Then we check if 2 (enqueue 1) or 3 (enqueue 2) was inputted.

  ==
   A
  AA
  AA
  ??
  vv
  vv
>   |


This is the full sequential tag interpreter:


  ==
   A
  AA
  AA
  ??
  vv
  vv
>   |
 [
  [
 =
 "
>  |
   =
 [ A
  [A
>   |
 [
  [
   [
   ;=
  ] AA
>    |
 %
o|

Notes

  • 0 is stored as 2 2, 1 is stored as 3 2.
  • This never uses the commands .,;-()^vnu so these are unnecessary for Turing-completeness. It's likely it could be minimized even more, but I'm not sure how.