Is this train setup possible with circuits?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
HadesSupreme
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Fri Nov 03, 2017 3:53 pm
Contact:

Is this train setup possible with circuits?

Post by HadesSupreme »

Hello. Here's what I'd like to do:

1. My unloading stations tally up the items in their chests. Then divide by the maximum capacity, get out a "fullness" value in %. So 2k iron out of 10k iron storage would leave me with a value of 20 iron. Easy.
2. Convert that to an "emptiness" value. So now we have the % empty, in our example this would leave a value of 80 iron. Also Easy.
3. Send that signal to the radar network, take Max(all of those signal sources), tell me which resources are the most empty, send signal to trains to go to the resource that is most empty. So if we have signals from stations of 80 iron, 30 iron, 40 copper, we'd get an output of 80 iron and 40 copper.

Is there any easy way to do step 3? It would be easy to take the average emptiness by sending a separate signal of 1 for each item type and dividing by that, but I can't figure out a way to do a max function, and doing an average could theoretically lead to a situation where certain resources never get filled because one unloading station is empty while the rest are full and pushing down the average emptiness.
jaylawl
Fast Inserter
Fast Inserter
Posts: 175
Joined: Sat Nov 23, 2024 10:14 am
Contact:

Re: Is this train setup possible with circuits?

Post by jaylawl »

You can get a min or max value (kind of) with the new selector combinator. For this you would have to use mode of operation "Select input", use index 0 and then use either ascending or descending depending on whether you need min or max.

The "kind of" part comes in where factorio signals do not differentiate between zero and null. So it's not a perfect min/max function.

I hope this helps.
Tertius
Smart Inserter
Smart Inserter
Posts: 1091
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Is this train setup possible with circuits?

Post by Tertius »

You don't need this complex setup, if you employ enough trains and generally make sure your production is slightly higher than your consumption, so all stations eventually fill up their buffers, so there isn't any station that is most empty.

In this scenario, a station running empty is a sign to build more production, not to balance the under-production. Since the factory will always grow, you need to build more production anyway.
waterBear
Long Handed Inserter
Long Handed Inserter
Posts: 99
Joined: Thu Apr 23, 2020 2:05 pm
Contact:

Re: Is this train setup possible with circuits?

Post by waterBear »

HadesSupreme wrote: Fri Dec 06, 2024 3:20 am Hello. Here's what I'd like to do:

1. My unloading stations tally up the items in their chests. Then divide by the maximum capacity, get out a "fullness" value in %. So 2k iron out of 10k iron storage would leave me with a value of 20 iron. Easy.
2. Convert that to an "emptiness" value. So now we have the % empty, in our example this would leave a value of 80 iron. Also Easy.
3. Send that signal to the radar network, take Max(all of those signal sources), tell me which resources are the most empty, send signal to trains to go to the resource that is most empty. So if we have signals from stations of 80 iron, 30 iron, 40 copper, we'd get an output of 80 iron and 40 copper.

Is there any easy way to do step 3? It would be easy to take the average emptiness by sending a separate signal of 1 for each item type and dividing by that, but I can't figure out a way to do a max function, and doing an average could theoretically lead to a situation where certain resources never get filled because one unloading station is empty while the rest are full and pushing down the average emptiness.
I wrote up a very similar design here: 123723

In my opinion, it's best not to worry about sorting which resources are more or less in demand - better to avoid making any decision at all about which train to send where. Just open up the exact number of loading stations you need and let the trains figure out where to go until all demand is met.

If you don't have enough trains, then either system will result in something being under supplied or left empty.
HadesSupreme
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Fri Nov 03, 2017 3:53 pm
Contact:

Re: Is this train setup possible with circuits?

Post by HadesSupreme »

Tertius wrote: Fri Dec 06, 2024 10:06 am You don't need this complex setup, if you employ enough trains and generally make sure your production is slightly higher than your consumption, so all stations eventually fill up their buffers, so there isn't any station that is most empty.

In this scenario, a station running empty is a sign to build more production, not to balance the under-production. Since the factory will always grow, you need to build more production anyway.
I don't want to have to remember how many trains I have or remember to delete/make a new train when I delete/make a new stop though. That's kind of the point. It's irritating having my factory stopped for an hour while I'm on another planet because I forgot to check one of these before getting distracted doing something else.

Right now I do have a generic pickup schedule weighted by priority but unfortunately there's no way I can tell to connect that to prioritizing the dropoff point with the fewest goods.
jaylawl wrote: Fri Dec 06, 2024 9:15 am You can get a min or max value (kind of) with the new selector combinator. For this you would have to use mode of operation "Select input", use index 0 and then use either ascending or descending depending on whether you need min or max.

The "kind of" part comes in where factorio signals do not differentiate between zero and null. So it's not a perfect min/max function.

I hope this helps.

Hmm, I don't think this works. This can count separate signals (e.g. if I have a signal of 50 coal and 30 iron it will output 2), but it doesn't work for multiple sources of the same signal (e.g. 30 iron and 50 iron will add to one signal of 80 iron and the counter will then output 1).

Basically what I need is either some of separating out signals after they are added together, or some way of generically converting each signal into a separate signal type before its sent to the radar so they aren't added together...
Post Reply

Return to “Gameplay Help”