Manufactoria

From Esolang
Jump to: navigation, search

Manufactoria is based on the game, and is basically the same thing. It was made by Quincunx with permission from pleasingfungus.

Definition

Manufactoria is a two-dimensional ASCII-based programming language. Here is a quote from the game that might help with understanding this language:

We, INDUSTRIAL ROBOTICS, have contracted you, ROBOTICS ENGINEER, to help us with a problem.
Our robots - built to bring happiness and joy to people across the world! - have shown an unfortunate tendency to go mad.
Our investigators suggested TESTING our robots before shipping them... which is where you come in.
Your job is to build: a testing MACHINE!
Our robots are programmed with read and blue code-symbols. Each class of robot follows a pattern in its programming. If that pattern is matched, the robot behaves correctly. Otherwise... well!
You will be given conveyor belts, which move robots in a fixed direction, and branch-conveyors, which read the next symbol and move the robot in the corresponding direction. With these tools, build a machine that moves robots: to the exit if they match the pattern given ('accept'), and to the floor with the rejects!

When the program is run, a robot with the input on its tape (queue) goes from the @ in the rightwards direction.

Conveyors (<^>v) and bridges (#) are the basic building blocks to the program; they tell the robot to move in a certain direction.

Branches (hjklHJKLuiopUIOP) move the robot in the direction corresponding to the first value on the queue. A branch has two colors, say a and b. If the first color is a, then the robot moves in the direction of a. If the color is b, then it moves in the direction of b. Otherwise, it moves in the direction of n (neutral). If the robot moves in any direction other than n, the first color is removed. A branch that 'points' in a certain direction has its neutral value pointing in that direction. Following is the b/r branch j:

 -------
|b     r|
 \__n__/

If a b is the first color, the robot will move left (as if it hit a <) and the b is removed. If a r is the first color, the robot will move right (as if it hit a >) and the r is removed. Otherwise, the robot moves down (as if it hit a v).

Writers (rcRCbdBDgGyY) add a new value onto the end of the queue.

Any mention of a number as binary works as follows:

  • Any g or y is ignored.
  • A b acts as a 1, and a r acts as a 0
  • The most significant bit is the bit closest to the head (first element) of the queue.

Instructions

Manufactoria has four directions for basically every command. SHIFT->CHAR (on Qwerty keyboard) reverses the direction of most commands in this language.

Character Action
! End of program; print in decimal the binary value of queue
$ End of program; print queue as ascii from binary. Uses 7 values per character
; End of program; print the contents of the queue
End of program; with error code 1
. End of program; do nothing
> Conveyor moving right
< Conveyor moving left
^ Conveyor moving up
v Conveyor moving down
# Bridge: continue in same direction
r Red writer, right
c Red writer, up*
R Red writer, left
C Red writer, down*
b Blue writer, right
d Blue writer, up*
B Blue writer, left
D Blue writer, down*
g Green writer, right
q Green writer, up*
G Green writer, left
Q Green writer, down*
y Yellow writer, right
t Yellow writer, up
Y Yellow writer, left
T Yellow writer, down
h b/r branch, left
j b/r branch, down
k b/r branch, up
l b/r branch, right
H r/b branch, left
J r/b branch, down
K r/b branch, up
L r/b branch, right
u g/y branch, left
i g/y branch, down
o g/y branch, up
p g/y branch, right
U y/g branch, left
I y/g branch, down
O y/g branch, up
P y/g branch, right

* chosen because of similarity to the corresponding letter.

If the robot goes off the edge of the screen, it acts as if it hit a space.

Input

Input is taken as a command line argument. There are three options: input by sequence of colors (brgy), input by interpreting a number into binary (b is a 1 and r is a 0), and input by interpreting the input as ASCII (where 7 bits encode each character; compatible with $ for output).

No matter which input is used, the robot starts by moving right. If the robot moves onto a starting character, the robot acts as if it moves onto a space.

There can only be one starting character in the program. If there are multiple, the compiler/interpreter throws an error.

Start type Character
color sequence @
number 0
ASCII &

When the input does not match the input type, it is implementation dependent on what happens.

Examples

Hello, World!

@brrbrrrbbrrbrbbbrbbrrbbrbbrrbbrbbbbrbrbbrrrbrrrrrbrbrbbbbbrbbbbbbbrrbrbbrbbrrbbrrbrrrbrrrrb$

Busy Beaver

CRR@v
Crc >yyT
ic<<<YYY
g>vGO>v
v#jbKRv
>##>t<<
 cI.

Last color inputted

  @v
 v<jv
v#<I#v
vv>>##;
vvdcvv
v#o##v
v##o#v
v>KK<v
>#II#<
 ^#j^
 ^j#^
  TQ
  >;

Implementations

https://github.com/Quincunx271/ManufactoriaLang

See also