Page 1 of 1

Combinator - Train Auto-Resupply

Posted: Fri Oct 16, 2015 10:00 pm
by Vile
Okay, so I did a search and couldn't find anything about this, but I'm sure it's a common problem. Basically, what I'm trying to do is have gun turrets at each outpost resupplied automatically, but I don't want to produce a ton extra and have to devote a separate train, or train car, to carrying a full load of ammo around on the off-chance my guns are running low.

Objective:
I want to have say...10 ammo in a box for each gun (unknown number of guns per outpost). I want the amount of missing ammo to be added up and sent to home base. Home base should make that much ammo (and no more), load it into a train car, and send it to back to the outpost. I am fine with a train devoted entirely to doing this as long as it only takes the amount needed so that it can be loaded with ore as it goes, The train can simply run a loop between loading ammo and all outposts. They can pull off what they need and load ore until full, then when it gets to the next outpost it might offload more ammo and now have space for more ore. The final stop can offload all ore before moving back to the ammo loading station to begin again. I don't want belts full of endless amounts of ammo, but rather clean belts that can be picked up and moved to a new location without a ton of waste.

Problem:
The trick is the time needed between the smart chests saying they're low and the ammo getting back to the guns. If you simply use a signal to say, "Make Ammo", then it will make far too much before the train actually gets it to the gun. I can say how much an outpost needs, but how to freeze that number in place, then decrement it each time one is made while reacting to changes in demand I can't figure. The only thing I can think of that might work would be a pulse generator that would add and subtract using a running total, but I can't seem to get this to work.

For those of you who love practical puzzles, this one's for you. :)

Re: Combinator - Train Auto-Resupply Help

Posted: Fri Oct 16, 2015 11:34 pm
by Lupoviridae
I would simply connect the smart chest at each outpost to a smart chest at the supply point in one big circuit network. Then have a smart chest that adds new ammo to the supply chest when the total ammo of the system is less than x. Any ammo in this supply chest is fed directly into a train by fast inserter. Smart inserts at each outpost connected directly by a second (green wire) network to the outpost chest, set to draw when ammo in that chest is less than y. No combinators needed.

Edit: If you set the train to remain at home base for a longer period of time, it can just make quick (5s) stops at each outpost, and the system will be very effective. I think I'm going to set this up in my world actually lol. Brilliant idea.

Re: Combinator - Train Auto-Resupply Help

Posted: Sat Oct 17, 2015 9:08 am
by Vile
Although that system is simplistic and would work to a degree, I think the amount of ammo needed would vary greatly from the amount needed as the train had to go further and further from base resulting in too much being put on the train over time. Playing with this, I now have a workable, and relatively simple system in place. I apologize for the wall of text as screenshots don't really show what's needed very well and I haven't figured out the blueprint output text as of yet. Hopefully it's straightforward enough to follow and replicate.

Image

Here’s what I did:

First I set a constant combinator (1) to output the desired amount of stored ammo in the total system. I chose 100 for each outpost, and currently have two outposts, so I set “C=200”. Then I filled boxes (A) and (C) with enough plates of iron and copper respectively to handle all needed ammo for the system. Overkill probably, but they’re easy to come by and since I'm only supplying the amount actually needed, this was very small.

Next, I plugged the output of constant combinator into the input of the arithmetic combinator (2) along with the green wire I chose to run through the power grid to my two outposts and hooked them to the two smart chests that hold the stored ammo there. In the combinator, I subtracted the total amount of ammo on hand from the amount I should have: “C-Ammo” and set that to output “A” for amount needed.

Decider combinator (3) received the input from “A” and the amount of iron stored in chest (B). It was set to “A > Iron”, output red signal to the two smart inserters (5) causing them to fill chest (B) with the amount of iron to match the amount of ammo needed to fill the system.

Decider combinator (4) was set to check the copper in box (D) against the iron in box (B). It was set to “Iron > Copper” output blue signal to the three inserters (6). This causes the box holding the ammo to release the correct amount to the train while counting how many were sent via copper in box (D) until output matches what was needed.

Decider combinator (7) was set to check the number of iron in box (B) against signal “A”. This way the amount needed would be reduced as each outpost received their ammo. It was set to “Iron > A” with output of “F”, for flush, to inserters (9) and (10). The iron and copper would recycle back into their respective storage boxes.

The entire system was duplicated for each outpost with only the number of needed ammo in the constant combinator being changed to match how much for that outpost instead of the whole system. Make sure not to cross red and green signal wires with other ammo in the system, or let the local outpost numbers collect data from other outposts. I did this by using green to connect the outposts to the main factory and red to connect the ammo storage in the outpost to the local decider group.
The output from the main base was loaded onto a dedicated train set to run to all outposts, hit my processing plant to drop off ore that was picked up along the way, and then return to the ammo supply point. The output at each outpost was put onto a belt and run to each storage box for the guns. I didn’t even need to loop it since the exact amount of ammo was put on the belt that the boxes needed to top off.

The only issues I found were 1) some latency caused the amount of ammo taken out of storage to be slightly different than the amount of copper plates moved. I noted this twice during groups of more than 100 ammo being supplied (only 98 were supplied instead of 100), and 2) priming the system with full boxes helped eliminate an issue where the amount needed changed at the exact moment ammo was deposited into the storage box at the far end of the system.

*Edit - fixed a logic issue and removed a combinator that wasn't needed.

Re: Combinator - Train Auto-Resupply

Posted: Sun Oct 18, 2015 12:44 am
by Lupoviridae
I see what you mean about the buildup, it would definitely be a problem. Still, I think I would solve that simply by putting a item flow counter (there's a post in the forums somewhere) right before the train, that counts how many are put in. A flow counter at each outpost subtracts from this total as items are transferred from the train to the local supply chest. Basically the network has some arbitrary signal that represents how many are in the train, and adds that to the circuit network total.

Re: Combinator - Train Auto-Resupply

Posted: Tue Oct 20, 2015 1:57 am
by Vile
Here is the blueprint code for what I was talking about. You'd simply plop this down where you want the train to load ammo from and set the total amount of ammo in the system in the constant combinator. You would put another wherever you want to disseminate that ammo from while setting the local constant amount of ammo. Make sure to prime all gun boxes first. Connect the top left power pole via signal wire to your gun crates. Load the copper and iron crates with a bit less than what you'll be storing in the local ammo crate so that if it runs out of ammo the count will still be accurate. I'm currently running about 300 guns using this and setting down a new outpost is cake-work now.
H4sIAAAAAAAA/9VYf2+bMBD9KhV/48o2pK3UMama1C9RTZEDTmrJ2MiYqRnKd58h5IcJEJtl69a/GuXufHfv7j07mbzjMiX8bpnUVGimGS2TuhYkp0mwIiVL
gVZElIVUGqwo10FYyNKYSZHUHwnA94twm4DofrHbhd5u+NxtTUoNmCip0lT17NHpmDBjiqbtNw9H3zIn5qD0nZa9k+BAfqPGYNx6OC94KiNMpRD7vEwD3wIU
fE9qRTPTzLav2yXLEoTDlKm0Yrr5hHfmr/HLWOfWfZnUa6ZKvSzZRhCe1HpbmER+MKUrwoOwy6v9EpgjgjZIqYnQCTT/5gVRREuVBF+DnVshwLsSdPNKVryi
jqVcn7B5c+k5lsNTiY+uGU1ZRhUwdayYaOqw/eNjy8+8ndqPm9E/+/jYNOctwEO2j5Yp6nlGF9B1WQ9DxzTND7gxJQUoONENbCVtYkxYp7IoTC8O9ja2oax0
UXnOSbFdprISerlWMl8yYQI0cPGSns+KEwh9CN1A6O1AaAM0jogNAXr0g2C4Ky8uGFiIzUfgwDluABje4RxQbtqpzP4VktMe+UT7PUJj5LNRlAqbfp52Oy8+
OCgOnCdUyFURDkQK/w8idRA390o+Wdymhwz5z1hkb7QFFPKcv6E5cvayhpYopt9zqo3rJKWhOZQWQXPQyLqNsZmNO7Kbhi+aZs3EqRifsfjmwnUFoyplYgNW
FedUg5xsyE8mms2QRohI25UAeBHfS7DzVRb4V5UFP/1JOR9Xnvla8npLJVlcWfJr5Hve53hhrfgk6e/JZR7Ul4jNIMrXm12cO8WDTg8meKrbXyFspkDIi0Wc
H3MzhXjokKlHQA/7Bzfs8cSax//WXAyMxSHwKAFGfggMKGy4Ztx0vPlJwlUYWh4xQvYEQyYy+tEGsh5zk+MftzmP/tBwPUA0HcBhA/cThSdTmCQiz1cvnD7P
IePfjjArb5c+OUAVO9/t8dHem+bjz7nZD/EiOlXhlHnUp8IrrznoGR/Old19IQsbjtjt0Mur6CQcjhfLIzAY2tB8CSwu64jpakD/begPs8t9yRkqbL+I9jNt
jmNp6+VcVthZ4nBcSEzcZ0V1pcTd8pmK7Bd+TPM6qRYAAA==

Re: Combinator - Train Auto-Resupply

Posted: Tue Nov 17, 2015 7:31 am
by nobodx
Currently all my outposts contain (at least) a Roboport with a few robots. I have a single train running around from base to all the outpost and back. The train transports a single stack of walls, turrets, repair packs and ammo.
Once it reaches a outpost, I use filtered smart inserters to take a set amount of stuff from the supply-train and put it into the local logistic network. Then the train moves in to the next outpost.
The initial fill up might take a while, but once that's done, only outpost under attack draw from it and most of the time, the train just drives around, enjoying the landscape ;) The thoughts behind this are, that most bases are attacked only every now and then, and stuff also gets destroyed only every now and then. And as long the Roboports are still active, any damage will be undone without any intervention needed from my side.

The only problem is, that I have a stack off all the supplies driving around plus another one waiting at the resupply station, waiting to be loaded onto that train.

My loading-area on the outposts ain't optimized for maximal loading-speed (I just use 4 fast inserters and load from one side only) but this way I have plenty of space to unload stuff at the same station.

I even went that far, to build a small production area inside my main trainstation (with hundreds of robots) to produce the supply's there.

If you want to see it in action, I can give you my savegame.