Factorio

Factorio

View Stats:
Track switch with circuit network
Hey,
I have a quick question to people smarter than me. I have big stations with number of tracks with steel plates output waiting for train, because of how the AI works, train will always pick shortest route, meaning if next train come right after first one leaves station freeing its track, it will pick the same track, grabing cargo from same boxes. To avoid this problem i tried building simple network so that once track 1 was taken, even if the train already has left, still next train will have to take track #2, next one #3 and so on until last track, which will reset it to #1, to avoid overtaking from one track when other tracks are full of cargo.
I was close to the solution but im having problem with first track and im surprised i cannot find anywhere similiar problem/solution for Factorio. Would be great if you could come in and share any ideas :>
< >
Showing 1-14 of 14 comments
brian_va Mar 12, 2023 @ 2:05pm 
theres probably quite a few ways to do this, but what i do is disable the rail signal leading into the station when there isn't enough for a full train. the main reason is i want the trains waiting in the stacker before these stations, not sitting full or empty somewhere else.

obviously i'm modded here using the bulk rail loader mod, warehouse mod and miniloader mod, but you can do the same in vanilla.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946196970

focus on the stations above and below the warehouses storing copper ore. the bottom one is the unload and the top is the loading station. theres a red wire from each bulk rail loader (you would wire each box for each wagon together but dont mix wagons, if thats what you were using) going to a decider combinator, set to everything >= to 10k (modded wagons, not sure of vanilla capacity if its different) and output 1 (number and the bubble). theres one of these sets per cargo wagon.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203677

all the decider's outputs are also wired together, going to an arethmetic combinator; input is each plus 0, and output is each.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203766

they all lead to a decider combinator set to condition each = 8 (again adjust to your number of wagons) and to output green selecting the output option of input count.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203843

that then goes to the rail signal, with the mode set to read signal, and red/yellow/green should be the respective colors.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946204023

the input station is more or less the same, just set to output green to the rail signal if each is less or equal to 7, meaning there is a loader that doesn't have a full load for a cargo wagon.
Last edited by brian_va; Mar 12, 2023 @ 2:58pm
Fel Mar 12, 2023 @ 2:10pm 
Train limits is what you want.
You can either set them as a specific value or set it with circuit network (on the stop).
Hedning Mar 12, 2023 @ 3:13pm 
If you don't want the next train to go to a recently visited stop before it has had time to fill back up again you can either disable the station or reduce the train limit to 0.

Eg it starts with a train limit of 1 and then when the train has emptied the chest you signal the station to set limit to 0 until the chests have had time to fill up again.

Another way is to simply have enough trains that it doesn't matter that a train is standing in a station that doesn't have a full load ready. If you just add a third train that can go to the full station while your second train is slowly being loaded at the empty station.
Last edited by Hedning; Mar 12, 2023 @ 3:17pm
Chindraba Mar 12, 2023 @ 3:41pm 
Sometimes you do want the near station used more often anyway, especially for ores. As long as it can fill trains fast enough to keep production going, anyway. The sooner the ore field is depleted the sooner you can remove the mines and build factories there. That being said, however, the best solution I found, reliable in all cases I've seen, is Hedning's. Set the stop's limit to 0 unless there's enough in the chests to fill a train. (Don't forget to count each 'car-worth' of chest separately - 9000 ore in the first 4 chests will still not fill a 4 car train.)
knighttemplar1960 Mar 12, 2023 @ 4:46pm 
As long as you have balanced the chests loading your train you can simply wire all the chests to a single arithmetic combinator, divide the total in the chests by the capacity of your train, subtract 1 from the result and use the result to set the train limit on the station.

As long as the station that has the shortest path has a limit of 1 or more the train will go there. When the math takes it to a zero that station allows zero trains to enter and will stay that way until the station accumulates enough material for the train limit to be set to 1 and allow a train to enter the station.

The best solution, as Hedning mentioned, is just to have enough trains that both/all stations get used. In that case you must assure that you have enough slots in your stacker to accommodate the total amount of trains that could be requested by the compound station to make sure that you don't get a traffic jam at the entrance to your station(s).
Originally posted by brian_va:
theres probably quite a few ways to do this, but what i do is disable the rail signal leading into the station when there isn't enough for a full train. the main reason is i want the trains waiting in the stacker before these stations, not sitting full or empty somewhere else.

obviously i'm modded here using the bulk rail loader mod, warehouse mod and miniloader mod, but you can do the same in vanilla.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946196970

focus on the stations above and below the warehouses storing copper ore. the bottom one is the unload and the top is the loading station. theres a red wire from each bulk rail loader (you would wire each box for each wagon together but dont mix wagons, if thats what you were using) going to a decider combinator, set to everything >= to 10k (modded wagons, not sure of vanilla capacity if its different) and output 1 (number and the bubble). theres one of these sets per cargo wagon.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203677

all the decider's outputs are also wired together, going to an arethmetic combinator; input is each plus 0, and output is each.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203766

they all lead to a decider combinator set to condition each = 8 (again adjust to your number of wagons) and to output green selecting the output option of input count.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946203843

that then goes to the rail signal, with the mode set to read signal, and red/yellow/green should be the respective colors.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946204023

the input station is more or less the same, just set to output green to the rail signal if each is less or equal to 7, meaning there is a loader that doesn't have a full load for a cargo wagon.

Wow, thank you for taking your time to explain everything!
Actually this is much better than my idea as it simply allows for stations to work not with order/assigned numbers. I could just sum everything up and check if there is more than train wants to take but your idea actually checks even if each wagon has enough - awesome!
Im using train buffer/stacker myself, using chain signals trains patiently wait for available station.
Maybe it's just because im tired, i had at first a little problem to understand what was happening along your explanation but in short time i believe i got it and actually understood better how networks work in this game :D
Although i must say i am not 100% sure why arethmetic combinator uses Each as output.

Still i am having problem making it work, i know theory how to later scale it to full station (using some mods myself of course but not for that, i use here 4 wagons, and 4 chests at each spot).
Below my test place trying to make it work. I believe becuase chests are empty, i did not put stack of plates (or any other item, should work also with condition for specific item as i understand this) inside, so the signal should change, but not matter what i do, train signals stays green, are you sure i shouldnt use stop train option at signal?
Maybe you are able to tell what im doing wrong in here, 3 chest represent 3 wagons, then check if all are correct and then singal output?

https://steamcommunity.com/sharedfiles/filedetails/?id=2946655808

https://steamcommunity.com/sharedfiles/filedetails/?id=2946655952

https://steamcommunity.com/sharedfiles/filedetails/?id=2946655997

https://steamcommunity.com/sharedfiles/filedetails/?id=2946656018

If i can make it work this would be perfect solution. As i said in theory just counting everthing in total should also work as there should be an even amount available but id love to make it work to avoid any possibilites!
Again thanks for help and hope you can correct me on what's incorrect there
Originally posted by Fel:
Train limits is what you want.
You can either set them as a specific value or set it with circuit network (on the stop).

hmm can you elaborate on the idea? I am not sure how that could help, and whole problem was how to make it connect between stations. eg. when i have 5 stations with steel plates. Even if i was to change manually train count for each station, i still have to somehow make the network... and that's my problem here ;P
Originally posted by Hedning:
If you don't want the next train to go to a recently visited stop before it has had time to fill back up again you can either disable the station or reduce the train limit to 0.

Eg it starts with a train limit of 1 and then when the train has emptied the chest you signal the station to set limit to 0 until the chests have had time to fill up again.

Another way is to simply have enough trains that it doesn't matter that a train is standing in a station that doesn't have a full load ready. If you just add a third train that can go to the full station while your second train is slowly being loaded at the empty station.

Hey, thanks for reply
As i explained in previous comment, train count still would need me to make a network to make checks and that's my problem here xp

Aand about increasing number of trains... first of all it's not possible as it serves as output station, i can add more trains but if such number of materials isnt required at the moment, they won't come back soon for another batch anyway so that really won't work... and it doesn't fix the problem, but just skips it haha
And i would have to have bigger production then it is physicly possible to load~
Originally posted by Chindraba:
Sometimes you do want the near station used more often anyway, especially for ores. As long as it can fill trains fast enough to keep production going, anyway. The sooner the ore field is depleted the sooner you can remove the mines and build factories there. That being said, however, the best solution I found, reliable in all cases I've seen, is Hedning's. Set the stop's limit to 0 unless there's enough in the chests to fill a train. (Don't forget to count each 'car-worth' of chest separately - 9000 ore in the first 4 chests will still not fill a 4 car train.)

I'm actually using unlimited recources so that's one problem less for me. I don't enjoy having to rebuild bases, i like more focusing on expanding and thinking on logical/factory problems, thus instead what i do i make modded rail world with really distanced recources and i have heavly multiplied # of required potions for research making me created bigger factories to supply everything.

Train count count be basic solution but won't be perfect as and i still would kinda have to build network (train count or just connecting it to the train signal with condition).
Still it is better that what i have now! hah
Fel Mar 13, 2023 @ 3:32pm 
Originally posted by StarAlone¹ (Starry-Kun):
hmm can you elaborate on the idea? I am not sure how that could help, and whole problem was how to make it connect between stations. eg. when i have 5 stations with steel plates. Even if i was to change manually train count for each station, i still have to somehow make the network... and that's my problem here ;P
It depends on what you want to happen, if you want trains to go to the next station if the first already has a train (assuming they are named the same of course) then set each station to train limit 1, only 1 train will path to each station at a time, the others will just wait before pathing.

If you want trains to go to the station that have enough items stored up to fill a train, read all of the chests (separately for each station) and divide it by however much can fit in a train (might need to also substract 1 to that result) and send that to the train station set to "set train limit".
Originally posted by knighttemplar1960:
As long as you have balanced the chests loading your train you can simply wire all the chests to a single arithmetic combinator, divide the total in the chests by the capacity of your train, subtract 1 from the result and use the result to set the train limit on the station.

As long as the station that has the shortest path has a limit of 1 or more the train will go there. When the math takes it to a zero that station allows zero trains to enter and will stay that way until the station accumulates enough material for the train limit to be set to 1 and allow a train to enter the station.

The best solution, as Hedning mentioned, is just to have enough trains that both/all stations get used. In that case you must assure that you have enough slots in your stacker to accommodate the total amount of trains that could be requested by the compound station to make sure that you don't get a traffic jam at the entrance to your station(s).

Yeah, just checking for total value seems like a good 'simple' solution, and is actually better than switching tracks (well maybe not better, final effect would be the same, just harder to create it seems).
And yeah, im trying to always have stackers, especially on such big stations as my Smelter bases as it can get high traffic.
But as mentioned above, having more trains isn't really a solution :P
1st of all impossible as i can't just magicly create demand for items, even if i add trains, if demand is low(er), the trains won't come back for some time (and also will be taking space in different bases), unless you mean creating train for each station...? but still not really practical as its smelter base, with expanding further, more factories needing plates etc. i will have to add new trains which won't be really possible to maintain fair and balanced routes so that each station has +/- same number of trains per eg. 10min~
Perhaps i don't understand what you mean
Originally posted by Fel:
Originally posted by StarAlone¹ (Starry-Kun):
hmm can you elaborate on the idea? I am not sure how that could help, and whole problem was how to make it connect between stations. eg. when i have 5 stations with steel plates. Even if i was to change manually train count for each station, i still have to somehow make the network... and that's my problem here ;P
It depends on what you want to happen, if you want trains to go to the next station if the first already has a train (assuming they are named the same of course) then set each station to train limit 1, only 1 train will path to each station at a time, the others will just wait before pathing.

If you want trains to go to the station that have enough items stored up to fill a train, read all of the chests (separately for each station) and divide it by however much can fit in a train (might need to also substract 1 to that result) and send that to the train station set to "set train limit".

Without even limit train will follow up to next (free station) so that's fine. The problem is what happens after the train leaves. Because next one will come in his place, instead of going to station that has few blocks longer path to, meaning less time for station to be filled back up.

Oh, that's actually also a nice idea to not only count total amount in chests, but also to divide it by max # my current trains can take at once! Thanks!
brian_va Mar 13, 2023 @ 3:53pm 
mousing over the decider combinator for each chest should show input signal with the count in the chest, and the output signal should be 1 if above the set target.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946669769

the aterthmetic combinator should show input signal of 1 with a bottom right number that should add up to the number of chest that passed the check, 3 in your case if they were filled. output should be the same.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946669788

this is what the final decider should show as an output, again the 8 on the output signal would be a 3 in your example.

https://steamcommunity.com/sharedfiles/filedetails/?id=2946669818

edit: just to be sure its not something odd with your layout, remove that section of rail from the main track

edit 2: maybe try setting the combinator attached to the chest to specifically look for the item delivered instead of anything, maybe thats causing the problem.
Last edited by brian_va; Mar 13, 2023 @ 4:30pm
knighttemplar1960 Mar 13, 2023 @ 7:44pm 
Originally posted by StarAlone¹ (Starry-Kun):
Yeah, just checking for total value seems like a good 'simple' solution, and is actually better than switching tracks (well maybe not better, final effect would be the same, just harder to create it seems).
And yeah, im trying to always have stackers, especially on such big stations as my Smelter bases as it can get high traffic.
But as mentioned above, having more trains isn't really a solution :P
1st of all impossible as i can't just magicly create demand for items, even if i add trains, if demand is low(er), the trains won't come back for some time (and also will be taking space in different bases), unless you mean creating train for each station...? but still not really practical as its smelter base, with expanding further, more factories needing plates etc. i will have to add new trains which won't be really possible to maintain fair and balanced routes so that each station has +/- same number of trains per eg. 10min~
Perhaps i don't understand what you mean
If you have stackers and they are empty (or have room) then you don't have enough trains to supply your demand. If your demand is too high no trains will be waiting in the stackers and that means that you need to increase production. As long as you have train limits set (manually or dynamically) the trains in the waiting stations act as storage but they are ready to immediately move and unload if your buffer empties the delivery train.

If you use the same name for each like station you can also tell at a glance if you have enough trains by clicking on one of the train stations. It will open and tell you how many stations have that name and how many total trains are currently servicing those stops with thumbnails that you can scroll through that has enough detail that even a half blind guy like me can still see well enough to count trains and available stacker slots.
https://steamcommunity.com/sharedfiles/filedetails/?id=2946726139

Build stackers into your designs. If you set up a station so that nothing else can pass through it can be as simple as making your track a little longer so that a 2nd train with that material can wait behind the train in the station without protruding onto your main line and blocking other train traffic (you can also build by pass lanes to keep traffic waiting for stackers sidelined off you main lines)
https://steamcommunity.com/sharedfiles/filedetails/?id=2946727366
https://steamcommunity.com/sharedfiles/filedetails/?id=2946727411

Space in the game is free for the taking. Take some extra and use it.

You don't magically create demand for your products. You do it manually (or with construction bots). If you are over producing raw and intermediate materials and all ready have extra trains in place when you build a new demand factory you can immediately start producing instead of having it sit idle while you build new ore mines and smelters to supply it. Your spare trains immediately take up the load and you can add extra trains to the system when you need them.

You can also build more and smaller smelter arrays scattered through your base. A huge smelter array set to accommodate 8 ore unloading stations and 4 plate loading stations is much more vulnerable to traffic congestion than 4 smaller smelting arrays (perhaps 1 in each cardinal direction from the demand/supply areas) designed to accommodate 2 unloading stations and 1 loading station.
https://steamcommunity.com/sharedfiles/filedetails/?id=2946731178
https://steamcommunity.com/sharedfiles/filedetails/?id=2946731191

The game all ready has a system to balance trains as you have seen and prompted your OP. The trains will go to the closest named station available.

(There are more complicated calculations than that, that actually control train behavior)
https://wiki.factorio.com/Railway/Train_path_finding

If math isn't your thing you don't need it to be to succeed. Using smaller subfactories/smelters spread out throughout your base will mostly make these calculations moot since the closest station will be the one doing the supplying the vast majority of the time. As you spread out and take more ore patches you'll also need more smelters and space anyway. For the smelting arrays I have pictured here they can handle ~2 ore patches. That means that each 2 ore patches I mine requires that I build a new smelter (Unless the new ore mine is to replace a played out one.)
< >
Showing 1-14 of 14 comments
Per page: 1530 50

Date Posted: Mar 12, 2023 @ 1:44pm
Posts: 14