Help with logic - select smallest value (0 excluded)
I need to compare 4 values and select smallest one, but ignore inactive 0 inputs. So if the inputs are 0,2,5,9, the result should be 2. Only if it is 0,0,0,0 the result should be zero.
I know I can use AND gate to find lowest signal. But the zeroes are making it tricky.
So far I made it in a way that if input is 0 i change it to 1000. And if the result value is 1000, I change it to 0. But that means Im running multiple operation 5 times to midify values. And because I need to copy this chip many times (ideally hundrets), Im looking for most optimized solution to reduce thermo usage.
Do you have better ideas how to do it with less calculations?
Thanks
-
Hi,
it might depend where your input values were coming from. If they were coming from nodes or some gadget you can turn off when the output is zero then there may be a version using 3 calculator gadgets.
In this case you can use the fact that with wire blend mode - "Blend" the power of the input gadget is used to blend the wire value onto the slider. So if you use calculators (set to "minimum") you can set the sliders on the calculator to 1000 and wire into them with blend mode - "Blend". Wire the calculators up so that two inputs go into the first calculator, 2 inputs go into the second and then results from each calculator go into the third. Also wire the output from each input into it's own power so that when the output is zero the input is powered off. Now when a node's output is 0 the calculator will take the value on the slider (1000) instead of the value on the wire. You can then wire all the inputs into the power of the final calculator so that in the case where all inputs are zero the final calculator will be off and also output zero.
If you don't know what I'm talking about with wire blend modes then have a look at a tweak menu and hold L1 over the input port of a tweak that you have wired into. Pressing L1 + X changes the wire blend mode.
Hopefully that'll give you some ideas anyway, good luck!
Matt -
A picture might help!
-
Interesting. Im not sure if this will be less gadgets than my solution, but can you please explain little more what is the blend mode? I see the tweak menu help, but have no idea, what does it changes on the input?
Thanks -
The picture looks interesting. When I will be home I will try. If this works (ignores the zeroes), then it is much more effective than my set up.
Basically Im trying to play with pathfinding on the grid. So Im counting distance from the target. Using receivers to read values on the 4 nearby squares then choosing smalles one (ignoring empty areas around), adding one and transmitting again.
The more efficent, the bigger I can create the grid and more potential it has. My solution was eating about 40% on 10x10 grid. I will see what yours does.
Thanks -
The wire blend mode decides what to do with the values that come in on the wire and decides how to apply them to the actual slider. You can have multiple wires going into the tweak and it needs to decide how to handle that. There are 3 options:
Overwrite - takes the largest of the values on the wire and applies it to the tweak
Modulate - takes the largest but multiplies it by the value on the slider
Blend - this is the most complicated one. It blends all values on the wires together weighted by the power of the gadgets the wire comes from. If the combined power of the gadgets is less than 1 then it also blends in the value on the slider. So if all the input wires come from gadgets with 0 power then the slider will operate as if nothing is wired into it. We used to have only this blend mode but understandably people found it too confusing so we added the other simpler ones.
If you're using wireless receivers then you should be able to use the setup in the picture bu just replacing the nodes with receivers. Should save you 2 gadgets per cell hopefully! -
Im just curious - if the node or receiver output zero and by that turn itself down, will it be activated back again, once it receives some signal later?
-
hey it works. hooking output to shut down the gadget was not working. Because once it shutted itself down, it never got updated again.
But I lead the signal from receivers via ports and shutted down the port by the output of receivers (so once receiver get the signal it powers the port back on). And the calculators with blend mode are doing exactly what I was doing by 7 gadgets by one. Thats great.
Thanks for the tip with the blend mode. -
Ha, yeah I was on the train on the way home and realised the same thing! If you lose the power to the receiver then they won't operate anymore. A sneaky workaround would be to wire into each receiver's power a wire that carries a very small signal, like 0.0001. Should be just enough to keep the receivers updating but because the power is so low the output signal will have almost no affect on the result. Might allow you to get rid of the nodes.
Also another thought was that receivers are slightly more expensive than transmitters because they have zones to think about. The communication is two-way between transmitters and receivers so perhaps you could invert it so that each cell uses 4 transmitters to detect its neighbours rather than 4 receivers. Might make a difference in a level with hundreds of cells.
Be sure to update us on the end result when you get to i!
thanks
Matt
Please sign in to leave a comment.