Human Resource Code
The office of the game Human Resource Machine, written out as text. One worker, two conveyor belts and a carpet of numbered cells.
EthanPixelate, 2019 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
EthanPixelate made Human Resource Code in 2019, after the puzzle game Human Resource Machine. In the game you program an office worker with a short list of commands. The worker takes boxes from an inbox conveyor, works on them with the help of the cells on the carpet and drops the results into the outbox. The language keeps the game's commands and is meant to look like game code pasted into a text editor. It adds commands to ask for input, to turn numbers into characters and back, and to halt.
The machine
| Command | Does |
|---|---|
ASK ASKSTRING | Put a number, or a line's character codes and then a 0, on the inbox |
INBOX OUTBOX | Take the next box; drop the held box in the outbox |
COPYFROM n COPYTO n | Pick up a copy of cell n; put a copy in cell n |
ADD n SUB n | Add cell n to the held box, or take it away |
BUMPUP n BUMPDN n | Add 1 to cell n, or take 1 from it |
TOCHAR TONUM | Turn a code into its character and back |
name: | A jump point |
JUMP JUMPZ JUMPN JUMPC | Jump always, or when holding 0, a negative number or a character |
STOP | Halt |
The carpet has cells 0 to 127, all holding 0, and four named cells with the codes of 0, A, a and the space. A number in the outbox is followed by a space.
The specification includes its author's Lua interpreter, and this implementation follows it, quirks too. The interpreter passes over any word it does not know, so COMMENT does nothing. A slip in operator precedence makes a lone ; stop the run with Unknown Command, though the specification calls it a comment. A numbered cell must hold a number from -999 to 999 each time it is used.
Example
The cat, without its blank lines.
The cat, without its blank lines. ASKSTRING ends the line with a 0, and JUMPZ catches it.
A countdown. Cell 0 holds the number and goes down until JUMPZ sees 0.
The truth machine. On 0 it prints 0. On 1 it prints 1 a thousand and one times, because cell 2 counts the rounds and the next BUMPUP 2 after it passes 999 stops the run.
The math example says it prints 3. Its third line misspells BUMPUP, the interpreter passes over the word, and so cell 1 stays 0 and the sum is 2.
Patterns it teaches
- Counter machines: cells that go up and down by one, and a jump on 0.
See also
Also in Turing tarpits
Write your own in Run Convert a program from Human Resource Code
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: human-resource-code.
Command line
shib run human-resource-code -e 'BUMPUP 0
BUMPUP 0
BUMBUP 1
COPYFROM 0
ADD 1
OUTBOX'shib manual human-resource-codeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/human-resource-code.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org