Remember Lowest / Highest Value
Posted: Mon Sep 12, 2016 11:29 pm
So as part of a system to keep track of how many robots I have in a network, and to add more when demand rises (less than 5% available bots), I needed a circuit that could remember a demand for robots and if the number fell below that before I could meet the demand it needs to remember the new number instead. As robots are added they are counted off from memory.
Surprisingly I couldn't find anything on the topic. There is a little bit on memory cells, jumping from very basic (decider looped to itself) to really complex stuff I have no hope of understanding at this time of night lol. Guess I'll get to work.
First off I created a reasonably complex setup with a timer that would process once every five ticks, 8 combinators total. I didn't like the way part of it worked so ripped it out, flipped something around and suddenly it's only three combinators and works every tick o_O gotta love unexpected efficiency (EDIT: Circuit Master XKnight pointed out there are fringe cases with every tick that won't be properly remembered)
This is actually really simple in premise. Firstly the comparer checks if the new value is lower/higher than the stored value, if it is it is, output. This disables the memory decider, clearing outs its previous value, and [A] is also converted to signal . is looped through memory and straight back to the comparer, as [A] now equals it stops outputting. This re-enables the memory unit to pick up the last tick of signal which it then stores. If the value is getting lower with every tick, the comparer simply keeps outputting [A] and is updated accordingly in the very next tick.
I will be connecting a roboport to some basic logic to take ([total robots] / -20) + [available robots] to provide the input. This gives me a negative number of how many robots below 5% I have available. Then I'll connect an inserter to the input of the memory cell to pulse any items it moves (will change to logistics bots), so as items are added the demand is "forgotten" until a higher demand arises. I guess you'd call this a "Demand Counter" or something? I can't actually think of any circumstance it would be used other than for counting robots in the network but hey, you never know =P
Surprisingly I couldn't find anything on the topic. There is a little bit on memory cells, jumping from very basic (decider looped to itself) to really complex stuff I have no hope of understanding at this time of night lol. Guess I'll get to work.
First off I created a reasonably complex setup with a timer that would process once every five ticks, 8 combinators total. I didn't like the way part of it worked so ripped it out, flipped something around and suddenly it's only three combinators and works every tick o_O gotta love unexpected efficiency (EDIT: Circuit Master XKnight pointed out there are fringe cases with every tick that won't be properly remembered)
This is actually really simple in premise. Firstly the comparer checks if the new value is lower/higher than the stored value, if it is it is, output. This disables the memory decider, clearing outs its previous value, and [A] is also converted to signal . is looped through memory and straight back to the comparer, as [A] now equals it stops outputting. This re-enables the memory unit to pick up the last tick of signal which it then stores. If the value is getting lower with every tick, the comparer simply keeps outputting [A] and is updated accordingly in the very next tick.
I will be connecting a roboport to some basic logic to take ([total robots] / -20) + [available robots] to provide the input. This gives me a negative number of how many robots below 5% I have available. Then I'll connect an inserter to the input of the memory cell to pulse any items it moves (will change to logistics bots), so as items are added the demand is "forgotten" until a higher demand arises. I guess you'd call this a "Demand Counter" or something? I can't actually think of any circumstance it would be used other than for counting robots in the network but hey, you never know =P