esolang

DigFill

Memory is only there once you have dug it out.

Abraham Karplus, 2011 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

Abraham Karplus made DigFill in 2011. Memory is an endless plane of bits, all 0 except the one the miner stands on. The miner can set the four cells around it to 1 (dig) or 0 (fill), and it can only walk through cells that are 1. So before it can go anywhere it has to dig a tunnel.

Read the story

There are no loops or jumps. The only flow control is the inscription. Code in parentheses can be inscribed on a cell that is 0, and ~ runs the inscription next to the miner. Digging a cell wipes what was written on it. A loop is an inscription that runs itself again, and an if is a miner that either can or cannot step next to a certain inscription.

The machine

Every command but ! and * takes a direction, n s e or w.

CommandDoes
@ #Dig the next cell (1), fill it (0)
$ %Step there if it is 1, walk as far as possible
^ &Read one input bit into the next cell, write the next cell as one output bit
(code) +Inscribe the code, or the block it stands in, on the next cell if it is 0
~Run the next cell's inscription
! *Nothing, end

Input and output go one bit at a time, most significant first. The end of the input is the byte 0xFF, which never appears in UTF-8 text.

Example

The Hello World digs one cell to the north.

The Hello World digs one cell to the north. Then &n writes a 1 and &s a 0.

The cat digs a hallway of eight cells, one per bit, and puts an end on the cell above it. The body reads a byte into cells east of the hallway. Only the 0xFF mark has its top bit set, and only then can the miner step east and walk north to the end.

Expected: dig

Further

Ideas it shows

Cell-based

Write your own in Run Convert a program from DigFill

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run digfill -e '@n&s&n&s&s&s&n&s&s&s&n&n&s&n&s&s&n&s&n&n&s&s&n&n&n'
shib manual digfill

Source

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

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

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