Question: Smart Trains

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
xmrtimex
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Apr 26, 2017 10:43 am
Contact:

Question: Smart Trains

Post by xmrtimex »

Hi,

I am searching for resources on how to get smart trains started in vanilla.

Problem:
I have a central oil refinery, where oil is brought to by trains. I've got 9 oil outposts and my oil refinery has 4 unloading stations.

My goal is that all 4 trains are parked in the unloading Station and when an oil outpost has enough oil stored to fill up 2 tank wagons, a train should take the route and deliver the oil to the refinery.
I don't want the trains to constantly bounce between the outposts and the refinery, because I already struggle with my train traffic.
My fist try was to name all Outpost stations the same and deactivate the stations per Network until the oil count is reached, but then, once the station was available, all 4 trains would start driving to the station. I would like to expand this idea later to all Outpost (Iron, Copper), therefore I am searching for a solution, that would not be limited to Oil.

If someone got a tutorial or a solution to my problem, I would be very happy :)

Manron
Inserter
Inserter
Posts: 39
Joined: Mon Apr 11, 2016 5:21 pm
Contact:

Re: Question: Smart Trains

Post by Manron »

Many have tried, noone came up with a real solution yet. It seems it's not doable in vanilla. There are some ideas around that involve quite complex combinator contraptions, but it all boils down to how to make ONE train depart and not all of them at once. The vanilla train network is simply not 'smart' enough to reliably do just that.

The only workaround i know of is to have a dedicated train for each outpost and enough unloding/waiting bays.

roothorick
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Aug 11, 2014 5:22 am
Contact:

Re: Question: Smart Trains

Post by roothorick »

In theory... run signal wires from each outpost back to the refinery. Have the trains waiting on a circuit condition to continue instead of hunting for the next stop. When an outpost has a load waiting, it not only enables its stop but also sends a signal to the refinery. The refinery then through a little combinator logic picks one specific train to send and raises its circuit condition. (Look at the circuit network settings for the train stop and what it sends back to the network. A simple "trigger the first available" should be pretty easy.)

You can still run into race conditions however. I'm not 100% sure what would happen if two outposts became available at the same time, but you might wind up with both trains going only to the first. Or it might work anyway.

Personally, I'd probably just roll out 9 trains, one per outpost, and set them up to park themselves at their outpost until full.

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Question: Smart Trains

Post by mrvn »

When you enable a station then all trains ready to leave will leave. So the trick is to not have them ready to leave.

Make the trains wait for a circuit signal and then add some circuit logic that compares how many trains are waiting, how many outpost can fill a train and accordingly send as many go signals to the trains. Simplest case have every crude oil station output 1 crude oil when it has 75k crude oil. Then for the first refinery station send a GREEN signal when crude oil >= 1, for the second station send a GREEN signal when crude oil >= 2 and so on. And all trains wait at the refinery till empty AND GREEN > 0.

It's not an ideal solution since when only one outpost has crude oil but the first train is coming back with a full load or still unloading the second train won't leave. The setup will wait for the first train to be unloaded and send it out again. But what's the harm?

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Question: Smart Trains

Post by mrvn »

roothorick wrote:Personally, I'd probably just roll out 9 trains, one per outpost, and set them up to park themselves at their outpost until full.
Problem then is that at some point you will get 9 trains at the refinery. Needs a bigger waiting bay.

(I wonder how big your setup is that you need 4 unloading bays for crude oil. Fluid wagons are so fast I have never needed more than one train yet.)

roothorick
Long Handed Inserter
Long Handed Inserter
Posts: 92
Joined: Mon Aug 11, 2014 5:22 am
Contact:

Re: Question: Smart Trains

Post by roothorick »

mrvn wrote:When you enable a station then all trains ready to leave will leave. So the trick is to not have them ready to leave.

Make the trains wait for a circuit signal and then add some circuit logic that compares how many trains are waiting, how many outpost can fill a train and accordingly send as many go signals to the trains. Simplest case have every crude oil station output 1 crude oil when it has 75k crude oil. Then for the first refinery station send a GREEN signal when crude oil >= 1, for the second station send a GREEN signal when crude oil >= 2 and so on. And all trains wait at the refinery till empty AND GREEN > 0.

It's not an ideal solution since when only one outpost has crude oil but the first train is coming back with a full load or still unloading the second train won't leave. The setup will wait for the first train to be unloaded and send it out again. But what's the harm?
Simpler than what I had in mind, but pretty much the same idea. I was thinking of using combinator latches to keep track of whether a given report has been responded to, and reading the train stops to find a present train and send it. A good bit more complex, but has the advantage of always sending a train, and doesn't actually care in what order or in what lanes the trains are parked.

xmrtimex
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Apr 26, 2017 10:43 am
Contact:

Re: Question: Smart Trains

Post by xmrtimex »

Thanks for the replies.
Seems like the easiest way would be to run the wires to the refinery...That's fun :c
I will keep you updated, if I find a more elegant solution.

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Question: Smart Trains

Post by mrvn »

For my train setup I have long distance power poles strung with red and green wires all across the map. The green wire carries signals of stuff I have. Like when the iron ore mine has >4000 iron ore it puts an iron ore = 1 signal on the green wire. The red wire is for stuff I need. So when the iron smelter has space for 4000 iron ore it outputs an iron ore = 1 signal on the red wire. That way I can access the supply and demand of goods at any point on the map and enable and disable stations accordingly.

Frightning
Filter Inserter
Filter Inserter
Posts: 807
Joined: Fri Apr 29, 2016 5:27 pm
Contact:

Re: Question: Smart Trains

Post by Frightning »

I don't see a real reason not to just have 9 trains and let them wait at their outposts, slowly being loaded as oil is mined (they shouldn't interfere with the main network if you've created a proper train stop and signaled it right). If you want backlog protection, just make a 5-bay stacker, so that you can have 4 trains unloading+5 waiting, which is all 9 (possible if production is exceeding demand, especially if significantly so).

Post Reply

Return to “Gameplay Help”