Unified unloading priority list to prevent undesired machine deadlocks when handling many items
Posted: Wed Oct 01, 2025 7:45 am
by Xeinaemm
Context
The problem becomes norm when you hit endgame, beaconed, legendary quality stage, and you need to handle mixed flows. But breaks the game engine when you stress test Space Age's new machines that support belt stacking. As a gamer with knowledge of programming and circuit networks, I can fix this, but the typical gamer shouldn't be "fixing" such problems, which require advanced engineering knowledge.
I will use as an example Fulgora and scrap recycling.
The two most notorious troublemakers that miss it are the recycler and the stack inserter
The recycler got a patch that reshuffled priority to increase throughput. But when you push the machine to its limits... Holmium ore is rarely unloaded properly, even if it should have the highest priority. The engine is fine to stay at 46-50 holmium limit, even if it will clog itself next cycle again and again.
Stack inserter is supposed to wait for input while handling belts, and it's OK to wait to pick up a full stack, but there still should be a timeout. But this same logic shouldn't be applied to the containers (chests, machines) when unloading, and should be more picky and smarter. Recycling a low density structure will deadlock itself in less than 2 seconds if you use the stack inserter, because it will wait for steel where there are 100 copper plates to unload in the machine.
Solution
Unload logic priority pseudocode(I avoided some negations even if it shortens logic):
1. Sort items descending (like insertion sort and dynamic sorting on a small set of items)
1.1 (optional) sort by difference to the item's stack limit and the projected amount produced in the next machine cycle that will cross the limit threshold
2. If the machine supports stack size and belt stacking(like stack inserter), and you pull from "container" (chests, machines)
2.1 Pick up the first item where item count >= stack size and do "working logic"
2.2 else "wait and don't pick up anything logic"
3. Pick up the first item and do "working logic"
4. Return to point 1.
Blueprint with showcase and potential fix(you need creative mode with infinity chests):
Re: Unified unloading priority list to prevent undesired machine deadlocks when handling many items
Posted: Wed Oct 01, 2025 11:10 am
by Xeinaemm
This will also have benefits for the machine and the inserters' throughput.
Stack inserters with a priority list produced a perfect half belt throughput (7200 items processed) than the recycler itself (6324 items processed) in 60 seconds.
Re: Unified unloading priority list to prevent undesired machine deadlocks when handling many items
Posted: Wed Oct 01, 2025 12:18 pm
by Rseding91
I think you're misunderstanding how to use recyclers... your example with the recycler putting directly onto a belt is the correct ways to interact with recyclers (and why they auto-eject as an option). If you want to interact with them in any other way - you can - but you then need to deal with the limitations you've discovered.
Stack inserters are specifically programmed to always and only ever wait for a full stack of items and never time-out until they have the full belt stack of items. If that's not the behavior you want - then don't use them.
Re: Unified unloading priority list to prevent undesired machine deadlocks when handling many items
Posted: Wed Oct 01, 2025 12:34 pm
by Xeinaemm
I think you're misunderstanding how to use recyclers... your example with the recycler putting directly onto a belt is the correct ways to interact with recyclers (and why they auto-eject as an option). If you want to interact with them in any other way - you can - but you then need to deal with the limitations you've discovered.
If you look into the examples, you will find that even in the correct way, it cannot handle logic as you suggest and starts malfunctioning at 105/s.
PS: As I remember, the last time someone created a mod that changed recycler priorities and increased throughput, you patched it almost the next day.
PS2: 2.0.30
Re: Unified unloading priority list to prevent undesired machine deadlocks when handling many items
Posted: Wed Oct 01, 2025 1:25 pm
by Xeinaemm
Stack inserters are specifically programmed to always and only ever wait for a full stack of items and never time-out until they have the full belt stack of items. If that's not the behavior you want - then don't use them.
The timeout was only a suggestion. I thought a little more about the second part.
But if "specifically programmed stack inserters" are smart enough to have "Waiting for more items" (I don't have enough items) and "Waiting for source items"(I don't have anything). But then why are they dumb enough to pick up the first item that doesn't even meet their purpose if they can choose one that matches their purpose?