Page 1 of 1

Compare four items

Posted: Wed Aug 07, 2019 4:42 pm
by PowerCheez
Ok, so heres the idea. From one (1) Cargo wagon, I'd like to use one (1) filter inserter to extract exactly 50 pcs each of 4 different items. Can it be done? I've scratched my head quite alot but have to admit defeat.

Re: Compare four items

Posted: Thu Aug 08, 2019 12:57 am
by mmmPI
There is this thing i tried :
50pcs.jpg
50pcs.jpg (310.83 KiB) Viewed 2444 times
When the chest is empty, there are 4 filters on the inserter, when 1 item is at quantity 50, it does [50*(-1)] + 50 = 0, so the filter disable and the inserter change item, untill all quantities are the same as specified on constant combinator. Then it just stop like on the picture.

It is slow with only 1 filter inserter, because of the override stack size, a stack filter inserter with stack size 5 or 10 could do faster :)

This work ?

Re: Compare four items

Posted: Thu Aug 08, 2019 1:39 am
by DaveMcW
If you set the constant value to 2147483597, you can skip the arithmetic combinator by using integer overflow.

Re: Compare four items

Posted: Thu Aug 08, 2019 2:55 am
by mmmPI
So there is this other thing that function in mysterious ways:
110010pcs.jpg
110010pcs.jpg (133.81 KiB) Viewed 2434 times
2,147,483,598 for some reason :shock:

i tried with 2,147,483,647 it took me some time to realize i had to go backward, and still not sure what i was doing i stopped when it was fine.
Then i realise you had made the math already.

If you use 2,147,483,647, there is 1 of each item that end up in the chest before the system stop.

I can only explain the easier solution with the extra combinator :mrgreen:

Re: Compare four items

Posted: Thu Aug 08, 2019 9:00 am
by PowerCheez
mmmPI wrote:
Thu Aug 08, 2019 12:57 am
There is this thing i tried :
50pcs.jpg

When the chest is empty, there are 4 filters on the inserter, when 1 item is at quantity 50, it does [50*(-1)] + 50 = 0, so the filter disable and the inserter change item, untill all quantities are the same as specified on constant combinator. Then it just stop like on the picture.

It is slow with only 1 filter inserter, because of the override stack size, a stack filter inserter with stack size 5 or 10 could do faster :)

This work ?
That's great! It worked like a charm. I'll start building my support train differently from now on! :P

Re: Compare four items

Posted: Thu Aug 08, 2019 12:04 pm
by mrvn
The 2,147,483,647 magic is the 32bit signed integer overflow. 2,147,483,647 + 1 == -2,147,483,648.

That aside I use a similar setup. Nut not limited to 1 inserter.

Instead I have 1 filter inserter with override stack size = 1. Then 1 stack filter inserter with an extra decider combinator set to "each > 12 = each" and 4 more stack filter inserter with a decider combinator "each > 60 = each". So as long as the item count is >60 all 6 inserters work. Then when I get close to the goal count first it drops to 2 inserters (<= 60 missing items) and then to the single filter inserter (<= 12 items). That way I don't have to wait forever for larger counts.

Re: Compare four items

Posted: Thu Aug 08, 2019 12:23 pm
by mmmPI
mrvn wrote:
Thu Aug 08, 2019 12:04 pm
The 2,147,483,647 magic is the 32bit signed integer overflow. 2,147,483,647 + 1 == -2,147,483,648.
I have heard of that, i don't what is happening in this particular case though.

2,147,483,598 is a smaller number than the overflow one, why would it act as a negative ? i realised i had to count backward in game i had closed the forum tab, at this point I questionned my understanding :)
mrvn wrote:
Thu Aug 08, 2019 12:04 pm
That aside I use a similar setup. Nut not limited to 1 inserter.

Instead I have 1 filter inserter with override stack size = 1. Then 1 stack filter inserter with an extra decider combinator set to "each > 12 = each" and 4 more stack filter inserter with a decider combinator "each > 60 = each". So as long as the item count is >60 all 6 inserters work. Then when I get close to the goal count first it drops to 2 inserters (<= 60 missing items) and then to the single filter inserter (<= 12 items). That way I don't have to wait forever for larger counts.
I can picture that, will keep inside a little room in my head :)

Re: Compare four items

Posted: Thu Aug 08, 2019 1:21 pm
by mrvn
mmmPI wrote:
Thu Aug 08, 2019 12:23 pm
mrvn wrote:
Thu Aug 08, 2019 12:04 pm
The 2,147,483,647 magic is the 32bit signed integer overflow. 2,147,483,647 + 1 == -2,147,483,648.
I have heard of that, i don't what is happening in this particular case though.

2,147,483,598 is a smaller number than the overflow one, why would it act as a negative ? i realised i had to count backward in game i had closed the forum tab, at this point I questionned my understanding :)
2,147,483,647 + 1 == 2,147,483,598 + 50 == -2,147,483,648

Re: Compare four items

Posted: Thu Aug 08, 2019 3:01 pm
by mmmPI
mrvn wrote:
Thu Aug 08, 2019 1:21 pm
mmmPI wrote:
Thu Aug 08, 2019 12:23 pm
I have heard of that, i don't UNDERSTAND what is happening in this particular case though.
2,147,483,647 + 1 == 2,147,483,598 + 50 == -2,147,483,648
I added the word i forgot maybe that's better to understand my sentence if i write all the words sorry x)

From that i am reminded of the "complement of something" logic, but i can't picture in my head what is happening exactly ( or even remotely) with the 1 and 0 for the game to have overflow that you can use to implement that logic and predict the behavior.

Now I understand it as , you need 50 in the chest so the quantity stop being a very high positive and become neutral (0).

I would compare that to a score board that has only 1 digit, but this extraordinary game reach the digit 8, then 9, and then it stop showing something positive ,the 1 is hidden the display can't show 10.

I will give another thought to see if can use that in other situations thanks for explaining !

Re: Compare four items

Posted: Thu Aug 08, 2019 3:14 pm
by mrvn
mmmPI wrote:
Thu Aug 08, 2019 3:01 pm
mrvn wrote:
Thu Aug 08, 2019 1:21 pm
mmmPI wrote:
Thu Aug 08, 2019 12:23 pm
I have heard of that, i don't UNDERSTAND what is happening in this particular case though.
2,147,483,647 + 1 == 2,147,483,598 + 50 == -2,147,483,648
I added the word i forgot maybe that's better to understand my sentence if i write all the words sorry x)

From that i am reminded of the "complement of something" logic, but i can't picture in my head what is happening exactly ( or even remotely) with the 1 and 0 for the game to have overflow that you can use to implement that logic and predict the behavior.

Now I understand it as , you need 50 in the chest so the quantity stop being a very high positive and become neutral (0).

I would compare that to a score board that has only 1 digit, but this extraordinary game reach the digit 8, then 9, and then it stop showing something positive ,the 1 is hidden the display can't show 10.

I will give another thought to see if can use that in other situations thanks for explaining !
That's pretty much what happens. It's a wheel in the scoreboard. But instead of going from 0-9 is goes from -2,147,483,648 to 2,147,483,647. It simply loops around to the negative numbers when it gets too big.