Rail split: Choose direction based on cargo

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by Pi-C »

Thanks a lot for your suggestion!
quyxkh wrote:
Tue Oct 16, 2018 10:45 pm
Pi-C wrote:
Tue Oct 16, 2018 2:59 pm
At higher speeds, however, the signals are set before the train has time to recalculate its path, so it could go to the wrong exit only to be stopped by a red signal.
Yep. You have to keep the train's braking point from reaching the switch exits before they're set up. It's easy-ish to do reliably, set up N+1 rail signals 7 meters apart, so for your 1-3 trains do five to count up to four, then one more 3+ meters farther along for braking-point control. Greenwire all the signals together, set the N entry signals to send C on red and the next one to send L on red, B on yellow. Set the farthest one, the braking-point-control signal, to close if B>C, so it'll close if a train has reserved the LB signal but hasn't yet reached any of the C signals.
The first of your signals outputs "E" instead of "Red", but "E" is never used by the combinators. Am I right in assuming that you changed the output only in order to discard "Red" from that rail signal?
quyxkh wrote:
Tue Oct 16, 2018 10:45 pm
To read the train length, you want the C signal value when the L signal lights, so run a pulse converter on L and feed everything into a memory cell on L=1, this one's setup for up to 6 carriages.

The memory cell readout's the accumulator on the right, feed that to your switch exits at least twice the braking distance you set ahead of the control signal, 1-1 nuc trains delivering nuclear fuel accelerate really really fast, so for this one that sets an at-most-46 meter braking distance on release you want the switch exits at least 46 rail segments farther along.
I need the value of C because I want to set the signals after the switch according to this value. There is some way between the control signals and the switch, but we have the memory cell to store that value until the train has passed the switch. More accurately, it keeps the value until another trains starts to pass through your signal chain.

So suppose train X had passed the "B > C" signal but train Y entered the signal chain before X had reached the switch -- Y would reset the signal and there is a 50:50 chance that X would go the wrong way, potentially even blocking a station for Y when it would have picked the other path if left undisturbed. 46 rail segments -- that's quite some way! Your long row of signals has about 25 segments, so I should set the first signal (the one where "Red" is turned to "E") about 70 segments apart from the switch, if I get you right. In this case, I have two blocks (each fitting a 1-2 train) left in front of the signal chain. Add to this one second the next train has to wait at the train stop (worst case -- the train just stops; there is more time if supplies are unloaded there), that is still not very much.

Train X should have enough time to reach the switch before Y interferes if I replaced the normal signals in your signal chain (excluding the "B > C" signal) with chain signals and made sure there is no other signal between "B > C" and the switch. The only problem I've now got is the lousy layout of my rails! The signal chain would have to cover some curves in the track, so I probably can't place the signals correctly for wagon counting. Putting it closer to the switch is bad because of the super fast trains, putting it closer to the train stop has other disadvantages. Guess I'll have to give it some thought again. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

Yah, that `E` was a holdover, it s/b a `C`, but the idea's useful, you can get a near-arbitrary braking-distance limit by making the braking controller close on B>E and add a red-E signal at the end of the braking distance you want rather than just using the back C signal.
Pi-C wrote:
Thu Oct 18, 2018 10:03 pm
it keeps the value until another trains starts to pass through your signal chain.
Specifically, until another train passes the LB signal, so I think there's a simple mutex here, a throttle in front of LB that closes when L lights and opens when a switch exit goes yellow, you'd have to add a pulse converter on the switch-exit yellows and an R-S latch on the yellow pulse and the L pulse you've already got for the memory latch.

Also I probably should have put a guard on the entire counting-blocks stretch, shut off the green readouts and add a no-readout gate at the entry wired to close if anything's > 0.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by Pi-C »

quyxkh wrote:
Thu Oct 18, 2018 11:08 pm
Yah, that `E` was a holdover, it s/b a `C`, but the idea's useful, you can get a near-arbitrary braking-distance limit by making the braking controller close on B>E and add a red-E signal at the end of the braking distance you want rather than just using the back C signal.
Pi-C wrote:
Thu Oct 18, 2018 10:03 pm
it keeps the value until another trains starts to pass through your signal chain.
Specifically, until another train passes the LB signal, so I think there's a simple mutex here, a throttle in front of LB that closes when L lights and opens when a switch exit goes yellow, you'd have to add a pulse converter on the switch-exit yellows and an R-S latch on the yellow pulse and the L pulse you've already got for the memory latch.

Also I probably should have put a guard on the entire counting-blocks stretch, shut off the green readouts and add a no-readout gate at the entry wired to close if anything's > 0.
Thank you for the suggestions! I have experimented a bit, and perhaps all that isn't actually needed at all. Here I've set up a little race track off my "real" network:


Unfortunately, we're not yet at 0.17, where you should be able to include trains in blueprints. So, two trains (a long one with at least 3 wagons and a short one with 0 to 2 wagons) should be placed at the starting position (top center). Schedule for both is "Stop; Wait until circuit condition Green > 0" (repeat, so the trains don't wait forever at the first stop). Put both on automatic schedule and switch off the combinator sending the red signal to see them running until there is no fuel left. The short trains should take the inner, long trains the outer loop. If the short train carries zero or one wagon, it should overtake the long train every other time they meet at the junction close to the train stops (top right). The only trouble is, I don't have nuclear fuel yet, so I can't test whether a very fast short train would interfere with the signal setting for a longer train running on solid fuel. Could you try that out, please? Meanwhile, I'll try to implement your new suggestions, but it may take some time until I'll get this done …
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

Pi-C wrote:
Wed Oct 24, 2018 1:47 pm
I don't have nuclear fuel yet, so I can't test whether a very fast short train would interfere with the signal setting for a longer train running on solid fuel. Could you try that out, please?
:-) yay for save-scumming:

Code: Select all

/c game.player.insert'nuclear-fuel'
and reload when you're done testing

quyxkh
Smart Inserter
Smart Inserter
Posts: 1027
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by quyxkh »

Pi-C wrote:
Wed Oct 24, 2018 1:47 pm
Thank you for the suggestions! I have experimented a bit, and perhaps all that isn't actually needed
Haha, of course you're right, just move the braking controller to guard the switch exits, duh. No need to slow the train for the latch, the switch exits are what need protecting.


I'm not sure how quickly closures are guaranteed to take and had some trouble with response time on closely-spaced layouts, looks like 5m is a better distance between the B-signal detector and the actual braking signal.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1639
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Rail split: Choose direction based on cargo

Post by Pi-C »

quyxkh wrote:
Wed Oct 24, 2018 7:56 pm
Pi-C wrote:
Wed Oct 24, 2018 1:47 pm
Thank you for the suggestions! I have experimented a bit, and perhaps all that isn't actually needed
Haha, of course you're right, just move the braking controller to guard the switch exits, duh. No need to slow the train for the latch, the switch exits are what need protecting.

I'm not sure how quickly closures are guaranteed to take and had some trouble with response time on closely-spaced layouts, looks like 5m is a better distance between the B-signal detector and the actual braking signal.
Thanks, I've got that to work now. I'm even thinking about using your carriage counter in my routing stations. This would allow for more fine-grained differentiation between different train types: normal cargo trains, shorter fluid trains, still shorter supply trains, possibly extra trains with artillery wagons only. Might be a good time to quit my current game and restart once again, though …

Also, the console command for getting nuclear fuel was very useful! Should have been obvious that there must be some way of "cheating" (in quotation marks because I only used it for testing) the game, but I had never even considered that possibility before. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Gameplay Help”