Artificial-life: A simple (300 lines of code) reproduction of Computational Life
Source: Hacker News
Program description
A 240 × 135 grid of 64‑instruction‑length Brainfuck‑like programs are randomly initialized. Every iteration, neighboring programs are randomly paired, have their instruction tapes concatenated together, and are run for a maximum of (2^{13}) steps. Once execution completes, the tapes are split back apart. The instructions can loop and mutate the instruction tapes (programs) themselves. As found in the paper, self‑replicating programs that copy themselves over their neighbor’s tape often spontaneously emerge, eventually spreading to take over the entire grid.
Example simulation
Every pixel is an instruction; each instruction has a unique color, while black represents a value on the tape that is raw data storage / not an instruction. Every 8 × 8 section of pixels represents a single program.
uv run main.py --seed 1
In this run, a self‑replicator emerges relatively early and soon takes over most of the grid, until a more efficient self‑replicator evolves and dominates everything.
