Wireworld is a cellular automaton which is well suited for simulating logic gates.
Each cell can be in one of four states:
- empty
- conductor
- electron head
- electron tail
The simulation proceeds in discrete steps. Each step changes the cells in the following ways:
- empty → empty
- electron head → electron tail
- electron tail → conductor
- conductor → Electron head if one or two neighboring cells are electron heads, else it remains a conductor. A cell neighbors another if it is orthogonally or diagonally adjacent (Moore neighborhood).
Run wireworld.py to start it. Requires Python 3 and PyGame 2.
python wireworld.py
An AND gate. Conductor cells are orange, electron heads are blue and electron tails are red. The inputs are on the left, the output is to the right.
A half adder. Left are the two inputs. Top right is the ones output and bottom right is the twos output.
Action | Binding | Alternative |
---|---|---|
Change cell state | Left mouse button | |
Pause/unpause the simulation | Space | |
Single step | Enter | |
Increase speed | + | |
Decrease speed | - | |
Delete cell | Ctrl + Left mouse button | |
Delete all electrons | Backspace | |
Delete all wires | Ctrl + Backspace | |
Move the map | W, A, S, D | Right mouse button |
Zoom in | Ctrl + | Mouse wheel up |
Zoom out | Ctrl - | Mouse wheel down |
Reset zoom | Ctrl 0 | Middle mouse button |
Quit | Esc |
- -h, --help: Show a help message and exit.
- -w, --window-size <width> <height>: Specify the window width and height in pixels.