I was looking to update a Java app I’d written and with all the changes recently with Java (modules and a bewildering array of stuff) I decided it would probably be easier just to rewrite it in C. The result actually works much better, I previously used an event based system, that I wasn’t entirely happy with, this time to propagate signals down the wires I settled on a different approach. After loading or any edit, I use recursion to find all the possible targets from each of gates outputs (a wire connected to a tiles output could branch to reach multiple inputs on different tiles). With each gate having a list of targets for its output, updating the input states for each gate is straight forward. (any length of wire regardless of length takes just 1 step to propagate its signal)

Right clicking on an input cell allows you to toggle an input on and off, which is the primary means of interacting with a completed circuit. Left clicking on a cell brings up the edit dialog, there are a number of rules about the number of inputs and outputs particular tile types need, but as you change the inputs and outputs the dialog tells you what the requirements are for that tile and indeed you can only click the Okay button when you have a valid tile. There are a small number of logic types but as you can see by the above screen shot that’s all you need for something as functional as an adder circuit.

Anyway, grab the source code off github and have a play, I’d be interested to hear what people think…

Leave a Reply

Your e-mail address will not be published. Required fields are marked *