Wireworld 1K
stableA binary adder cellular automaton.
My entry for the PICO-1K Jam Sep-Oct 2022. The goal was to make cool things in PICO-8 by using only 1K (1024) Compressed Bytes of code.
Wireworld 1K is a Turing-complete cellular automaton (CA) suited to simulating electrons moving on copper wire. By placing copper in specific configurations you can build electronic components - transistors, timers and logic gates.
This cart implements a Wireworld CA Binary Adder. Two numbers represented in binary (little-endian, LSB) are added together. The largest decimal value it can calculate is 126 (an unsigned 7-bit number).
Wireworld was first proposed by Brian Silverman in 1987.
Rules of Wireworld
Wireworld consists of a grid of cells, each can be in one of four states:
- Empty (dark cells): nothing happens on this cell. This is an insulator.
- Wire (gold): provides a means for electrons to travel upon.
- Electron head (blue): The forward-facing part of an electron.
- Electron tail (white): The backward-facing part of an electron.
Time moves in discreet steps, and the rules that govern cell states are:
- Empty cells stay empty
- Electron heads become tails
- Electron tails become Wire
- Wire becomes an electron head if one or two of its neighbors are electron heads (Moore neighborhood)
The animation below demonstrates three electrons as they move along separate wires:
- The top circuit shows how a signal can be split into two copies.
- The middle and lower wires show components known as diodes - they limit the flow of a signal to one direction only.
- The lower diode allows the incoming signal through, while the middle diode prevents the signal from passing.
Diodes are not used much within Wireworld since wires rarely carry bi-directional signals, but these demonstrate how the Rules can be used to build complex interactions. If you are interested to read more about Wireworld, check out the links below.
How To Play
This cart is an interactive rail demo, press any of the Pico keys (Z, X, or Arrow keys) to advance to the next step:
- Roll the Dice, in two steps: picks two random numbers A and B
- Computation: Runs the simulation until it reaches the answers
- Outcome: Displays the sum of A and B
The binary adder is composed of these inputs and outputs:
The Inputs and Output are serially encoded binary numbers. The order of the bytes, also known as Endianess, is least-significant byte first (LSB). That just means the smallest bit (1) is read first by the adder.
To read a number, simply sum the bits where an electron is present:
Cartridge
If you have the Pico-8 fantasy console you can load this cart:
See also
- Wireworld on WikiPedia
- The Wireworld Computer
- Below link in the Journal section for the source code!
Journal
Date | Title |
---|---|
11 Mar 2023 | source code |