Archway and Archway2
Brainfuck on a grid where the only loops are arches, drawn so that no wire ever crosses another.
Scott Feeney, 2005 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Scott Feeney made Archway in 2005 to show that a universal machine's state diagram never needs crossing wires, inspired by Beturing. It is brainfuck on a grid, like SNUSP, with two mirrors as the only branches. The proof did not work: its recipe for turning brainfuck into Archway was wrong. Archway2 fixed the mirrors and the recipe, and with them the claim.
The machine
Brainfuck's tape of byte cells, unbounded on the right. The pointer starts at the lower left moving right. Lines are padded to a rectangle, and leaving it ends the run.
| Char | Does |
|---|---|
< > + - , . | As in brainfuck; , reads 0 at the end of input |
\ | If the cell is not 0: right turns down, down right, left up, up left |
/ | If the cell is not 0: right turns up, up right, left down, down left |
In Archway the pointer turns on the mirror. In Archway2 it looks one cell ahead: if a mirror is there and the cell is not 0, it turns before it gets there, and a mirror stepped on is a nop. Loops can then close without crossing their own path.
Example
A straight line needs no mirrors and runs the same in both.
A straight line needs no mirrors and runs the same in both.
The cat from the specification, in each. In Archway the pointer runs round the four mirrors while the cell holds a byte. In Archway2 the mirrors sit outside the loop.
Patterns it teaches
- Two-dimensional control flow: every
[ ]of brainfuck becomes an arch of mirrors. - Turing completeness: Archway2 takes any brainfuck program, and does it with a planar drawing.
See also
Archway and Archway2 builds on Brainfuck.
Two-dimensional languages
Brainfuck derivatives
Write your own in Run Convert a program from Archway and Archway2
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: archway.
Command line
shib run archway -e '/.\
\,/' --input 'cat'shib manual archwaySource
- Module
langs/tio/ports.js- Interpreter
langs/tio/archway.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org