Remix.run Logo
Show HN: Circuit Artist – Circuit simulator with propagation animation, rewind(github.com)
135 points by rafinha 7 days ago | 19 comments

Hello,

Circuit Artist is a game about drawing digital circuits as pixel art — like MS Paint, but pixels are wires and little triangles are NANDs. Hit play and the simulation runs in real time. It's fully white-box: every wire's state is visible.

I launched it last year with a unit-delay simulation that ran until convergence on each update. It worked, but I realized it had some fundamental problems:

(i) It hid what was actually happening. Players couldn't tell the difference between a ripple carry adder and a look-ahead adder — everything just resolved instantly.

(ii) Design bugs became "game bugs." When players had non-converging wires (like A = not(A)), the game couldn't explain why or where the error was.

(iii) Layout didn't matter. A NAND on one side of the map would instantly propagate to the opposite side, making spatial decisions meaningless. Unit delay probably works better for schematic-based simulators like Logisim, not a layout-focused game like this.

(iv) Propagation visualization couldn't be added on top of the unit-delay engine — there was no notion of direction or distance.

So I rebuilt the engine with variable-delay event-based simulation using an adaptation of Elmore delay. The delay for each wire depends on distance and fanout — longer wires are slower, higher fanout adds delay, branching wires are faster.

For the implementation: I compute Elmore delay over wire trees. Each pixel has resistance and capacitance, with NAND inputs as nodes to account for fanout. For non-tree wire graphs, I build a Dijkstra-based spanning tree (driver as root) and interpolate for edges outside the tree. I calculate the delay for each node and project it back to the image so every pixel has a distance.

This lets me animate propagation with a glow effect during simulation. The shader knows when each wire was triggered, the current time, and the Elmore distance of each pixel, so it resolves state per-pixel in real time.

On top of that:

- Time rewind: the simulation is now delta-based, so players can freeze and scrub backwards to debug. Super useful for cyclic circuits.

- Layers: since timing matters now, I added up to 3 layers. NANDs only go on the bottom layer, upper layers propagate faster (lower capacitance). Lets you route wires above dense NAND areas.

The game has a campaign for learning from scratch, though it's still incomplete and in progress. I'm working toward Steam Workshop support so people can create their own campaigns to teach different concepts or cover more advanced topics.

GitHub (full source): https://github.com/lets-all-be-stupid-forever/circuit-artist

Steam: https://store.steampowered.com/app/3139580/Circuit_Artist/

jacquesm 2 days ago | parent | next [-]

What a beautiful visualization. I will try this on my electronics loving child, see if it takes.

If at all possible: add resistors and capacitors. With those two added you can make many more interesting circuits (Schmitt triggers, a-stable stuff).

rafinha 2 days ago | parent [-]

Hi, thanks! Today the game is focused on digital logic, It would be fun to put resistors, capacitors or maybe transistors, maybe as a mod, but the algorithm would be a little different, would need analog simulation which I'm less familiar with.

Would probably be slower but doable, fun mod for the future!

atroon 2 days ago | parent | next [-]

If you are mapping the lines where each pixel has resistance and capacitance (presumably quite small values) could you add a new pixel type with editable resistance / capacitance and hide it behind a graphic of the schematic representation (i.e. the zigzag of a resistor like --\/\/\-- or capacitor like --|(-- ?

Your current algorithm would need to be able to accept a wider range of values but it seems like it would work from a math standpoint.

jacquesm 2 days ago | parent | prev [-]

Nand gates you already have and they can take the place of transistors for now, so C's and R's would bring the most options at once. And LEDs, but those should be very easy.

zamadatix 2 days ago | parent | prev | next [-]

This seems awesome! I wish this had come out a few weeks ago so I had time to tinker with it waiting for the Turing Complete rewrite. I particularly like the implementation of Elmore delay to give some meaning to the spatial layout.

I'm not 100% sold on the bitmap editing style of circuit layout vs something like the automatic wire pathing in Turing Complete though. It's something I'll need to play with to get a real opinion on though.

Purchased to have some fun with this weekend. Thanks for publishing the source as well!

its-summertime 2 days ago | parent [-]

Disclaimer: I've only played before the release of the propagation.

Across all the Zach-like and other games I've played around with, the wire management in Circuit Artist I'd say feels very fair and intuitive, and not obstructive to gameplay.

The developer is very accepting of feedback and it showed up a lot, with quality of life features showing up constantly (e.g. being able to automatically draw bus lines, with corners et al).

Worst case, you can copy the circuit into your favorite image editor, make edits there, and paste it back into the game (Or use Netpbm/other software to programmatically generate circuits) (Or make a library of circuits to copy from using any other app that can handle images).

The flexibility of the idea of MS Paint + circuit is taken to its complete logical conclusion.

falsaberN1 a day ago | parent | prev | next [-]

It's kind of like Wireworld, a cellular automaton type, similar to Conway's Life but more oriented to circuits. I always loved these things.

SilentM68 2 days ago | parent | prev | next [-]

This is nice. I wish I had something like this when was taking Electronics courses. The visual component would have been very helpful. Merging this with a course on electronics would be a great resource.

pjc50 2 days ago | parent | prev | next [-]

Having Elmore delay in this is fantastic - many "proper" educational simulators don't bother with this important aspect. It also forces people to deal with fanout, as you say.

Plus it looks really cool with the neon.

simgt 2 days ago | parent | prev | next [-]

What a gem. That seems super fun and I love the Paint aesthetic :)

rafinha 2 days ago | parent [-]

Thanks!

ckmiller 2 days ago | parent | prev | next [-]

I've written simulators as a career for more than a decade, and I'm stunned at what a good job you've done. The simulation engine is excellent and the visualization is prettier (and more intuitive!) than any I've ever seen.

rafinha 21 hours ago | parent [-]

Wow, thanks for the kind words!

random_duck 2 days ago | parent | prev | next [-]

Oh wow, this is such a great project! I love how we can elegantly simulate propagation <3 Congratulations, I will defiantly purchase it from stream just to help it's development.

random_duck 2 days ago | parent [-]

Also, I will strategically wait until the sale is over because this deserves full price.

NwtnsMthd 2 days ago | parent | prev | next [-]

Love the aesthetic, even more, that you published the source! I bought a copy on Steam, thank you for your work!

Any plans to add more advanced campaigns, say, to build up to a simple processor?

rafinha 2 days ago | parent [-]

Hi thanks! Sure, certainly! I also want to eventually add some physics-based levels for fun, with like a box2D sim interacting with the circuits (with N circuit ticks = 1 box2D "tick"), or even little games on top of the circuit, but I need these tutorial campaigns first otherwise the step curve is way too high.

goku12 2 days ago | parent | prev | next [-]

Beautiful work on an interesting subject!

boobsbr 2 days ago | parent | prev [-]

Holy moly.