OGEL

OGEL stands for Open Grid Execution Language (the fact that, backwards, it happens to spell the name of a certain famous manufacturer of coloured blocks (LEGO®) is a complete coincidence). It was designed by GreyKnight in August of 2006.

Elements of an OGEL program
An OGEL program consists of a grid-like arena, each cell of which can contain a stack of coloured blocks. Processors wander this grid, climbing up certain stacks and executing their contents as code.

The regular blocks are coloured black(K), red(R), yellow(Y), green(G), blue(B), and white(W). There is also a glass(s) block used as a separator.

Each processor has an associated stack somewhere on the arena on which it can keep data. Processors can also be instructed to address one other stack on the arena and manipulate it, although the commands for doing so are not quite as numerous. These "processor stacks" are not protected specially, and can be executed and manipulated just like any other.

Stacks as data
When reading an addressed stack, or a processor stack, the contents are interpreted as integers or the special nil value in the following manner. First, the number of glass (s) blocks which separate a number from the previous one is examined. If it is an odd number, a positive (or zero) number is being described; if an even number, a negative number (or nil) is present. The first item on a stack can optionally leave out its leading s blocks and start directly on a colour, in which case the value is assumed to be positive. Values are specified in base-6, with the following digits:

If you specify a negative number and a value of zero, the item will be interpreted as "nil". This is used as the boolean false value, and often used to signal errors. Any non-nil value (including 0) is boolean true.

For instance, a stack containing the values (1, 2, 12, -12, nil, 27) could be represented:

RsYsYKssYKssKsBG

The "top" of the stack
Values that are popped from a stack are taken from the bottom, and pushed values also appear on the bottom. Note that this is upside-down from the usual visualization of a stack. Unless otherwise specified, in this article the phrase "top of the stack" will refer to the point where push/popping takes place; that is, its physical bottom.

Processors
Each processor, upon arriving in an arena cell, will begin executing any stack found there from the bottom up; if there is no stack, it will idle in the cell until given further instructions. Upon reaching the top of the stack, or exiting it by some other means, it will pop an x and y offset from its processor stack and move by that amount to a new cell. If either value popped is nil then the processor will not move anywhere, but idle in the current cell. If an offset of <0, 0> was popped, the current stack is executed again from the bottom.

Niceness
Processors can have different "niceness" values (a priority), in which the lowest-niceness processor gets the highest share of actual execution time. Specifically, the niceness indicates the number of clock ticks the processor waits between steps. A niceness of 0 means that the processor executes a step every tick. All processors created at the start of the execution have the default niceness of 8.

Instructions
Instructions are sequences of coloured blocks separated by s blocks. The number of s blocks used to separate one instruction from the next is not normally significant (exceptions are noted below). Any value not recognized as a valid instruction will be treated as a "no-operation" instruction; however, when you wish to explicitly insert a no-op, you should use the instruction reserved for this use: (5)WWWWWK

Notation
Instructions are separated into tiers by the number of W blocks in their prefix. For clarity, the sequence WWWWK could be written as (4)WWWWK, or even shortened to (4)WK or (4)K. This is easier to read than long strings of Ws.

System Calls
For use with (5)WWWWWB. If too few arguments are specified, the remaining are set to nil. If too many, the excess are thrown away. On error, the call returns its usual number of arguments, but all set to nil.

Arguments after ';' in the argument lists shown below have default values and can be unspecified if you wish; unless otherwise stated, the default is 'nil'.

Resources

 * Original OGEL specification notes