Reso is a low-level circuit design language and simulator, inspired by things like Redstone, Conway's Game of Life, and Wireworld.

Related tags

Miscellaneous reso
Overview

Reso

Reso logo

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) #ff8000 #804000 #ffc080 #806040
Lime (L) #80ff00 #408000 #c0ff80 #608040
Teal (T) #00ff80 #008040 #80ffc0 #408060
Sapphire (S) #0080ff #004080 #80c0ff #406080
Purple (P) #8000ff #400080 #c080ff #604080
Violet (V) #ff0080 #800040 #ff80c0 #804060

(Note: Don't sample directly from your web-browser! They don't always render colors reliably.)

Examples

The Reso logo is actually a complete circuit in-and-of itself! Here is a small gif that explains what's going on, animated at 1/4th the speed (that is, one update every 2000ms):

This is Reso gif

Things to be done:

Despite all the tests and documentation, Reso is a proof-of-concept and there's a lot to be done before this could even be a little useful!

Here are some neat ideas:

Flag to map to nearby colors: I've been having a weird issue with some versions of The GIMP, where colors are saved or picked incorrectly. Reso requires precise colors (e.g. #ff8000 is a valid color but #ff8800 is not.) Perhaps a flag to consider only the ~4 or so most-significant-bits per pixel, or to map colors within a certain range to their nearest one in the palette, would be useful?

Export to GIF option: Self explanatory! No more fiddling with GIMP or ffmpeg.

Transferrable compiled graphs: Reso is really a graph computation model of a logical circuit, and images are a way to define that graph. I want to better decouple that model, and make this a repository a better reference implementation.

Specifically, we consider pixels to represent logical "resels" which can also be represented textually, and regions of resels represent elements, which are represented internally as a graph implemented with Python dictionaries. But this graph isn't a standard, so a compiled graph can't be transferred between implementations.

GUI and interactivity: Some kind of GUI would be nifty too, rather than requiring expertise in some external graphical application. An interactive, Javascript webpage would make this a lot easier to mess around with, huh?

Speed: This is also really slow. Might reimplement in Rust when I get around to learning it!

Port to a faster language: Porting this to a faster language would be great. I think Rust would be fun (both because I want to learn it, and because there's some "Web Assembly" thing that makes me think it's easier to put Rust in the web than, say, C or C++.)

See Also

Here are a list of similar projects that I am aware of. Please make an issue or PR if you have something else to share!

  • Several sandbox videogames which have turing-complete circuit languages that empower the player to automate their world:
    • Minecraft's Redstone was the primary inspiration for this.
    • Terraria (Minecraft's 2D analogue) has a similar logic-gate wiring mechanism.
    • Hempuli is one of my favorite game devs, and seeing their development on Baba Is You kept my brain on the right track for this.
    • Various other open-world sandbox games: Factorio, No Man's Sky, Dwarf Fortress, and others!
  • Conway's Game of Life -- A Turing-complete zero-player-game. By far the most popular cellular automata. Rest in Peace John Conway.
  • Wireworld -- Another cellular automata in which it is easy to implement logic circuits.
  • Brian's Brain -- A cellular automaton similar to the previous.
  • Bitmap Logic Simulator -- I'm not sure how this works, but check it out! It's a similar idea.
You might also like...
A simple assembly- and brainfuck-inspired stack-based language

asm-stackfuck A simple assembly- and brainfuck-inspired stack-based language. The language has a few goals: Be stack-based Look like assembly Have a s

🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.

Boltons boltons should be builtins. Boltons is a set of over 230 BSD-licensed, pure-Python utilities in the same spirit as — and yet conspicuously mis

Mines all the moneys and stuff and things.

NFT Miner NFT Miner - Version 1.1.0 - Quick Fix Since the whole NFT thing started booming on Twitter it's been hard not to see one of those ugly ass m

A curated list of awesome things related to Pydantic! 🌪️

Awesome Pydantic A curated list of awesome things related to Pydantic. These packages have not been vetted or approved by the pydantic team. Feel free

For when you really need to rank things

Comparisonator For when you really need to rank things. Do you know that feeling when there's this urge deep within you that tells you to compare thin

A sandpit for textual related things

A sandpit repo for testing textual related things.

A price calculator for multiple things
A price calculator for multiple things

Price Calculator A price calculator for multiple things Example I have 0.0567kg diamond. The price of diamond in kg is: $4500. Then it says: The price

A guy with a lot of useful things to do when doing AtCoder in Python

atcoder_python_env Python で AtCoder をやるときに便利な諸々を用意したやつ コンテスト用フォルダの作成 セットアップ 自動テス

Comments
  • Palette update!

    Palette update!

    Out with the primary + secondary colors, in with the tertiary colors! The tertiary colors look better IMO, and are more consistently visible across both black and white backgrounds.

    Regarding wires, we're moving from red and blue wires, and now using orange, sapphire, and lime wires. Adding a third wire makes it easier to wire complicated circuits, and are chosen for the aesthetics. Orange and sapphire are the familiar and attractive 'portal' colors, and 'lime' was chosen as a nod to 'limewire' of the early 2000s.

    Tests and many examples are updated alongside the new palette. This also comes with a nifty, pretty new logo!

    Have fun.

    opened by lynnpepin 0
  • Bump pillow from 9.0.1 to 9.3.0

    Bump pillow from 9.0.1 to 9.3.0

    Bumps pillow from 9.0.1 to 9.3.0.

    Release notes

    Sourced from pillow's releases.

    9.3.0

    https://pillow.readthedocs.io/en/stable/releasenotes/9.3.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    9.3.0 (2022-10-29)

    • Limit SAMPLESPERPIXEL to avoid runtime DOS #6700 [wiredfool]

    • Initialize libtiff buffer when saving #6699 [radarhere]

    • Inline fname2char to fix memory leak #6329 [nulano]

    • Fix memory leaks related to text features #6330 [nulano]

    • Use double quotes for version check on old CPython on Windows #6695 [hugovk]

    • Remove backup implementation of Round for Windows platforms #6693 [cgohlke]

    • Fixed set_variation_by_name offset #6445 [radarhere]

    • Fix malloc in _imagingft.c:font_setvaraxes #6690 [cgohlke]

    • Release Python GIL when converting images using matrix operations #6418 [hmaarrfk]

    • Added ExifTags enums #6630 [radarhere]

    • Do not modify previous frame when calculating delta in PNG #6683 [radarhere]

    • Added support for reading BMP images with RLE4 compression #6674 [npjg, radarhere]

    • Decode JPEG compressed BLP1 data in original mode #6678 [radarhere]

    • Added GPS TIFF tag info #6661 [radarhere]

    • Added conversion between RGB/RGBA/RGBX and LAB #6647 [radarhere]

    • Do not attempt normalization if mode is already normal #6644 [radarhere]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Hello world

    Hello world

    Hey there!

    I just started learning rust and as a small exercise, I've made an implementation of reso from scratch on rust. And I was wondering whether you'd like to connect these projects?

    My code is still a bit messy and needs some refactoring, but it's not too slow (~0.25s per step on my machine) and could be used for creating an interactive WebAssembly interface. Let me know what you think!

    Link to my implementation: https://github.com/ashirviskas/rust_reso

    opened by ashirviskas 6
Owner
Lynn
PhD student at UConn, they/them. I'm more active on GitLab: gitlab.com/lynnpepin
Lynn
A general purpose low level programming language written in Python.

A general purpose low level programming language written in Python. Basal is an easy mid level programming language compiling to C. It has an easy syntax, similar to Python, Rust etc.

Snm Logic 6 Mar 30, 2022
An awesome list of AI for art and design - resources, and popular datasets and how we may apply computer vision tasks to art and design.

Awesome AI for Art & Design An awesome list of AI for art and design - resources, and popular datasets and how we may apply computer vision tasks to a

Margaret Maynard-Reid 20 Dec 21, 2022
System Design Assignments as part of Arpit's System Design Masterclass

System Design Assignments The repository contains a set of problem statements around Software Architecture and System Design as conducted by Arpit's S

Relog 1.1k Jan 9, 2023
Plugin to manage site, circuit and device diagrams and documents in Netbox

Netbox Documents Plugin A plugin designed to faciliate the storage of site, circuit and device specific documents within NetBox Note: Netbox v3.2+ is

Jason Yates 38 Dec 24, 2022
Python module for creating the circuit simulation definitions for Elmer FEM

elmer_circuitbuilder Python module for creating the circuit simulation definitions for Elmer FEM. The circuit definitions enable easy setup of coils (

null 5 Oct 3, 2022
Async Python Circuit Breaker implementation

aiocircuitbreaker This is an async Python implementation of the circuitbreaker library. Installation The project is available on PyPI. Simply run: $ p

null 5 Sep 5, 2022
Simple package to make requests throughout Tor with circuit renewal.

AutoTor Table of Contents About the Project Contents Dependencies Getting Started Installation Coding Contributing About the Project Simple package to

Salvador Belenguer 6 Jan 1, 2023
This is an online course where you can learn and master the skill of low-level performance analysis and tuning.

Performance Ninja Class This is an online course where you can learn to find and fix low-level performance issues, for example CPU cache misses and br

Denis Bakhvalov 1.2k Dec 30, 2022
Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems.

Control System Packer is a lightweight, low-level program to transform energy equations into the compact libraries for control systems. Packer supports Python ?? , C ?? and C++ ?? libraries.

mirnanoukari 31 Sep 15, 2022
Low-level Python CFFI Bindings for Argon2

Low-level Python CFFI Bindings for Argon2 argon2-cffi-bindings provides low-level CFFI bindings to the Argon2 password hashing algorithm including a v

Hynek Schlawack 4 Dec 15, 2022