Page 1 of 2

Why is this train being stupid?

Posted: Sat Oct 22, 2016 12:31 pm
by lingnau
I've browsed around, but couldn't find an explanation. I imagine that someone might have already encountered this (issue?) as most people now use queuing stations instead, but I would expect this to work in a small set-up. From my knowledge of trains, this should work. However, the result is rather confusing.
  • Should this train be behaving this way?
Some background explanations:
  1. Both train stops to the left are have the same name ("Ore Unload" or similar). All trains go from some outpost to these two stations
  2. O / Circle = Regular Signal(color represents status)
  3. □ / Square = Chain Signal (color represents status)
Questions
  • Since the shortest path and the "clear" path are the first choice, why does this train want to enter the second station and not the first one?
Note: There couldn't have been a second train on the first station before this train, there are only 4 ore trains in this railroad.
Note2: The image you're about to see is not OCD friendly. Which some take very seriously. :)

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 12:42 pm
by Frightning
It's path and choice of (un)loading bay were made long ago, and at that time, the 2nd bay was free (or had less trains waiting for it). This is the thing you were hearing a lot about on these boards when 0.13 was still experimental. The trains aren't smart enough to re-check their path choice to see if a different bay has opened up, hence why people use queuing style setups now: it solves this problem (at least as well as can be done in 0.13 iirc).

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 1:51 pm
by Optera
I'm using multiple loading bays with the same station name too. Trains do reevaluate their paths eventually. Sadly routing is nowhere close to OTTD.

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 2:18 pm
by lingnau
Frightning wrote:It's path and choice of (un)loading bay were made long ago, and at that time, the 2nd bay was free (or had less trains waiting for it). This is the thing you were hearing a lot about on these boards when 0.13 was still experimental. The trains aren't smart enough to re-check their path choice to see if a different bay has opened up, hence why people use queuing style setups now: it solves this problem (at least as well as can be done in 0.13 iirc).
Uh, thank you for the feedback/explanation.
Optera wrote:I'm using multiple loading bays with the same station name too. Trains do reevaluate their paths eventually. Sadly routing is nowhere close to OTTD.
Thank you for your reply. While it is unfortunate and I may need to change my design, we must agree that OTTD's sole existence purpose is exactly this sort of thing, Factorio is a mix from good stuff about other games. While this is annoying, it wont be the end of the world for me. :)

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 4:18 pm
by Optera
One thing i noticed that's different between your station and mine is your exit signals (in red squares in your screenshot) are chain signals while i use block signals.

Here are my unloading stations. Even the circuit controlled block signals from the crossings don't seem to freak out path finding.
2016-10-22-18-09-54-4871776.jpg
2016-10-22-18-09-54-4871776.jpg (499.41 KiB) Viewed 9561 times

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 5:16 pm
by lingnau
Optera wrote:One thing i noticed that's different between your station and mine is your exit signals (in red squares in your screenshot) are chain signals while i use block signals.

Here are my unloading stations. Even the circuit controlled block signals from the crossings don't seem to freak out path finding.
2016-10-22-18-09-54-4871776.jpg
I believe this is a slightly different situation, since you have the same amount of trains and stations, which makes its "hassle free". Btw, cool to see double-headed-push–pull trains with 6 wagons. :D

Re: Why is this train being stupid?

Posted: Sat Oct 22, 2016 6:59 pm
by Optera
lingnau wrote:
Optera wrote:One thing i noticed that's different between your station and mine is your exit signals (in red squares in your screenshot) are chain signals while i use block signals.

Here are my unloading stations. Even the circuit controlled block signals from the crossings don't seem to freak out path finding.
2016-10-22-18-09-54-4871776.jpg
I believe this is a slightly different situation, since you have the same amount of trains and stations, which makes its "hassle free". Btw, cool to see double-headed-push–pull trains with 6 wagons. :D
The train entering the top copper station originally wanted to go to the bottom station. It can't really be shown in a single screenshot.
Sometimes it takes trains so long to find the new path, another train simply dashes in that station.

I like 2L-6C-2L, they are fast and deadly. These gate controlled signals on the rr crossings are pure survival. One of those trains has more kills on me than all biters together. :D

Re: Why is this train being stupid?

Posted: Sun Oct 23, 2016 4:53 am
by impetus maximus
try putting a station before the unload stations (left of blue square) with a wait time of 0 seconds. trains should recalculate after the 0 second stop.

Re: Why is this train being stupid?

Posted: Sun Oct 23, 2016 1:49 pm
by Jupiter
impetus maximus wrote:try putting a station before the unload stations (left of blue square) with a wait time of 0 seconds. trains should recalculate after the 0 second stop.
I have used this technique in my previous game but it seems that it only works to a degree. This is because the trains will leave from that station immediately and only then will they calculate their path. If, at that moment, none of the stations are free it will just pick one. If that station isn't the first to clear up it won't reconsider its options.

While writing I thought about a possible solution. With the new train waiting conditions it's possible to have trains wait until some circuit condition is met. You could use a circuit network to check if any of the stations are clear and as soon one is you'll let the train leave. So it will delay calculating its path until it actually has to move.

However, in my new game I've circumvented the issue entirely with the following unloading station design:

http://imgur.com/a/IoJEg
Image

This design maximizes the unloading capacity of the station itself by having as many output belts as possible. I have tested this setup and one station nearly fills up all 16 belts (it's more than 15 belts for sure). I also have separate waiting bays for each station with a capacity of 12 or so 2-4-0 trains and I made sure that the time between 1 train leaving and the next standing still for unloading is as short as possible. In the screenshot I'm only using 4 belts but this way I can expand much much more.
The benefit of this is that you need just 1 station for each type of resource you're shipping in (and therefore circumventing the problem) because you probably won't need more than 16 belts anyway. And even if you do, just build a second one and you have enough capacity to supply a sizable mega base with 32 belts.
The only downside is... it's kinda huge. But that's mainly due to the waiting bays.
Blueprint string

Re: Why is this train being stupid?

Posted: Sun Oct 23, 2016 2:47 pm
by lingnau
Jupiter wrote:
impetus maximus wrote:try putting a station before the unload stations (left of blue square) with a wait time of 0 seconds. trains should recalculate after the 0 second stop.
I have used this technique in my previous game but it seems that it only works to a degree. This is because the trains will leave from that station immediately and only then will they calculate their path. If, at that moment, none of the stations are free it will just pick one. If that station isn't the first to clear up it won't reconsider its options.

While writing I thought about a possible solution. With the new train waiting conditions it's possible to have trains wait until some circuit condition is met. You could use a circuit network to check if any of the stations are clear and as soon one is you'll let the train leave. So it will delay calculating its path until it actually has to move.

However, in my new game I've circumvented the issue entirely with the following unloading station design:

This design maximizes the unloading capacity of the station itself by having as many output belts as possible. I have tested this setup and one station nearly fills up all 16 belts (it's more than 15 belts for sure). I also have separate waiting bays for each station with a capacity of 12 or so 2-4-0 trains and I made sure that the time between 1 train leaving and the next standing still for unloading is as short as possible. In the screenshot I'm only using 4 belts but this way I can expand much much more.
The benefit of this is that you need just 1 station for each type of resource you're shipping in (and therefore circumventing the problem) because you probably won't need more than 16 belts anyway. And even if you do, just build a second one and you have enough capacity to supply a sizable mega base with 32 belts.
The only downside is... it's kinda huge. But that's mainly due to the waiting bays.
Blueprint string
At this point in the game I don't even get to use all the resources that I'm able to collect, so usually trains take a while to unload because the belts/furnaces to which they output are barely consuming anything.


I've actually (on a different game) settled for something more traditional (train queue) which appears to work pretty well. One could also improve this by reading the amount of resources on the chests from each "bay" and only open the signal once the whole incoming train can be unloaded (8k resources for 4 wagons), this can reduce unloading time.

On the screenshots, trains come from the south, hold one the "wait stations" (bottom of the screenshot) before proceeding to the free unload station (top of the screenshot). It scales pretty easily by adding additional "wait" stations (one for each train that uses the station above should be more than sufficient) and it's cheap to build(and, very small footprint).

Re: Why is this train being stupid?

Posted: Sun Oct 23, 2016 3:59 pm
by Jupiter
lingnau wrote:At this point in the game I don't even get to use all the resources that I'm able to collect, so usually trains take a while to unload because the belts/furnaces to which they output are barely consuming anything.

I've actually (on a different game) settled for something more traditional (train queue) which appears to work pretty well. One could also improve this by reading the amount of resources on the chests from each "bay" and only open the signal once the whole incoming train can be unloaded (8k resources for 4 wagons), this can reduce unloading time.

On the screenshots, trains come from the south, hold one the "wait stations" (bottom of the screenshot) before proceeding to the free unload station (top of the screenshot). It scales pretty easily by adding additional "wait" stations (one for each train that uses the station above should be more than sufficient) and it's cheap to build(and, very small footprint).
My point was that you can have enough with just one station per resource and therefore get rid of the problem all together. It's high capacity is just an added bonus that makes the solution future proof.

Re: Why is this train being stupid?

Posted: Sun Oct 23, 2016 4:03 pm
by lingnau
Jupiter wrote:
lingnau wrote:At this point in the game I don't even get to use all the resources that I'm able to collect, so usually trains take a while to unload because the belts/furnaces to which they output are barely consuming anything.

I've actually (on a different game) settled for something more traditional (train queue) which appears to work pretty well. One could also improve this by reading the amount of resources on the chests from each "bay" and only open the signal once the whole incoming train can be unloaded (8k resources for 4 wagons), this can reduce unloading time.

On the screenshots, trains come from the south, hold one the "wait stations" (bottom of the screenshot) before proceeding to the free unload station (top of the screenshot). It scales pretty easily by adding additional "wait" stations (one for each train that uses the station above should be more than sufficient) and it's cheap to build(and, very small footprint).
My point was that you can have enough with just one station per resource and therefore get rid of the problem all together. It's high capacity is just an added bonus that makes the solution future proof.
Point taken. :)

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 8:35 am
by Deadly-Bagel
Trains recalculate when they pass signals. Therefore there is a problem when you use chain signals, where if a train queues up at a chain signal but then a different bay becomes free, the train will not see it because is not recalculating its path.

The solution is to make a "faux-chain signal" which is just a regular signal that you connect to the circuit network to behave like a chain signal. Connect it to all the adjacent-forward signals via circuit network and tell it to go red if [Green] = 0. Therefore when ANY bay becomes available it is allowed to become green, the train will pass it, recalculate, and enter the available bay. See this topic for more info

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 9:50 am
by Optera
Deadly-Bagel wrote:Trains recalculate when they pass signals. Therefore there is a problem when you use chain signals, where if a train queues up at a chain signal but then a different bay becomes free, the train will not see it because is not recalculating its path.

The solution is to make a "faux-chain signal" which is just a regular signal that you connect to the circuit network to behave like a chain signal. Connect it to all the adjacent-forward signals via circuit network and tell it to go red if [Green] = 0. Therefore when ANY bay becomes available it is allowed to become green, the train will pass it, recalculate, and enter the available bay. See this topic for more info
Circuit controlled "faux-chain signal" seem to force pathfinder to update instantly while regular chain signals will update only every minute or so.
2016-10-27-11-45-10-6699145.jpg
2016-10-27-11-45-10-6699145.jpg (396.52 KiB) Viewed 9154 times
It took that train half a minute to update it's path to a free station.
2016-10-27-11-45-33-9442457.jpg
2016-10-27-11-45-33-9442457.jpg (318.48 KiB) Viewed 9154 times

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 10:21 am
by lingnau
Deadly-Bagel wrote:Trains recalculate when they pass signals. Therefore there is a problem when you use chain signals, where if a train queues up at a chain signal but then a different bay becomes free, the train will not see it because is not recalculating its path.

The solution is to make a "faux-chain signal" which is just a regular signal that you connect to the circuit network to behave like a chain signal. Connect it to all the adjacent-forward signals via circuit network and tell it to go red if [Green] = 0. Therefore when ANY bay becomes available it is allowed to become green, the train will pass it, recalculate, and enter the available bay. See this topic for more info
Awesome! Thank you. Eager to try that out now. :)

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 10:25 am
by ssilk
That is also my experience and also the issue: Some way to tell a train, that he now needs to search a new path, but avoid to search always for new paths (cause this is CPU-intensive). In other words: A train should search new path only, if he needs to. :)

The problem with this definition is, that every player can interpret that differently and a programmer cannot guess, he needs to decide how that could be interpreted.

This is also the answer the OP question: This is "stupid", cause some programmer had to decide between using less CPU and more cleverness and he decided for the CPU, which was at that time the right decision, cause he could not know all implications, if he made it more clever, but know all if he decided for the CPU.

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 10:59 am
by Deadly-Bagel
Hmm, well the programmatic way to decide that would be when a signal changes, it would fire a Signal Changed event (I presume it does this already). Any chain signals 'linked' to it would be subscribed to that event so it knows to update, which would trigger a path recalculation for any trains in its block. However I am aware of the problem where trains recalculate halfway through a junction of chain signals and pick a route that isn't available, deadlocking the junction. A way around this would need to be devised, I can think of three off the top of my head with various pros and cons.

When I tested this before, might have been 0.13, the train never recalculated.

Re: Why is this train being stupid?

Posted: Thu Oct 27, 2016 1:38 pm
by mrvn
Jupiter wrote:
impetus maximus wrote:try putting a station before the unload stations (left of blue square) with a wait time of 0 seconds. trains should recalculate after the 0 second stop.
I have used this technique in my previous game but it seems that it only works to a degree. This is because the trains will leave from that station immediately and only then will they calculate their path. If, at that moment, none of the stations are free it will just pick one. If that station isn't the first to clear up it won't reconsider its options.
Have you tried putting the station just behind a signal that you turn green only when a spot opens up? The train will then try to reach the station but gets stoped just before it by the signal. When the signal turns green it will reach the station and then find the way to the open spot.

Re: Why is this train being stupid?

Posted: Sat Oct 29, 2016 11:01 am
by Jupiter
mrvn wrote:
Jupiter wrote:
impetus maximus wrote:try putting a station before the unload stations (left of blue square) with a wait time of 0 seconds. trains should recalculate after the 0 second stop.
I have used this technique in my previous game but it seems that it only works to a degree. This is because the trains will leave from that station immediately and only then will they calculate their path. If, at that moment, none of the stations are free it will just pick one. If that station isn't the first to clear up it won't reconsider its options.
Have you tried putting the station just behind a signal that you turn green only when a spot opens up? The train will then try to reach the station but gets stoped just before it by the signal. When the signal turns green it will reach the station and then find the way to the open spot.
Nope and it would work indeed. However, that signal would have to be a normal signal hooked up to the circuit network but then the 0 sec trainstop would be redundant because, if I'm right, leaving that signal would cause a recalculation anyway. You practically end up with the faux-chain signal idea.

Re: Why is this train being stupid?

Posted: Mon Oct 31, 2016 12:52 pm
by mrvn
Have to try this with and without the extra station. If the signal is enough to recompute the way this could be fun.

Challenge: Design a minimal train network where the signals are such that the train always finds a path but never reaches its goal.