RubE On Conveyor Belts

From Esolang
(Redirected from RubE on Conveyor Belts)
Jump to navigation Jump to search

RubE On Conveyor Belts (abbreviated to ROCB in this article and pronounced "Roob-Ee On Conveyor Belts", a bad pun on "Ruby on Rails") is a language created in 2007 by immibis, and based on Chris Pressey's RUBE.

C++ interpreter source code (for Windows)

Overview

A program in ROCB consists of a two-dimensional grid, on which are placed program parts.

=?=*==
|    F
=>>>>=
 (cat program in ROCB)

Every tick, each part on the grid is evaluated. What the part does depends on the type of part. The cat program, for example, reads a number from standard input and drops it (the question mark) on the conveyor belt (the arrows), then it passes under the scanner (the asterisk) and into the furnace (the capital F). The equal signs and vertical bar are walls.

File format

Header
Control program (optional)
Main program

The header is a single line of one of the following formats

WIDTH HEIGHT
cWIDTH HEIGHT CONTROL-LENGTH

If the second form is used, a control program is expected to be present, and of the specified length. Note that if there is no control program and there is no 'c' in the header line, you do not leave a blank line in its place.

The control program

The control is a variant of Brainfuck, with some extra commands to control If not specified, the default control

+[dsti[o[-]]+]

is used.

CommandDescription
+-<>[]Same as in Brainfuck.
dUpdate the display
sSleep for one tick, use this to avoid running too fast.
i or ,Set the current cell to be the character that was input, or 0 if nothing was input.
Does not block waiting for input.
oIf the current cell contains the ASCII code for a digit, send that digit to the main program. Otherwise, do nothing.
OIf the current cell contains a number between 0 and 9, send it to the main program. Otherwise, do nothing.
tRun one tick in the main program. You MUST use this somewhere in the control, or the main program will do nothing.
aChange the current state number of the main program to the contents of the cell under the pointer, modulo 10.

The main program

Note that parts are case-sensitive. Anything not in this table acts as a wall - it stops bulldozers and data that run into it and can be used to support bulldozers and data.

PartDescription
0-9Single digit of data
bMulti-digit data. This is produced only by arithmetic operations. If there is a b in the initial state of the program, it will be equivalent to a 0
aState control. There must be a single digit or multi-digit number on top of this, and when the current state number (set by the control program) is not equal to the digit on top, barriers appear on the left, right, and bottom.
[]Bulldozers - push data about. [ moves right and ] moves left.
TTurning point - makes bulldozers turn if you put one above the bulldozer's path. The bulldozer will never reach the space directly underneath the turning point. The bulldozer takes an extra tick to turn.
FFurnace - destroys data that touches it
*Scanner - when data passes directly under it, it is written to the output file.
?Input - when the o or O command is used in the control program, that digit appears beneath all inputs in the main program.
AUpward pipe - sucks data upwards
VDownward pipe - sucks data downwards
iUpward copier
!Downward copier
^Upward bulldozer pipe - sucks bulldozers upwards. There is no downward bulldozer pipe.
WDownward swinch - sucks one piece of data downwards then becomes an upward swinch
MUpward swinch - sucks one piece of data upwards then becomes a downward swinch
<Left conveyor
>Right conveyor
OSorting device. If there is data above and below the device, then if the data above is greater, it moves to the right. Otherwise, it moves to the left. If there is no data above or no data below, nothing happens.
rRandom data - if it is on a copier, it stays random and the copier makes random digits, otherwise it changes into a random single digit when the program starts.
+Adder - if there is data below and to the left, and data directly below, it adds them together, and places the result below and to the right. The source data is destroyed.
-Subtracter - works like the adder
DDoor - if one side is occupied and the other is empty, a barrier appears on the empty side.
sSeparator - when a multi-digit number is placed directly below a separator, the individual digits appear to the right and the source data is destroyed, if there is sufficient space. If not, nothing happens and the source data remains intact.
\Ramp - if data goes on top, it is pushed to the right. Bulldozers can move up ramps, and so can data if pushed by a conveyor belt or bulldozer.
/Ramp - if data goes on top, it is pushed to the left.

Order of evaluation in the main program

Every part in the main program performs its action, in the following categories - lower category numbers perform their actions first, and from left to right, bottom to top, within a category.

  1. input, output, splitter, state control
  2. door key, furnace, random crate
  3. up pipe, down pipe
  4. gravity, copiers, winches
  5. dozers, conveyors
  6. gate, adder, subtracter

The order of evaluation matters because if you have something like:

 A   
[4  F
=====

then if the dozer is evaluated first, it will push the 4 to the right, but if the pipe is evaluated first, it will suck the 4 upwards.

Interpreter source code