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

Related tags

Miscellaneousreso
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.
Owner
Lynn
PhD student at UConn, they/them. I'm more active on GitLab: gitlab.com/lynnpepin
Lynn
Find your desired product in Digikala using this app.

Digikala Search Find your desired product in Digikala using this app. با این برنامه محصول مورد نظر خود را در دیجیکالا پیدا کنید. About me Full name: M

Matin Ardestani 17 Sep 15, 2022
Prometheus exporter for chess.com player data

chess-exporter Prometheus exporter for chess.com player data implemented via chess.com's published data API and Prometheus Python Client Example use c

Mário Uhrík 7 Feb 28, 2022
🇮🇳 A Indian Flag Animation Project Made With Python

🇮🇳 A Indian Flag Animation Project Made With Python

MuFaz-TG 2 Oct 21, 2022
uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.

uMap project About uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site. Because we think that the more OSM wil

771 Dec 29, 2022
A country information finder module

A country information finder module

Fayas Noushad 3 Nov 28, 2021
The official FOSSCOMM 2021 CTF by [email protected]

FOSSCOMM 2021 CTF Table of Contents General Info FAQ General Info Purpose: This CTF is a collaboration between the FOSSCOMM conference and the Machina 2 Nov 14, 2021

a simple thing that i made for fun :trollface:

we-do-a-little-trolling about a simple thing that i made for fun. requirements and instructions first you need to install obs , then start the virtual

ranon rat 6 Jul 15, 2022
Find out where all films you want to watch are streaming

Just Watch Letterboxd Find out where all films you want to watch are streaming Ever wonder what films you want to watch are already on the streaming p

Jordan Oslislo 2 Feb 04, 2022
🔩 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

Mahmoud Hashemi 6k Jan 06, 2023
Курс про техническое совершенство для нетехнарей

Technical Excellence 101 Курс про техническое совершенство для нетехнарей. Этот курс представлят из себя серию воркшопов, при помощи которых можно объ

Anton Bevzuk 11 Nov 13, 2022
🙌Kart of 210+ projects based on machine learning, deep learning, computer vision, natural language processing and all. Show your support by ✨ this repository.

ML-ProjectKart 📌 Repository This kart showcases the finest collection of all projects based on machine learning, deep learning, computer vision, natu

Prathima Kadari 203 Dec 28, 2022
Get a link to the web version of a git-tracked file or directory

githyperlink Get a link to the web version of a git-tracked file or directory. Applies to GitHub and GitLab remotes (and maybe others but those are no

Tomas Fiers 2 Nov 08, 2022
Машинное обучение на ФКН ВШЭ

Курс "Машинное обучение" на ФКН ВШЭ Конспекты лекций, материалы семинаров и домашние задания (теоретические, практические, соревнования) по курсу "Маш

Evgeny Sokolov 2.2k Jan 04, 2023
python's memory-saving dictionary data structure

ConstDict python代替的Dict数据结构 若字典不会增加字段,只读/原字段修改 使用ConstDict可节省内存 Dict()内存主要消耗的地方: 1、Dict扩容机制,预留内存空间 2、Dict也是一个对象,内部会动态维护__dict__,增加slot类属性可以节省内容 节省内存大小

Grenter 1 Nov 03, 2021
FantasyBballHelper - Espn Fantasy Basketball Helper

ESPN FANTASY BASKETBALL HELPER The simple goal of this project is to allow fanta

1 Jan 18, 2022
Generate your personal 8-bit avatars using Cellular Automata, a mathematical model that simulates life, survival, and extinction

Try the interactive demo here ✨ ✨ Sprites-as-a-Service is an open-source web application that allows you to generate custom 8-bit sprites using Cellul

Lj Miranda 265 Dec 26, 2022
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

Windel Bouwman 277 Dec 26, 2022
DOP-Tuning(Domain-Oriented Prefix-tuning model)

DOP-Tuning DOP-Tuning(Domain-Oriented Prefix-tuning model)代码基于Prefix-Tuning改进. Files ├── seq2seq # Code for encoder-decoder arch

Andrew Zeng 5 Nov 02, 2022
Cool little Python scripts & projects I've made.

Little Python Projects A repository for neat little Python scripts I've made! How to run a script: *NOTE: You'll need to install Python v3 or higher.

dood 1 Jan 19, 2022