Circuit net: help with saving max value in a memory cell

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
KAA
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Tue Dec 06, 2016 4:50 pm
Contact:

Circuit net: help with saving max value in a memory cell

Post by KAA »

Hi again!
So my base is growing and new question appears.
I'm an engineer in life but it's a shame to admit - I'm stupid in factorio circuit network logic.
I cannot get how game ticks influence logic circuits that I design,
Maybe you can help me.

So, I have a chest that is filled with something like the following (one number - one, let's say, second, let's call this chest "C")
And below is what I need my memory to display (let's call it "Z"):
C: 0-1-0-0-0-0-2-2-1-1-0-0-0-0-0-3-3-2-1-0-0-0...
Z: 0-1-1-1-1-1-2-2-2-2-2-2-2-2-2-3-3-3-3-3-3-3...

I hope you got it. Will be glad to the complete solution.

But if you are interested, here is how I do it, maybe you can just correct me.

This is my solution:
2017-11-04 19_24_26-Factorio 0.15.37.png
2017-11-04 19_24_26-Factorio 0.15.37.png (341.34 KiB) Viewed 1741 times
Combinators are following:
2017-11-04 19_25_17-Factorio 0.15.37.png
2017-11-04 19_25_17-Factorio 0.15.37.png (59.8 KiB) Viewed 1741 times
2017-11-04 19_25_28-Factorio 0.15.37.png
2017-11-04 19_25_28-Factorio 0.15.37.png (58.33 KiB) Viewed 1741 times

My logic is the following:
Z - resulting variable, A - temporary.
Decider combinator sends 1 in case input signal is larger that Z
Arithmetic combinator than adds this 1 to resulting signal.
If it's not enough and input decider signal is still larger than Z, decider still sends 1,
And arithmetic combinator adds 1 again,

After signals get equal or input becomes less, decider combinator sends nothing, so arithmetic combinator just adds 0 constantly, keeping Z constant.

But what I'm getting is following:
C: 0-1-0-0-2-1-0-0-3-3-2-2-1-1-0-0-0-4-3-2-1-0-0-0...
Z: 0-2-2-2-2-2-2-2-4-4-4-4-4-4-4-4-4-6-6-6-6-6-6-6...

I just don't know what's wrong here...

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Circuit net: help with saving max value in a memory cell

Post by DaveMcW »

The problem is your temporary variable A exists for 2 ticks before Z updates, so every increment is +2 instead of +1.

You could run A through a timer/filter, so it is only allowed to exist once per 5 ticks (the filter itself increases the lifetime of A, so you can't just use once per 2 ticks).

Or you could reset the memory cell instead of incrementing it, like this:
Blueprint

KAA
Long Handed Inserter
Long Handed Inserter
Posts: 70
Joined: Tue Dec 06, 2016 4:50 pm
Contact:

Re: Circuit net: help with saving max value in a memory cell

Post by KAA »

Yes, reset seems more valid option because it can have more places to apply than just increment.
I tested this and it works.
Thanks a lot!

Post Reply

Return to “Gameplay Help”