Setting train destinations using combinators.

Smart setups of railway stations, intelligent routing, solutions to complex train-routing problems.
Please provide - only if it makes sense of course - a blueprint of your creation.
thraxxaldor
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Sep 11, 2015 5:19 am
Contact:

Setting train destinations using combinators.

Post by thraxxaldor »

Thanks to the ability to enable/disable train stations it is now possible to route trains to arbitrary destinations. First a little explanation of train behavior in regards to station enabling and disabling to help understand why certain workarounds were needed in the system, and how it works. When trains leave a station they check from the first enabled station after the station they are currently at and will not care if any stations they skipped over because they were disabled are re enabled or not. In addition, trains that are at a station do not care if the station they are at is disabled after they arrive, if they got to the station, they behave completely normally, and will leave the stations when their conditions specify and only then. However, if the station they are going to is disabled en-route, they will re-route to the next enabled station, if one exists. That fact makes it impossible to simply route trains by enabling and disabling stations as trains leave, so a more complicated workaround is needed.

How does it work? The system works by synchronizing when trains leave stations with a network of combinators that controls which stations are enabled/disabled as well as choosing which trains to send to which locations. As was mentioned above simple enabling and disabling the stations is not enough, so every destination station (What I will call a core station) has a number of stations in front of it (What I will call a seeker station), the number of seeker stations is dependent on the number of trains in your system, as every train requires its own unique seeker station. Every core station is only enabled during a certain phase of the circuit network, and every seeker station is enabled from when a train leaves it storage, until it arrives at its destination, once it arrives the station disables itself. In the image below you can see the core station in the top of the screen, and the 6 seeker stations at the bottom.

Image

Below is a screenshot of what a train's route looks like, Iron-4 is the storage yard, Iron-X-4 is the seeker station for core station X, and Iron 1 and Iron 2 are core stations.

Image

The circuit network has two main phases, the send phase and the return phase. During the send phase the controller pings mining bases and decides which mining bases need trains sent to them, chooses the first mining base that needs a pickup, chooses the first available train and sends a signal to the station telling it to enable the seeker station at for that train. After the base enables the seeker station, the train leaves and the system moves on to the return phase. During the return phase, the controller enables all of the core mining stations, which allows for any train currently waiting at a seeker station to move to begin loading at the core mining station. While the train is moving to the core mining station a signal is sent out which disables the controller from leaving the return phase, as if it were to enter the send phase the core station would become disabled, which would re-route the train back to unload without ever having picked up its cargo. Once all the trains that were waiting at a seeker station have moved to the core station, the controller returns to the send phase and the cycle repeats.

Image

You could expand the system to as many core stations as you can make you're controller capable of supporting (the one in this base supports 5 even though I'm only using two), and as many trains as you are willing to build seeker stations for.

The system as a whole is quite interconnected, so I cant really give a blueprint, so instead I've attached the save file.
Attachments
trains .zip
(19.8 MiB) Downloaded 384 times
Sarkazeoh
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Apr 21, 2017 1:34 am
Contact:

Re: Setting train destinations using combinators.

Post by Sarkazeoh »

I've come up with a way to circuit control trains too unfortunately I am at work and cannot share a blueprint atm. I've got an example design in blueprint form, if you'd like to see it send me a message so I don't forget about it.

The way I've got it working is unloading stations are enabled and disabled based on quantities of material at that station.
The logic works as:

If material < a smaller quantity then enable station until material > a greater quantity.

Additionally anytime the station is enabled a signal of 1, or more, of that material is sent to the circuit which connects all stations.

For example: A copper plate unloading station needs copper plates, a signal of 1 copper plate is put into that circuit.

Each copper plate unloading station does this which will create a total quantity of copper plate unloading stations that need material.

This information is fed into each loading station train stop to be sent to the train for circuit condition reading by whatever train might be there.

Each train is programmed as:
Unloading station->Leave when empty.
Loading station->Leave when full and when train material signal >= x.

Where x is the minimum signal from the train circuit that will activate that train. x should be increased by one for each train delivering a specific material.

Lastly all train loading and unloading stations have exactly the same name for each material and function respectively. For example Copper Plate Loading, or Copper Plate Unloading.

This system allows the unloading stations to choose exactly how many trains are delivering at any given time without requiring the train to go to any specific location. This works because it doesn't matter what train makes the delivery to the station, only that a train does. And since each station only orders as many as it needs, no more, or less, trains than are needed are taking up space on the track, or in stackers.

The only problem I've encountered is that if a station becomes disabled when a train is en route to that station the train will no path if there is no way for it to reach another unloading station, or if it cannot turn around and return to the loading station. This is only an issue for non-loop train systems.

The simple fix was to make any train stackers have a way back into the train line and to have places along the main line where trains can turn around.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

@Sarkazeoh: That does not work with more trains that loading stations or trains are left without a viable destination. They then end up sitting behind a red signal waiting for a station to become free. Also trains will chose the nearest station. Then when the first one arrives they may or may not choose to repath to a different free station. Overall that breaks down as you scale it up.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

@thraxxaldor: Great minds think alike.

I've been playing around with disabling stations and had the same idea about seeker stations.

But I think there is room left for improvement. Note that trains seek the nearest enabled station with a clear path when leaving the previous station. So why not name all your loading stations the same and use the following train destinations:

- Work
- Seek <train id>

All train stops are set to wait for circuit signals. Normally all stations are disable and a train sits at Work waiting for a signal.

Now you want the train to fetch a load of iron ore. You enable the Seeker station at the iron ore mine. Next you send the GO signal to the train. There is always just one Seeker station active for a train so it has to go there. When it arrives at the seeker station you disable it, enable the following work station and again send the GO signal. More than one work station can be enabled but the train will seek the nearest, the one just following the seeker station. It has to pass that station to go anywhere else so it's always nearest. Once the train arrives at the work station you disable it again.

Note that no train leaves any station without a circuit signal. This is important as otherwise trains waiting at a work station would drive to any other work station that is enabled. They may only leave a station once their Seeker station is enable so they never skip a station. You have to program the train waiting condition at each train stop using circuits. But usually that is just a comparator that reads the train contents and then checks for train full or empty.

You could name all stations used by the iron ore trains "work iron ore" and copper ore trains "work copper ore". Or even go totally insane and name all stations just "work" and schedule trains totally freely. A train might haul iron ore one time and copper ore the next time followed by a load of electronic circuits.
thraxxaldor
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Sep 11, 2015 5:19 am
Contact:

Re: Setting train destinations using combinators.

Post by thraxxaldor »

@mrvn
Naming all the loading stations the same is very clever and certainly simplifies the setup quite a bit, especially if you were to make a more sophisticated setup. However, I think scheduling trains would be quite difficult with using only two destinations like that, that's not to say it wouldn't be possible, just that it would complicate an already complex circuit network. You could use the same seeker station setup, once a train arrives at a seeker stations at a mining base have it send a signal back to the main base telling it to enable the seeker station for the unloading station for that mining base's resource. Every trains schedule would look something like this:

-Storage
-Seek-T
-Load
-Seek-T
-Unload

By keeping Load and Unload stations separate, it helps to simplify the circuit setup, as trains would not need to synchronize leaving unloading and loading stations if you keep them separate.
Sarkazeoh
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Apr 21, 2017 1:34 am
Contact:

Re: Setting train destinations using combinators.

Post by Sarkazeoh »

mrvn wrote:@Sarkazeoh: That does not work with more trains that loading stations or trains are left without a viable destination. They then end up sitting behind a red signal waiting for a station to become free. Also trains will chose the nearest station. Then when the first one arrives they may or may not choose to repath to a different free station. Overall that breaks down as you scale it up.
I have not tested the idea on a large scale yet, so you are probably right. It really depends on the ai the trains use for choosing a destination.

Here is the blueprint for my test design.

It does require the "spawn belt" mod for ease in testing.

https://pastebin.com/BS88nJMj

Trains waiting to unload at either station repath to the other if they are waiting behind a chain signal regardless of where they were headed originally. If this is coupled with a path from the stacker that leads back to the main line trains could leave if all of that locations stops are occupied. I don't really know how much of a problem this could be with large numbers of trains.

This design is my current project and is basically a prototype. I figured I'd post it though since it might give the OP some ideas.

Thanks for the feedback! :D
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

thraxxaldor wrote:@mrvn
Naming all the loading stations the same is very clever and certainly simplifies the setup quite a bit, especially if you were to make a more sophisticated setup. However, I think scheduling trains would be quite difficult with using only two destinations like that, that's not to say it wouldn't be possible, just that it would complicate an already complex circuit network. You could use the same seeker station setup, once a train arrives at a seeker stations at a mining base have it send a signal back to the main base telling it to enable the seeker station for the unloading station for that mining base's resource. Every trains schedule would look something like this:

-Storage
-Seek-T
-Load
-Seek-T
-Unload

By keeping Load and Unload stations separate, it helps to simplify the circuit setup, as trains would not need to synchronize leaving unloading and loading stations if you keep them separate.
There certainly is a balance to be had between having more station names and more circuit logic. I think having loading and unloading stations named differently reduces circuits but in your example you had the mining outposts named differently. And I think that just makes the trains station list longer without any effect on circuits.

I think your list above is a good one as far as load and unload go. But I don't like the Storage stop. I assume that is where you send trains you have no use for at the moment so the load and unload stops remain clear. I see a problem with that design: Every train will visit Storage once a turn. That makes that easily a congestion problem. It's also wastes time and fuel. I think storage needs seeker stations, too. Then storage can be generally disabled and only get enabled for a short time when a train actually arrives at the storage seeker station.

Other thoughts: How about naming the seeker station Load-<train id> and Unload-<train id>. I don't think it makes any difference to the circuit what they are named. And do station names look better on the map when you place seeker stations in north-south direction?
thraxxaldor
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Sep 11, 2015 5:19 am
Contact:

Re: Setting train destinations using combinators.

Post by thraxxaldor »

mrvn wrote: There certainly is a balance to be had between having more station names and more circuit logic. I think having loading and unloading stations named differently reduces circuits but in your example you had the mining outposts named differently. And I think that just makes the trains station list longer without any effect on circuits.

I think your list above is a good one as far as load and unload go. But I don't like the Storage stop. I assume that is where you send trains you have no use for at the moment so the load and unload stops remain clear. I see a problem with that design: Every train will visit Storage once a turn. That makes that easily a congestion problem. It's also wastes time and fuel. I think storage needs seeker stations, too. Then storage can be generally disabled and only get enabled for a short time when a train actually arrives at the storage seeker station.

Other thoughts: How about naming the seeker station Load-<train id> and Unload-<train id>. I don't think it makes any difference to the circuit what they are named. And do station names look better on the map when you place seeker stations in north-south direction?
You are correct that naming the stations differently just makes train schedules longer and has no effect on circuits. That just wasn't something I had considered when I first made the setup.

For storage with my current setup every train has its own storage station because I know what seeker station to enable based on what the train station the train that is sitting in the storage yard is. There will never be any congestion because there is a station for every train, so in that train schedule replace "Storage" with "Storage-T" because that's what it actually is. Technically it is possible to create a generic storage yard by reading the number of the train, but you would have to create a circuit setup that converted the number that the game has assigned your train be to the number you have decided it is.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

thraxxaldor wrote:For storage with my current setup every train has its own storage station because I know what seeker station to enable based on what the train station the train that is sitting in the storage yard is. There will never be any congestion because there is a station for every train, so in that train schedule replace "Storage" with "Storage-T" because that's what it actually is. Technically it is possible to create a generic storage yard by reading the number of the train, but you would have to create a circuit setup that converted the number that the game has assigned your train be to the number you have decided it is.
Having one storage bay per train could be wasteful. A good size of the train fleet will be moving at all times or you have too many trains. But in this insanely big setup (think of the number of seeker stations you have to place) one more track for the train to rest at the storage is nothing much.
thraxxaldor
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Sep 11, 2015 5:19 am
Contact:

Re: Setting train destinations using combinators.

Post by thraxxaldor »

mrvn wrote: Having one storage bay per train could be wasteful. A good size of the train fleet will be moving at all times or you have too many trains. But in this insanely big setup (think of the number of seeker stations you have to place) one more track for the train to rest at the storage is nothing much.
How many trains would you call an insanely big setup? This only has 6, and I don't think space would really be an issue for seeker stations, they take up very little space. I figure I could probably expand this to use 100 trains fairly easily if I had the need to. I feel as though the storage bays are necessary for larger setups. My last base in .13 had around 60 trains in total. There have been several points during that play through where I had to almost completely halt production for hours to rework major parts of the base. If there were not dedicated storage yards the tracks would back up and the few trains that needed to run would not be able to due to the congestion in the tracks. You are right that under normal circumstances most of the storage yard is a waste though.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

thraxxaldor wrote:
mrvn wrote: Having one storage bay per train could be wasteful. A good size of the train fleet will be moving at all times or you have too many trains. But in this insanely big setup (think of the number of seeker stations you have to place) one more track for the train to rest at the storage is nothing much.
How many trains would you call an insanely big setup? This only has 6, and I don't think space would really be an issue for seeker stations, they take up very little space. I figure I could probably expand this to use 100 trains fairly easily if I had the need to. I feel as though the storage bays are necessary for larger setups. My last base in .13 had around 60 trains in total. There have been several points during that play through where I had to almost completely halt production for hours to rework major parts of the base. If there were not dedicated storage yards the tracks would back up and the few trains that needed to run would not be able to due to the congestion in the tracks. You are right that under normal circumstances most of the storage yard is a waste though.
6 trains isn't much, I was thinking more like 20+ trains. But let stick with 6. Add 12 ore mines if the patches are small and 4 unloading stops. That makes 16*6 seekers + 16 stops + 6 storage = 118 train stops. Would saving maybe 3 stops make a difference?

And that would be just iron ore. Same setup for copper ore, iron plate, copper plate. Smaller for steel, electronic circuits, oil.
qdbp
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun May 28, 2017 11:22 pm
Contact:

Re: Setting train destinations using combinators.

Post by qdbp »

In my experience simple "disable if station resources below X" logic works well if done properly. More precisely, I keep the station closed until each wagon can be filled independently, using some balancing logic to ensure even distribution into the buffer chests. Trains do not actually wait on red if signalled correctly - using path signals, you can have an incoming train wait at a point where it can decide to turn back immediately without going through the station or waiting for the preceding train to clear. Having hundreds of stations seems unnecessarily complicated. Using the above principles, I have two logical stations per resource, e.g. "Iron Mine" and "Iron Drop", and the trains roam fully autonomously. This also makes trains completely interchangeable and replaceable, and their orders never have to be updated. The system is expanded by spam-cloning from a depot.

This does leave some trains "roaming" the network before finding an open station, but I consider such autonomous behaviour interesting, and it doesn't hamper throughput since trains only roam if your outposts aren't producing enough.

Below is a picture of the system I use - it was designed to absolutely minimize human intervention. Setting one constant combinator to change the chest requests, and two station renames. The station entrace/exit attaches to standard modular mainline components for the most common width. The attached resupply station will automatically bring in anything needed to keep the station in good repair. In principle once the station is built you can remotely blueprint the miners and all the necessary items will be pulled in.

Image

Code: Select all

0eNrtXV1uIzmSvspAjwurN8ngb2EwwBxgsS/zMINFwZDtLFeiZcmbkjxb2/AB5iBzsT3JZkqynBIZmRFhOz1Z6Jd2V5X1iYwIkh+D8fPb7Ga5Kx/rarWdffltVt2uV5vZl//6bbap7leLZft32x+P5ezLrNqWD7Or2Wrx0P6pXlTL2fPVrFrdlf8z+6Ker4Y/sr5ZP67rbedjmvKx8m7+96ouOx8Dwsfu67JcXX7QPH+9mpWrbbWtysM093/4cb3aPdyUdTOP0+dvd/VT8837eV7NHteb5jPrVft1Dc4crmY/mh/KN9h3zXfcHv7RtQO7gNQ0SJtHhAwinBA32wbs/vsWG6Y7gppzUJ8BNVTQkMdUGUxLlGY8QqphSEcdpiry47Q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P20nw5aTDkut/REXOjrWY4DQzD9UQMhYjOQ1SM0ANM7eSBGo5RetDXoSOZMOdRCtUGZ40GtU7msAuXF4MjitSxnVsl5UflylorSk7QX/IaEynQBy1QAwMYmrSDKF3hkDBiL0QhiYkPzgfdhEdNwjpKNOzvdMj2bfqhQg0CRWD04lMCQ0iKkoDjFcL+np1aEz4ZXaz3JWPdbVqf325uCmbg2b2nw+r6tjS7w//8esfil9C849PzXl0yI82RltrQ6H88/P/A6svWIU=
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

qdbp wrote:This does leave some trains "roaming" the network before finding an open station, but I consider such autonomous behaviour interesting, and it doesn't hamper throughput since trains only roam if your outposts aren't producing enough.
I disagree there. The roaming happens all the time. If you don't produce enough then trains simply can't find an open station and roam forever. But that is OK, there is nothing for them to do. But roaming also happens when all stations are producing enough. All the trains will drive to the nearest station, the first one blocks that. Then all the remaining trains hit the red signal, block a while and then go somewhere else. Likely most will pick the same destination again and again and again. By the time they have even half sorted themselv out the nearest station is free again restarting the problem.

What makes this problem worse is that it is likely to happen for mines, which are really far away. They are the only stations where enough trains would get on the way without one yet reaching it. And yes, I'm talking dozens of mines here, not just 3 or 4.

Thinking about it, what might help is to not use signals or even single track to the mines. A single track would limit each mine to one train driving to or from it. With a waiting bay one train can be loading while another drives. No other train could go the long way to the mine and they should all turn around to go to another mine instead. Similar with a double lane without signals on the way. One train can drive to the mine, one at the mine and one driving from the mine. Hmm, I think my train track blueprint with evenly spaced signals is biting me in the ass on the mines.
qdbp
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun May 28, 2017 11:22 pm
Contact:

Re: Setting train destinations using combinators.

Post by qdbp »

mrvn wrote:Then all the remaining trains hit the red signal, block a while and then go somewhere else. Likely most will pick the same destination again and again and again. By the time they have even half sorted themselv out the nearest station is free again restarting the problem..
I have about six mines per resource right now, and I have not found this to happen. I can see where you're coming from though - it might depend on network topology. I have a single long main going straight away from base, and my mine stations are shallow pockets away from this. Therefore, when trains miss the first station and all go to the second station, it doesn't matter, since going to the second is also going to the third, etc, since they're all in a line. By the time the first reopens, the attractor is farther down the line. I can see what you're saying becoming a significant problem in a tree topology with a higher branching factor.

The ideal solution, then, is something that allows two logical stations per resource and interchangeable trains, but avoids this issue. I suspect the ticket will be clever use of "the Internet" (which I think is a handy term to refer to the global circuit net that's laid along rail backbones and connects your mines). My intuition, however, is telling me that per-station buffer size would need to grow linearly in the length of the longest segment on the network. Any solution that keeps a station closed long enough for a train to route to the farthest station from base will accumulate O(rail network height) resources in the meantime, which need to be buffered. (unless train release can be synchronized as in the OP and the train can be prevented from re-pathing midway, which the OP does with auxiliary stations and I don't think is possible without them) Fortunately an ideal branched network (where your mines are all on a front equidistant from base) minimizes this height. And the network that maximizes it, a straight line from base with pockets, doesn't actually need clever station closing.

I'd be very excited to see an internet controller that can route identical trains between two logical stations comprised of 15+ physical outposts.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

qdbp wrote:
mrvn wrote:Then all the remaining trains hit the red signal, block a while and then go somewhere else. Likely most will pick the same destination again and again and again. By the time they have even half sorted themselv out the nearest station is free again restarting the problem..
I have about six mines per resource right now, and I have not found this to happen. I can see where you're coming from though - it might depend on network topology. I have a single long main going straight away from base, and my mine stations are shallow pockets away from this. Therefore, when trains miss the first station and all go to the second station, it doesn't matter, since going to the second is also going to the third, etc, since they're all in a line. By the time the first reopens, the attractor is farther down the line. I can see what you're saying becoming a significant problem in a tree topology with a higher branching factor.
Yes, having mines in a line will totally avoid the problem. Even if the first mine becomes ready again the trains would have to turn around, drive all the way back and restart. Unless you have some strange layout the next further mine should be closer than turning back.

I currently have a a star topology. The base is in the middle and I develop mines in all directions outward. So there are several spokes going from the center to a mine.
qdbp wrote: The ideal solution, then, is something that allows two logical stations per resource and interchangeable trains, but avoids this issue. I suspect the ticket will be clever use of "the Internet" (which I think is a handy term to refer to the global circuit net that's laid along rail backbones and connects your mines). My intuition, however, is telling me that per-station buffer size would need to grow linearly in the length of the longest segment on the network. Any solution that keeps a station closed long enough for a train to route to the farthest station from base will accumulate O(rail network height) resources in the meantime, which need to be buffered. (unless train release can be synchronized as in the OP and the train can be prevented from re-pathing midway, which the OP does with auxiliary stations and I don't think is possible without them) Fortunately an ideal branched network (where your mines are all on a front equidistant from base) minimizes this height. And the network that maximizes it, a straight line from base with pockets, doesn't actually need clever station closing.

I'd be very excited to see an internet controller that can route identical trains between two logical stations comprised of 15+ physical outposts.
To allow full routing control you have to have one unique station per train per destination and then enable the station you want the train to go to. But I think that is overkill. At least for mines you don't really have a network of mines. You have line like you, the simplest case, a star like me or later then a tree. So lets talk about the tree as the most general layout. With double tracks going at least to the last branch point in the tree. Leaves could be single track. So what do you NEED to control the trains?
Directing only with signals
The old, less efficient way, would be to use signals to control trains. On a red signal trains repath, eventually. So if you keep track of how many trains each mine can fill (and keep in its waiting bay) and then sum that up along the branches of the tree then at each branching point you can use signals to control how many trains can go down each branch. Since every train going down a branch now has a definite destination you don't need a way for them to turn back other than going through a station.
Directing only with stations
Signals have the problem that it takes time for a train to repath. With stations the repath is instantaneous. So you can put a station "A", "B", "C", ... between each branch point going down the tree. The train schedule would then be to go from "Smelt" to "A" to "B" to "C" ... to "Mine". Again you track the number of trains each mine can fill and enable stations along the branch that don't have enough trains on the way.

One drawback there is that you have to have all mines at the same depth in the tree. So a mine close to the base needs stations "C", .... without having a branch and the train will stop at each. But I think close mines will be exhausted by the time this would be a problem.
Zaka
Inserter
Inserter
Posts: 36
Joined: Mon Jun 27, 2016 5:23 pm
Contact:

Re: Setting train destinations using combinators.

Post by Zaka »

I came at this from a different approach. Now my setup works only for raw material, Coal, Copper, Iron, ect.

I have 10 trains (this can be scaled without difficulty) for each resource in their own set of waiting bays.
Each Resource has a Scanning device that sequentially selects the mine(s). Currently this is set to 20 of each mine type, but again this can be scaled if necessary.

The Mines and the Waiting Bays use state machines (someone mentioned state machines and the light bulb went on) that sequence through the conditions at the mine (resource available, selected, acknowledged, enabled, loading) and waiting bay (train available, selected, released).

The mine scanner controls the interface between the two parts.
The WAN is on the Red Wire and the LAN to the waiting bay is on the Green Wire.
Video
Currently there appears to be a bug where the Station State (Enabled/Disabled) does not update when the train leaves the waiting bay (released by Green > 0). This can be worked around by placing an off line Station (in video with hazard concrete) so that the train schedule never shows the station as disabled.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

I don't see where you set the destination at all. The state machine is just keeping track of supply and trains. If 10 mines need a train then you would release one train each tick for 10 ticks. All those trains would go to the nearest mine. You solved a different problem.
Zaka
Inserter
Inserter
Posts: 36
Joined: Mon Jun 27, 2016 5:23 pm
Contact:

Re: Setting train destinations using combinators.

Post by Zaka »

They go to the closest mine first of course. But the Mine (Station) is disabled when the train arrives (cyan light). This causes the next train to path to a different mine.

The trick to the thing is to only have a number of active trains <= the number of available destinations.
Having more trains on the tracks than available destinations is a recipe for disaster.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Setting train destinations using combinators.

Post by mrvn »

As said, different problem. You need that one solved too but you aren't setting train destinations.
Zaka
Inserter
Inserter
Posts: 36
Joined: Mon Jun 27, 2016 5:23 pm
Contact:

Re: Setting train destinations using combinators.

Post by Zaka »

I'm confused by the statement "Not setting the train destination".

Since all of my copper mines are named "Mine-Copper" the destination is built into the schedule. Your destination(s) is(are) built into the schedule for your trains as well.

I'm confused by the Seeker Station. Is this an intermediate stop? If so, why? What do you gain from it?

The logic that I'm using at the Mine Station and the Waiting Bay is as follows:

Mine Station State Machine
State 0: Black
Input (F)ull from Mine -> Index
State 1: Red
Input Station (N)umber equal to Selector (C)ount (from controller) = (E)nabled -> Index
State 2: Yellow
Output Resource Available (Material Icon) -> Controller (add 1 to material count)
Input (1 to 5) Ack (from controller) -> Index
State 3: Green
Output Enable Stop
Input Train at Station = 1-> Index
State 4 Blue
Input (M)oving = 1 -> Reset

Waiting Bay State Machine
State 0: Black
Input (O)ccupied (Train at Station) > 0 -> Index
State 1: Red
Input (W)aiting from Waiting Bay -> Index
(Gated S >= 1) Output (E)nabled (from waiting bay controller) + Gate = (W)aiting (to Waiting Sweeper)
State 2: Yellow
(Gated) Input (7)Release (From Mine Sweeper) -> Index
(Gated S >= 1) Output (W)aiting (to Waiting Sweeper)
State 3: Green
Output Green to Train Stop (Release Train)
(Gated) Output (8)Train Released (To Mine Sweeper, subtract 1 from material count)
(Gated S >= 1) Output (W)aiting (to Waiting Sweeper)
Input (M)oving = 1 -> Reset

The controller for the mines scans each mine in sequence and counts the number of mines that have resources to load. When that number is equal to 1 (and a train is available in the waiting bay) it signals a train to leave the waiting bay. When the train leaves the bay 1 is subtracted from the number of mines with resources waiting to load. This prevents extra trains from being on the rails when they are not needed.

How are you controlling how many trains are released? Do the trains continuously cycle between seeker stations? Or do the go to a waiting bay (train yard) for dispatch?
Post Reply

Return to “Railway Setups”