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
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
| Char | Does |
|---|---|
@ 0 & | Start, moving right, with the input as colours, as a binary number, or as 7 bits per character |
> < ^ v | Conveyors |
# | Bridge, keep going |
r c R C | Write red at the back and go right, up, left, down |
b d B D g q G Q y t Y T | The same for blue, green, yellow |
h j k l H J K L | b/r and r/b branches whose neutral side points left, down, up, right |
u i o p U I O P | g/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.
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.
Patterns it teaches
- Two-dimensional control flow, belts and branches on a grid, with a queue as the only memory.
Further
See also
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 manufactoriaSource
- 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