Reso is a low-level circuit design language and simulator, inspired by things like Redstone, Conway’s Game of Life, and Wireworld.
What is Reso?
- Reso is a digital logic circuit graphical programming language!
- Reso is a digital logic circuit simulator.
- Reso program outputs other Reso programs.
- Reso is not a cellular automata, despite similarities.
- Reso is not useful or good yet, but I hope you can still have fun with it.
An input program is a circuit described by a (bitmap) image. When a Reso program is ran through the Reso simulator, it outputs another valid Reso program! Things get interesting when you iterate this process.
While the simulator acts like a pure function, for performance reasons, it maintains state between iterations.
Because images are valid circuits, you can copy-and-paste smaller components to build up more complex circuits using your favorite image editor!
This implementation is (1) slow (it’s in Python!) and (2) not-interactive (you can’t edit circuits live!) I hope you can have fun with this despite those limitations. :)
Installation
TODO — I should list the packages and Python version here!
It is recommended to run git clone
with flag --depth 1
since the examples, slides, etc. in this repository made it a bit heavy.
Usage
This implementation of Reso supports command line usage. Input is a single image, and outputs are iterations of the Reso simulation of the circuit described in the first image.
Command line
Here’s an example: Load ~/helloworld.png
, iterate (-n
) 12 times, and save (-s
) the results to ~/hello_00.png
, ~/hello_01.png
, … ~/hello_04.png
, printing information verbosely (-v
) along the way:
python3 reso.py ~/helloworld.png -n 12 -s hello_ -v
If you only wanted to save the end result, add the “-o” flag, as such:
python3 reso.py ~/helloworld.png -n 12 -s hello_ -v -o
And here is the full command-line usage:
usage: reso.py load_location [--numiter NUMITER] [--save SAVE] [--outputlast] [--verbose]
positional arguments:
load_location Location to load image from
other arguments:
--save SAVE, -s SAVE Prefix to save images to.
--numiter ITERATE, -n ITERATE
iterate the reso board n times. Defaults to 1.
--outputlast, -o Only save the final iteration of the board.
--verbose, -v Print extra information; useful for debugging.
Palette
The palette is an important part of Reso! You can define a circuit using an image. Any pixel with a color in this palette of eight colors has semantic meaning, any other color doesn’t.
Color | Meaning | Hex code |
---|---|---|
Bright orange | Orange wire (on) | #ff8000 |
Dark orange | Orange wire (off) | #804000 |
Bright sapphire | Sapphire wire (on) | #0080ff |
Dark sapphire | Sapphire wire (off) | #004080 |
Bright lime | Lime wire (on) | #80ff00 |
Dark lime | Lime wire (off) | #408000 |
Bright purple | Output (node to wire) | #8000ff |
Dark purple | Input (wire to node) | #400080 |
Bright teal | XOR logic node | #00ff80 |
Dark teal | AND logic node | #008040 |
For backwards compatibility with new functionality, we reserve a total of 48 colors. (This is by convention and is not enforced by the Reso simulator.)
A brief description of how programs run: Wires push their signals through input nodes. There are three different colors of wire (orange, sapphire, and lime). Input nodes pass these signals to logic nodes and output nodes. Logic nodes are used to calculate the ‘AND’ or ‘XOR’ of every input signal, and push these on to output nodes. The output nodes act as one big OR gate, pushing the new signals out to wires.
The colors of different wires don’t have any significance. They exist to make it easier to wire in 2D space, and to make it easier to keep track of which wire is which.
Here’s the full palette of colors that we consider “reserved”. Other colors are ‘whitespace’, i.e. will not have any semantic significance.
Hue | Saturated (1) | Dark (2) | Light (3) | Unsaturated (4) |
---|---|---|---|---|
Red (R) | #ff0000 |
#800000 |
#ff8080 |
#804040 |
Yellow (Y) | #ffff00 |
#808000 |
#ffff80 |
#808040 |
Green (G) | #00ff00 |
#008000 |
#80ff80 |
#408040 |
Cyan (C) | #00ffff |
#008080 |
#80ffff |
#408080 |
Blue (B) | #0000ff |
#000080 |
#8080ff |
#404080 |
Magenta (M) | #ff00ff |
#800080 |
#ff80ff |
#804080 |
Orange (O) | # |