This is a toy implementation of the Wireworld cellular automaton. It is built on top of the OpenGL 3.3 core profile and serves as a playground for me to learn about the shader pipeline. As such, this should not be considered finished, or even useful. It is added to or changed every once in a while.
Wireworld is a cellular automaton in the same spirit as Conway's Game of Life. It was first proposed by Brian Silverman in 1987, as part of his program ”Phantom Fish Tank”. It subsequently became more widely known as a result of an article in the “Computer Recreations” column of Scientific American. Wireworld is particularly suited to simulating boolean logic gates and, despite the simplicity of the rules, Wireworld is Turing-complete.
This was all designed to run reasonably well on
NVIDIA GeForce GT 430/PCIe/SSE2
with driver version
4.5.0 NVIDIA 346.35. No guarantees are made this works on
any other system.
The input controls like the Textbox are extremely rudimentary and a bit
flaky to use. Text selection is not supported. When clicking a textbox, it
gains focus, allowing you to type. Hitting Escape or Enter releases focus.
There is nothing in place to stop multiple textboxes from having focus at the
same time. This is only relevant for the Resize dialog (
F6), so take note.
Idealy I'd like to use an existing, lightweight UI library for all this,
but as yet I have not found one which works in Go and has an OpenGL 3.3+ backend.
go get github.com/jteeuwen/wireworld
Almost everything is controlled through the keyboard. Here's a listing of all the available controls.
|Left Mouse drag||Draw cells using the current tool.|
Q | Perform a single simulation step. E | Toggle continuous simulation.
| Decrease simulation clock speed.
| Increase simulation clock speed. |
F1 | Clear all isolated cells -- Non-empty cells with only empty neighbours.
F2 | Discharge -- changes all Electron Head- and Tail cells to Copper.
F5 | Trim grid size down to fit the current circuit.
F6 | Open dialog which allows current grid to be rescaled.
V | Center grid in viewport.
B | Toggle cell border visibility.
Mouse wheel | Zoom in/out.
Space+Mouse move | Move the grid around the screen.
Right Mouse drag | Begin/end selecting a region of cells.
Escape | Clear current cell selection.
Delete | Clear selected region.
Ctrl+A | Select all cells.
Ctrl+X | Cut selected cells and place them on the clipboard.
Ctrl+C | Copy selected cells to the clipboard.
Ctrl+V | Paste clipboard contents at the current mouse position.
Ctrl+N | Start a new, empty grid.
Ctrl+O | Open an existing simulation from a file.
Ctrl+S | Save the current simulation to a file.
Ctrl+Shift+S | Save the current simulation to a new file.
Ctrl+I | Import an existing simulation from a file. The contents of this file are copied to the clipboard and you can use
ctrl+v to paste it anywhere on the existing grid.
Ctrl+R | Reload the current simulation from file.
Ctrl+F | Show/hide a semi-transparent version of the clipboard contents under the mouse cursor. This makes it easier to accurately position pasted content.
Ctrl+Z | Undo the last change. This applies to manual drawing, cutting, pasting and deleting of regions of cell data.
Ctrl+Shift+Z | Redo the last undone change.
The samples directory contains some predefined circuits for you to examine.
- Clock: A simple clock which periodically emits a signal to whatever wire you attach to it.
- Diode: A diode allows a signal to travel along a wire in only one direction.
- OR: The OR gate has 2 inputs and 1 output. The output yields the signal from either the input or the output or both. Signals can not travel back along the input wires.
- XOR: The XOR (eXclusive OR) gate has 2 inputs and 1 output. It will only output a signal from either input A or B. if both yield a signal at the same time, it outputs nothing.
- AND-NOT: For an explanation on how this works, refer to this page.
- ROM: This is a read-only memory bank with ten 7-bit values. To understand how this works, refer to this page.
- Flip-flop: This gate can store 1 bit of information when needed. Refer to this page for details.
Unless otherwise stated, all of the work in this project is subject to a 1-clause BSD license. Its contents can be found in the enclosed LICENSE file.