DOG
Orders you would give a dog. Numbers are piles of cookies, carried between its mouth, ten dishes, ten plates and the floor.
Jeremy Ruten, 2007 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Jeremy Ruten made DOG in 2007. Every command reads like an order to a dog, such as fetch, drop, eat, show, bark and die. A number is a pile of cookies. The dog holds one pile in its mouth, and it can leave piles in ten dishes, on ten plates or on the floor.
Read the story
A line can start with a count. A number or a dish runs the line that many times, so dish1 fetch dish2 multiplies. A plate runs it once if the plate is not 0, so plate1 jump loop is a jump if not zero, and with it a loop. A count of 0 runs nothing, which is how comments are written.
The floor holds any number of piles. When the dog takes from the floor it picks a pile at random, and the specification rolls a dice that way. This implementation takes the picks from a fixed sequence, so a run always gives the same answer.
The machine
| Command | Does |
|---|---|
fetch X | Add X to the mouth |
drop V | Move the mouth into V |
pickup V | Move V into the mouth |
eat X | Take X away; eat alone empties the mouth |
clear V | Set V to 0, or empty the floor |
take | Add a number read from the input |
show give | Print the mouth as a number; give empties it too |
bark "text" | Print the text, with \n as a line feed |
label name jump name | Mark a line; go there |
die | Stop |
X is a number, dish0 to dish9, plate0 to plate9 or floor. V is the same without the number. Every place starts at 0, and numbers may go below 0.
Example
The multiplication keeps the two numbers in dishes and runs fetch dish2 as many times as dish1 says.
The multiplication keeps the two numbers in dishes and runs fetch dish2 as many times as dish1 says.
A countdown. The plate holds 3, and the jump goes back while the plate is not empty.
The specification also has the Fibonacci numbers, a quiz on the sum of two random numbers and the 99 bottles of beer, all of which run.
Patterns it teaches
- Camouflage: a plain machine dressed up as orders to a dog.
- Counter machines: dishes and plates are counters, and a plate is the test for zero.
Further
See also
Pseudonatural
Write your own in Run Convert a program from DOG
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: dog.
Command line
shib run dog -e '2 take
give' --input '3
4'shib manual dogSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/dog.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org