Conveyor

From Esolang
Jump to: navigation, search

Conveyor is a concept language based on multiple workers each with two conveyor belts, two stacks, a collector, and a hand. There is a turn system in who gets turns in what order.

Example (3 thinkers):

  • Initialization: Creates all the necessary objects and allocates required memory.
    • Manager: Prepares the assembly line and starts it all up.
      • Conveyor: Shifts the objects through the assembly line.
      • Supervisor: Prepares for the next worker by clearing out the stacks, and dumping whatever is in the hand.
      • Worker 1: Alters the objects currently stored on their section of the conveyor.
      • Supervisor: Prepares for the next worker...
      • Worker 2: Alters the objects currently stored...
      • Supervisor...
      • Worker 3...
      • Jumper: If the halt command was not given, loops back to the conveyor.
    • Manager: Finalizes the process.
  • End: Frees the memory allocated and ends the program.


Commands

POPA - Picks an object off the top of stack A.
POPB - Picks an object off the top of stack B.
PSHA - Places an object on the top of stack A.
PSHB - Places an object on the top of stack B.
CLNA - Cleans out stack A.
CLNB - Cleans out stack B.
DUMP - Throws away whatever is held (places it into a void).
DUPA - Duplicates the held item and places the copy on stack A.
DUPB - Duplicates the held item and places the copy on stack B.
PUTA - Places an object on conveyor A.
PUTB - Places an object on conveyor B.
GETA - Picks up an object from conveyor A.
GETB - Picks up an object from conveyor B.
ENDT - End turn.
HALT - (Supervisor+) Signals the jumper not to jump.
FAIL - (Manager+, Start only) Signals the program to exit without starting the assembly line.
SWAP - Swaps stack A and B.
SUBA - Pops from stack A, and subtracts the result from the hand.
SUBB - Pops from stack B, and subtracts the result from the hand.
MULA - Pops from stack A, and multiplies the result with the hand.
MULB - Pops from stack B, and multiplies the result with the hand.
DIVA - Pops from stack A, and divides (integer) the hand by the result.
DIVB - Pops from stack B, and divides (integer) the hand by the result.
MODA - Pops from stack A, and modulo's the hand by the result.
MODB - Pops from stack B, and modulo's the hand by the result.
SIFT - Pops from stack A, and searches for the result in stack B.
       If it is found, the value popped from stack A is added to the hand.
QUIT - The worker quits its job and is replaced with a null worker.
FIRE - (Supervisor+) The last turn's worker is replaced with a null worker.
RAIS - (Supervisor+) The next QUIT called by the previous turn's worker is ignored.
STME - Seeds the random number generator with the time.
SEED - Pops stack A and seeds the random number generator with the result.
RAND - Pops stack A and generates a random integer modulo the popped value and adds it to the hand.
CERR - Pops stack A and sends the result modulo 256 as an unsigned char to std::cerr.
INCR - Increment what I have in my hand.
DECR - Decrement what I have in my hand.
INC5 - Increment what I have in my hand by 5.
DEC5 - Decrement what I have in my hand by 5.
IFEZ - If I am holding a zero or not holding any object...
IFGT - Pops stacks A and B. If the result from A is greater than the result from B...
ELSE - Should be self-explanatory.
ENDF - End If.

Specifications

All commands end in a newline and have no arguments. Any characters after the 4-character command but before the newline are treated as comments. Putting something down (or picking something up) clears the source and adds to the destination. Or, in assembly:

ADD dest,src
MOV src,0

Examples

Add the objects from conveyors A and B (a + b), and put the result on both A and B.

GETA
GETB
DUPA
PUTA
POPA
PUTB
ENDT - Oh yay our turn is finished.

Add and subtract the objects from conveyors A and B (a + b, a - b), and put the results in A and B respectively.

GETA
DUPA
PSHA
GETB
DUPB
POPA
PUTA
POPA
SUBB
PUTB
ENDT - We're done, right?

Copy the object from conveyor A and overwrite (not add) it onto conveyor B.

GETA
DUPA
PUTA
GETB
DUMP
POPA
PUTB
ENDT - Your turn, now!

Apply the ROT13 transformation to each conveyor individually (not exactly rot13, I don't feel like writing a bunch of if's right now).

GETA
INC5
INC5
INCR
INCR
INCR
PUTA
GETB
INC5
INC5
INCR
INCR
INCR
PUTB
ENDT

Snippets

Ensure a job quit, regardless of a raise.

QUIT - You don't pay me enough!
QUIT - My word is FINAL.

Categories