I have multiple chests which are in close proximity and all store large amounts of metal plates. I would like to distribute the load evenly between them, so that all chests always contain roughly the same amount of plates.
Preferably I would like to have some setup where when any chest has more plates than the others, those plates are moved to the chests with less plates. Alternatively I would also be satisfied with some setup which ensures that the chests are filled or emptied in order of fill-state. How can I do that?
Background: The chests are part of my train station. To optimize loading and unloading times I would like to avoid uneven distribution between chests or train cars.
I would prefer a solution which doesn't require any mods.
Best Answer
After some experimenting I found a setup which works quite well. It is based on an idea that only those chests will be filled which have below average item count:
iron plates / 6 = BLUE
.iron plates < BLUE
(except for the first inserter which isn't connected to any network at all. This is important to avoid a deadlock when all chests are perfectly balanced). This means the inserter will work when the chest they serve has below average iron plates.BLUE - 1 = GREEN
.iron plates < GREEN
. That means they will start taking plates from the right neighbor chest when the chest they serve is more than 1 below average. The purpose of the -1 difference is to make sure that chests prefer to take items from the ring than from the neighbor. Without that there will be an infinite loop because the last chest will feed an item back into the ring the moment the first chest picks one up.The result is that all metal plates which enter the system will be evenly distributed along the chests. When plates are manually removed from one of the chests, the inserters will rebalance by moving items from right to left to refill that chest. The last will move plates back into the ring which will then be picked up by the first chest. After a while the chests will be balanced again.
Also, the upper part of it is free (the electric poles and combinators could easily be placed further south) so a trainstop could be placed there to fill and empty the system. A method to empty the system without blocking train access would be an additional inserter right of the rightmost chest.
The only flaw in the design is that the first chest will always have slightly above average number of items. But considering that I built the design to handle large quantities of items I consider that acceptable.