AsciiDots
The program is a drawing of pipes. Dots carrying numbers run along them, all at once, and meet at operators.
Aaron Janse, 2017 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Aaron Janse made AsciiDots in 2017, inspired by circuit diagrams. A program is ASCII art: lines, corners and crossings. A . is where a dot starts. Each dot carries two numbers, a value and an id, both 0 at first, and travels along the lines until it falls off the end.
Read the story
There are no variables and no jumps. Data moves because dots move. To add two numbers you send two dots into a {+} box from two sides; one waits for the other, and the result comes out the far side. To loop, you draw a loop and let a dot run around it. * copies a dot into every branch, so a program can have many dots running at the same time.
The machine
Every tick, each dot moves one cell. A dot that leaves the paths dies. The program ends at &, or when no dots are left, or when every dot is waiting at an operator.
| Char | Does |
|---|---|
. | A dot starts here |
- \| + | Paths and a crossing; a dot that meets - going up or down dies |
/ \ ( ) | Mirrors; ( and ) send a dot right or left |
> < ^ v | Side paths join here, all leaving in one direction |
* | Copy the dot into every other attached path |
#5 @5 #? #a? | Set the value or the id; read a number or a character |
$"text" $# $@ $a# $_ | Print text, the value, the id, the value as a character; _ drops the newline |
[+] {+} | Wait for a second dot; the vertical ([ ]) or horizontal ({ }) dot leaves with the result |
+ - * / % ^ & o x | Operators, also = ! > < G L and ≠ ≥ ≤ ÷ for comparisons |
~ ! | A dot arriving sideways turns upward if the dot waiting below is non-zero (zero with ! under the ~) |
: ; | Kill a dot whose value is 0, or 1 |
& | End the program |
%$AB | Make the letters A and B warps: each leads to its twin |
Libraries (%!file X) are left out, since there are no files to load.
Example
The dot starts at ., takes the only path, and reaches $.
The dot starts at ., takes the only path, and reaches $. In the second program it passes #37 first, so its value becomes 37, and $a# prints that as a character.
Two dots each read a number and meet at {*}. The top dot arrives sideways, so it is the one that leaves, carrying the product:
.-#?-{*}-$#
|
.-#?--/
And a loop. * sends a copy of the dot left, where #1 sets it to 1 and it waits in [-]. The dot itself goes down, prints its value, and comes up into [-] from below, so it leaves with its value minus 1. Back at the top, : kills it once it reaches 0:
.-#5\
/-:-v
[-]1#*
\-#$/
Patterns it teaches
- Two-dimensional control flow: the program's layout is its control flow, and timing matters, because a dot that arrives early waits.
- Quine: the specification has a one-line quine,
($'.-#40-$_a#-#36-$_a#-#39-$_a#). The(bounces the dot back, so it reads its own line twice. - Turing completeness: loops plus unbounded numbers are enough.
Try this
- Print
Hitwice using*. - Change the countdown to count from 10.
- Hard: print the powers of 2 up to 1024, then stop.
Further
See also
Two-dimensional languages
Write your own in Run Convert a program from AsciiDots
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: asciidots.
Command line
shib run asciidots -e '.-#37-$a#'shib manual asciidotsSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/asciidots.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org