Skip to main content

Search

Help with logic - select smallest value (0 excluded)

  • Mm Bogdan & Matt

    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

  • Mm Bogdan & Matt

    A picture might help!

  • Agarwel

    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

  • Agarwel

    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

  • Mm Bogdan & Matt

    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!

  • Agarwel

    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?

  • Agarwel

    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.

  • Mm Bogdan & Matt

    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.