Compare four items

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
PowerCheez
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue May 21, 2019 10:59 am
Contact:

Compare four items

Post by PowerCheez » Wed Aug 07, 2019 4:42 pm

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.

mmmPI
Filter Inserter
Filter Inserter
Posts: 324
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Compare four items

Post by mmmPI » Thu Aug 08, 2019 12:57 am

There is this thing i tried :
50pcs.jpg
50pcs.jpg (310.83 KiB) Viewed 198 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 ?

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

Re: Compare four items

Post by DaveMcW » Thu Aug 08, 2019 1:39 am

If you set the constant value to 2147483597, you can skip the arithmetic combinator by using integer overflow.

mmmPI
Filter Inserter
Filter Inserter
Posts: 324
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Compare four items

Post by mmmPI » Thu Aug 08, 2019 2:55 am

So there is this other thing that function in mysterious ways:
110010pcs.jpg
110010pcs.jpg (133.81 KiB) Viewed 188 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:

PowerCheez
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue May 21, 2019 10:59 am
Contact:

Re: Compare four items

Post by PowerCheez » Thu Aug 08, 2019 9:00 am

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

mrvn
Smart Inserter
Smart Inserter
Posts: 3520
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Compare four items

Post by mrvn » 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.

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.

mmmPI
Filter Inserter
Filter Inserter
Posts: 324
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Compare four items

Post by mmmPI » 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 :)
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 :)

mrvn
Smart Inserter
Smart Inserter
Posts: 3520
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Compare four items

Post by mrvn » Thu Aug 08, 2019 1:21 pm

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

mmmPI
Filter Inserter
Filter Inserter
Posts: 324
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Compare four items

Post by mmmPI » 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 !

mrvn
Smart Inserter
Smart Inserter
Posts: 3520
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Compare four items

Post by mrvn » Thu Aug 08, 2019 3:14 pm

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.

Post Reply

Return to “Gameplay Help”

Who is online

Users browsing this forum: Google [Bot]