esolang

Manufactoria

A factory floor drawn in letters. A robot rides the belts with a queue of colours, and the machine decides where it ends up.

Quincunx, 2014 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, World!

The idea

Quincunx made Manufactoria in 2014 from pleasingfungus's game of the same name, with permission. In the game you build a machine that tests robots. Each robot carries a tape of red and blue marks, and the machine sends it to the exit or drops it on the floor. In the language the factory is a grid of characters and the tape is a queue of four colours, b r g y.

Read the story

The only memory is that queue. A branch reads and removes the colour at the front, and a writer adds one at the back, so a program works by cycling the queue through itself.

The machine

CharDoes
@ 0 &Start, moving right, with the input as colours, as a binary number, or as 7 bits per character
> < ^ vConveyors
#Bridge, keep going
r c R CWrite red at the back and go right, up, left, down
b d B D g q G Q y t Y TThe same for blue, green, yellow
h j k l H J K Lb/r and r/b branches whose neutral side points left, down, up, right
u i o p U I O Pg/y and y/g branches
; ! $Exit and print the queue as letters, as a binary number, or as 7-bit characters
.Exit quietly

A branch looks at the front colour. The first of its two colours turns the robot clockwise from the neutral side and the second anticlockwise, and either one is taken off. Any other colour, or none, sends it to the neutral side and stays. A space, the edge or anything else is the floor, which ends the run with exit code 1.

In binary b is 1 and r is 0, and green and yellow are skipped.

Example

Hello, World! is one row of writers that spells the text in 7 bits a character, ending at $.

Hello, World! is one row of writers that spells the text in 7 bits a character, ending at $.

Writing a colour at the back of a binary number doubles it and adds the bit. With the 0 start the input 5 becomes brb, and r then b make it brbrb, which is 21.

Expected: 21

The machine for the last colour of the input. When the robot reaches one of its two ; exits, only the last colour is left in the queue.

Expected: y

Patterns it teaches

Further

Queue-based

Two-dimensional languages

Write your own in Run Convert a program from Manufactoria

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: manufactoria.

Command line

shib run manufactoria -e '  @v
 v<jv
v#<I#v
vv>>##;
vvdcvv
v#o##v
v##o#v
v>KK<v
>#II#<
 ^#j^
 ^j#^
  TQ
  >;' --input 'brgy'
shib manual manufactoria

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/manufactoria.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org