Page 1 of 1

[0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Mon May 18, 2020 5:09 pm
by Artyom
I done the research that increases the research speed of laboratories. And after that I spotted that number of science packs preloaded into single laboratory increased from 2 to 3. I thought it had a connection with that research (+50% of speed). But the problem is that 3 science packs are preloaded randomly. Especially strange is that it hasn't happened with red science packs.

I see 2 sides of the issue:
1. it is unpredictable behavior in case where it shouldn't
2. and as result it slightly brokes logic that I invented to control production of science packs based on number of laboratories and capacity of preloaded packs

Re: Unpredictable number of science packs preloaded into laboratory

Posted: Mon May 18, 2020 5:25 pm
by boskid
Your assumptions will break as soon inserters will have stack size > 1 or when you have lab with multiple input inserters since they check target content before movement and then they will try to push anything they have into the target.
Please follow the rules for posting bug reports (3638) like marking version, providing log file (well, not required here) and providing save file with reproduction. For now moving to pending.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Mon May 18, 2020 5:52 pm
by Artyom
I've remake the topic according to the rules (version and save file).
It seems I understand the reason. Due the increased stack size an inserter could load 1 pack (because only one was on belt at that time) and then load 2 packs (because the stack size eqauls to 2).

Sorry sometimes I forget that the stack size is increased after the research.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Mon May 18, 2020 6:32 pm
by Artyom
But despite the changed stack size, number of preloaded items in the target should be constant (for example, 2 in laboratory or 10 in turret).

There are my arguments. Let's assume that a chest can hold 100 items. And 99 items are already loaded in it. So even an inserter can load more than 1 item at the time, it loads only 1 item before the chest is full. So other types of containers (laboratories, factories, turrets and so on) should also have the limited and (what is more important) constant capacity.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 1:36 am
by 5thHorseman
Artyom wrote: Mon May 18, 2020 6:32 pm There are my arguments. Let's assume that a chest can hold 100 items. And 99 items are already loaded in it. So even an inserter can load more than 1 item at the time, it loads only 1 item before the chest is full. So other types of containers (laboratories, factories, turrets and so on) should also have the limited and (what is more important) constant capacity.
They do. That capacity is large, however. Try to put 1000 red science packs in a lab. You can not.
2 is not the maximum capacity of the lab. it's the number at which inserters will decide "I don't need to load more into here right now."
If a lab has 1 red science pack your inserter (which can load 2 items at a time) will grab 2 items and load them in. Not because it wants the lab to have 2, but because the lab has less than 2.
If a lab has 1 red science pack and you have 3 inserters that can each load 1 item, all of them will decide to load 1 item and your lab will end up with 4 items. Whichever one gets there first doesn't "win" and the other 2 don't give up and put their items back. They just load the items like they had originally intended to.

Which is okay to do as the total available space in the lab is far greater than 2.

If you want to make sure you have exactly the number you expect, you need to set all your stack sizes to 1 and make sure no 2 inserters could ever try to insert the same item at the same time. In your image, you could possibly do that by using filter inserters so - say - the labs on the right can't pass red science packs while the labs on the bottom can. Or just eliminate the multiple inserters.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 11:12 am
by Artyom
5thHorseman wrote: Tue May 19, 2020 1:36 am
They do. That capacity is large, however. Try to put 1000 red science packs in a lab. You can not.
2 is not the maximum capacity of the lab. it's the number at which inserters will decide "I don't need to load more into here right now."
If a lab has 1 red science pack your inserter (which can load 2 items at a time) will grab 2 items and load them in. Not because it wants the lab to have 2, but because the lab has less than 2.
If a lab has 1 red science pack and you have 3 inserters that can each load 1 item, all of them will decide to load 1 item and your lab will end up with 4 items. Whichever one gets there first doesn't "win" and the other 2 don't give up and put their items back. They just load the items like they had originally intended to.

Which is okay to do as the total available space in the lab is far greater than 2.

If you want to make sure you have exactly the number you expect, you need to set all your stack sizes to 1 and make sure no 2 inserters could ever try to insert the same item at the same time. In your image, you could possibly do that by using filter inserters so - say - the labs on the right can't pass red science packs while the labs on the bottom can. Or just eliminate the multiple inserters.
All you've wrote I understand. I see how inserters work with destinations like laboratories, factories etc. But that behavior is different unlike chests. The last ones always loaded to full capacity and this is predictable. That capacity is known so logic to act with them can be programmable. And though other destinations have the maximum capacity (I didn't check it), they are loaded at least to certain minimum capacity. And this is UNPREDICTABLE. Consequently such behaivor can't be programmable. I am not even saying that chests can be attached to circuit network.

Is it clear?

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 11:17 am
by Loewchen
Moved to gameplay help.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 1:46 pm
by Artyom
Loewchen wrote: Tue May 19, 2020 11:17 am Moved to gameplay help.
Why did you move the post to this section? Is it acceptable behavior of laboratories?

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 2:18 pm
by Loewchen
Artyom wrote: Tue May 19, 2020 1:46 pm Why did you move the post to this section? Is it acceptable behavior of laboratories?
Nothing you show is deviating from documentation, your setup does not work because it fails to control for any of the variables that define the input cap.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 2:19 pm
by MEOWMI
I don't quite follow. If you set the stack size to 1, do they not load a predictable amount of science packs every time? Afaik they will.

If you don't set the stack size to 1, they will load however many they can grab and this is intended behavior. edit: Inserters are not meant to solve everything automatically, they're meant to grab items when below a threshold.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 3:04 pm
by DerGraue
the labs that you are showing in your images also have 2 input inserters, one from the belt, one from the adjacent lab. If the inserters want to insert a new pack, both of them will do so at the same time, depending on if there are items on the belt and if there are items left in the lab. Therefore you can easily end up with more than 2 or even 3 items in the lab. So congratulations, you build an unpredictable setup.

Also, inserters always try to pick up the maximum amount of items if they can. That also applies for chests that have only space for 1 single item left.

Re: [0.18.24] Unpredictable number of science packs preloaded into laboratory

Posted: Tue May 19, 2020 8:24 pm
by 5thHorseman
In short, your labs have an unpredictable number of science packs because you built it to do so.

The big is not in the game, but in your setup.