Condo I/O: Ability to compare counter values

Since logic gates are seemingly arriving in 0.17.12.0, I think it’d be useful to have a few more modules that are designed to work on Counter values. Since right now, there’s no easy way to compare counter values, without doing a bunch of extra work.


As modules:

IsGreater module: Takes 2 counters as ordered inputs A and B, then waits for its own Compare action to be called. Outputs a true event if A > B, but outputs a false event otherwise.
IsLower module: Takes 2 counters as ordered inputs A and B, then waits for its own Compare action to be called. Outputs a true event if A < B, but outputs a false event otherwise.
IsEqual module: Takes 2 counters as inputs in any order, then waits for its own Compare action to be called. Outputs a true event if A == B, but outputs a false event otherwise.

I know comparing equality between floating point values can be a bit unreliable, but counters only seem to store up to 2 digits of precision* so hopefully this wouldn’t be too unreliable. *(until you pass 2 million-ish, at which point it starts to break down)

Also, these examples work with only 2 inputs at a time for simplicity, but the modules wouldn’t necessarily have to. The IsGreater/IsLower modules could theoretically work with any amount of inputs, as long as the first connected input is the value being compared to.

Example: IsGreater could output true if A > B, and A > C, and A > D, and so on, for as many inputs as it’s been connected to, otherwise output false.


As actions:

If creating modules for this is too cumbersome, the Counters could be given similar I/O actions instead. There’s currently no system for conditionally running actions if a preceding action is true, so they’d need to be designed to do something immediately after doing the comparison.

CopyIfGreater action: Counter A’s action checks if its value is greater than Counter B, then copies its value to Counter B if so.
CopyIfLower action: Counter A’s action checks if its value is lower than Counter B, then copies its value to Counter B if so.

(Copying if equal would be meaningless, so that’s not listed.)

These would be much less intuitive to work with in my opinion, but could theoretically be used to do similar work. It could be extended with the other current Counter actions, e.g. AddIfGreater, AddIfEqual and so on, but I think this would get very messy in the UI very quickly.


As far as I can tell, the lack of this functionality is the only remaining major obstacle to advanced I/O computations. It would let people create things like small games with collision detection, (Pong, Snake, etc) high score trackers, and much more that I can’t even imagine.

I’d love to hear if other players have had similar ideas, and how you would go about designing this!

While this is currently possible with some countdown timers, its currently very inefficient when using larger numbers.

This would have an outstanding effect on counter logic. The biggest consequence of this would be the ability to have a unique output for every number in a counter. This effectively trivializes things like decoders, speeding up creations that make use of them like my 7 segment display (max of 0.3 seconds to decode).

3 Likes

Persistent connections are getting a small clean up to make these types of logic work as right now connections have no maintained order to them. Once that is fixed, then we can add ordered comparisons in the same way as the logic gates. I do also want to make a UI for the persistent connections so you can change the order without having to reconnect everything up.

3 Likes

With the release of the Logic Compare module, this is actually really close to being implemented. (Thank you for doing this so fast!)

The only obstacle is the fact that the Logic Compare module’s value doesn’t seem to be dynamically modifiable - you can only compare against a static number.

Allowing the Counter’s “Copy” action to copy its value into the Logic Compare module’s value would be the last thing needed.

Currently this does nothing, but imagine how powerful it would be if it could change that 5 to a 4!

1 Like

Adding copy to the logic compare module is very easy. I’ll see about getting that in very soon.

2 Likes