A toy OpenGL 3.3 implementation of the Wireworld cellular automaton.
Go
Switch branches/tags
Nothing to show
Latest commit 48eded2 Mar 15, 2015 @jteeuwen Fixes all import paths to reflect recent changes to
the go-gl repos.

Signed-off-by: Jim Teeuwen <jimteeuwen@gmail.com>
Permalink
Failed to load latest commit information.
gfx Fixes all import paths to reflect recent changes to Mar 15, 2015
maths Basic implementation of program. Simulation is working. Feb 3, 2015
samples More major refactoring, cleanups and fixes. Feb 5, 2015
testdata Adds new screenshots. Feb 5, 2015
CONTRIBUTING.md Basic implementation of program. Simulation is working. Feb 3, 2015
LICENSE Basic implementation of program. Simulation is working. Feb 3, 2015
README.md Adds some README info on what the undo/redo functions Feb 6, 2015
assets.go Basic implementation of program. Simulation is working. Feb 3, 2015
bottompanel.go More major refactoring, cleanups and fixes. Feb 5, 2015
button.go Fixes all import paths to reflect recent changes to Mar 15, 2015
clipboardvisualization.go Fixes all import paths to reflect recent changes to Mar 15, 2015
drawablegrid.go Changes the conditions under which `DrawableGrid.Draw` Feb 6, 2015
filebrowser.go Fixes all import paths to reflect recent changes to Mar 15, 2015
main.go Fixes all import paths to reflect recent changes to Mar 15, 2015
memorablegrid.go Adds undo/redo functionality through a simple application Feb 6, 2015
scaledialog.go Fixes all import paths to reflect recent changes to Mar 15, 2015
selectablegrid.go Adds undo/redo functionality through a simple application Feb 6, 2015
simulation.go More major refactoring, cleanups and fixes. Feb 5, 2015
textbox.go Fixes all import paths to reflect recent changes to Mar 15, 2015
toppanel.go More major refactoring, cleanups and fixes. Feb 5, 2015
version.go Basic implementation of program. Simulation is working. Feb 3, 2015
visualisablegrid.go Adds keybinding (`ctrl-f`) to toggle visibility of the Feb 6, 2015

README.md

Wireworld

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.

Warning

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.

Install

go get github.com/jteeuwen/wireworld

Dependencies:

github.com/go-gl/glfw3
github.com/go-gl/glow/gl-core/3.3/gl

Screenshots

Usage

Almost everything is controlled through the keyboard. Here's a listing of all the available controls.

Key Function
Left Mouse drag Draw cells using the current tool.
1 Select Eraser tool.
2 Select Copper wire tool.
3 Select Electron Head tool.
4 Select Electron Tail 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.

Samples

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.

License

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.