esolang

Ziim

Arrows that point at arrows. An arrow's instruction is whatever points at it, and at what angle.

Timwi, 2011 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

Timwi made Ziim in 2011. A program is nothing but the twelve arrows ↑ ↗ → ↘ ↓ ↙ ← ↖ ↕ ⤢ ↔ ⤡ and spaces. An arrow points at the first arrow in its direction, at any distance. What an arrow does is set only by how many arrows point at it and how far each one has to turn to follow it. Turn a whole program by 45 degrees and every instruction stays the same.

Read the story

Values are strings of bits, carried by threads. Every arrow that nothing points at starts a thread holding a single 0. The only ways to get a 1 are to invert a bit or to read one from the input. The run ends when a thread leaves the grid, and that thread's bits are the output.

The machine

Pointed at byDoes
nothingStart a thread with the value 0
one arrow, turning 45° leftRead a bit; the empty value at the end of the input
one arrow, turning 135° rightNothing
one arrow, turning 135° leftInvert every bit
two arrows, turning 45° right (A) and 45° left (B)Wait for both, then join A and B
two arrows, turning 135° left and rightMerge two paths
one arrow, at 90° to a double arrowSplit the thread both ways
one arrow, 45° left or 135° right of a double arrowTake off the first bit; go 45° left on 0, 135° right on 1
one arrow, 135° left or 45° right of a double arrowGo 45° right if the value is empty, else 135° left, and empty it

Any other way of pointing is an error. A thread may not overtake another on an arrow, so it waits until the arrow ahead is free. The specification lets an interpreter show the output bits any way it likes. This implementation prints a value of whole bytes as those bytes, most significant bit first, and any other value prints as its bits.

Example

The Hello World has 235 arrows.

The Hello World has 235 arrows. 40 of them start threads with a 0, 59 invert, 59 do nothing, 19 split and 58 join.

The specification draws each instruction with the arrows that point at it, and each drawing without letters in it runs on its own. In the inverter, ↗ starts a thread with a 0 and ← follows it with a 135° left turn. So ← inverts the 0 and then points off the grid.

Expected: 1

In the read, ↘ starts a thread and → follows it with a 45° left turn, so → replaces the value with the first bit of the input. In UTF-8 é is the bytes C3 A9, and the first bit of C3 is 1.

Expected: 1

Patterns it teaches

Further

Concurrent programming

Two-dimensional languages

Write your own in Run Convert a program from Ziim

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: ziim.

Command line

shib run ziim -e ' ←
↗'
shib manual ziim

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/ziim.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org