{"by":"rafinha","descendants":19,"id":46445412,"kids":[46499597,46499268,46499736,46502165,46497879,46514987,46501901,46501425,46502121,46499135,46498437],"score":135,"text":"Hello,<p>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&#x27;s fully white-box: every wire&#x27;s state is visible.<p>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:<p>(i) It hid what was actually happening. Players couldn&#x27;t tell the difference between a ripple carry adder and a look-ahead adder — everything just resolved instantly.<p>(ii) Design bugs became &quot;game bugs.&quot; When players had non-converging wires (like A = not(A)), the game couldn&#x27;t explain why or where the error was.<p>(iii) Layout didn&#x27;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.<p>(iv) Propagation visualization couldn&#x27;t be added on top of the unit-delay engine — there was no notion of direction or distance.<p>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.<p>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.<p>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.<p>On top of that:<p>- Time rewind: the simulation is now delta-based, so players can freeze and scrub backwards to debug. Super useful for cyclic circuits.<p>- 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.<p>The game has a campaign for learning from scratch, though it&#x27;s still incomplete and in progress. I&#x27;m working toward Steam Workshop support so people can create their own campaigns to teach different concepts or cover more advanced topics.<p>GitHub (full source): <a href=\"https:&#x2F;&#x2F;github.com&#x2F;lets-all-be-stupid-forever&#x2F;circuit-artist\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;lets-all-be-stupid-forever&#x2F;circuit-artist</a><p>Steam: <a href=\"https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;3139580&#x2F;Circuit_Artist&#x2F;\" rel=\"nofollow\">https:&#x2F;&#x2F;store.steampowered.com&#x2F;app&#x2F;3139580&#x2F;Circuit_Artist&#x2F;</a>","time":1767197540,"title":"Show HN: Circuit Artist – Circuit simulator with propagation animation, rewind","type":"story","url":"https://github.com/lets-all-be-stupid-forever/circuit-artist"}