Train signal and/or pathfinding weird thing

Post all other topics which do not belong to any other category.
Post Reply
Pellomari
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Mar 03, 2016 1:49 pm
Contact:

Train signal and/or pathfinding weird thing

Post by Pellomari »

I was testing some train stuff an i made this (ignore the trains for now):

http://imgur.com/2iVMu9Q

The idea is to allow a 2 way railroad, BUT, with a little improvement: the trains always take the straight path if possible. If not, the trains going from left to right always use the bottom path; the ones going from right to left, the upper path.

RESULTS
With a train it works as expected, always taking the bottom path.
With 2 trains works as expected.
With 3 trains it works, BUT there is a little problem.

THE PROBLEM
When the chain signal is blue, the train doesn't go forward. It stays still for about 10 seconds. Then, it moves (and no, it's not the station timer). This happens on both sides. Here is an image when the train is stoped. The train at the right isn't moving, even thought the chain signal is blue.

http://imgur.com/PP9DQIj

The same image showing the path the train is tryng to take:
http://imgur.com/xySZ8jA

After about 10 seconds, the path of the train changes, and it starts to move.

THE POINT OF THE POST

Why does that happen? I don't get it. Someone please explain.
Is it a bug? A code inconsistency? Or am I missing something?

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by ratchetfreak »

make the signals on the passing point one way. (remove the double signals)

The train is trying to path through a occupied block because it is shorter. However it is blocking his path so after a timeout he repaths and finds the clear passing point.

Pellomari
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Mar 03, 2016 1:49 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by Pellomari »

Well, the point was to do it two ways. Doing them one way is just too easy :D. It's just a little experiment I wanted to do, and i just don't understand what is going on.

Any ideas on how the repath of the train works? How often does it happen? Thank you for your answer!

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by ssilk »

I also watched that happen many times in my much bigger train network (with over 200 trains). So I don't know exactly (and is some underline to the question to the devs), how this really works.
But AFAIK it works like so: If a train is standing 10 secs in front of a red signal it looks, if there is another free path. If yes it changes. That simple.

I think the idea of this waiting is, that the train path should not change immediately, it should insist on the path it has calculated; which is the right direction, no question. But there is also some space for optimization. :)

In my opinion there should be some rule, which enables to shorten this time very much: the train should insist on it's path only, if the (possible) path around is much longer. And vice versa: It should change the path much faster, if it sees that the detur is very small.

This is some kind of balancing: Which is more efficient now; waiting or going around?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Pellomari
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Mar 03, 2016 1:49 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by Pellomari »

I appreciate your knowledge. Thank you very much. The stuff about optimization you talk about seems really complicated, and I am not even sure that it could be coded.

Anyways, I am not sure that the waiting time is a fixed number:

I played a little bit more with the setup mentioned and it has become even weirder. If you let the trains go between the two stations for a long period of time, even more weird things happen: sometimes it works as I expected it would do (no weird waiting times). Sometimes the waiting time of the train is much shorter. And other times, the train on the left time waits for the 10 seconds (aprox) too.

It´s not a big deal in my little setup, but in a train system with 200 trains, I guess that those kind of things can become real problems.

Hexicube
Fast Inserter
Fast Inserter
Posts: 204
Joined: Wed Feb 24, 2016 9:50 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by Hexicube »

ssilk wrote:I also watched that happen many times in my much bigger train network (with over 200 trains). So I don't know exactly (and is some underline to the question to the devs), how this really works.
But AFAIK it works like so: If a train is standing 10 secs in front of a red signal it looks, if there is another free path. If yes it changes. That simple.

I think the idea of this waiting is, that the train path should not change immediately, it should insist on the path it has calculated; which is the right direction, no question. But there is also some space for optimization. :)

In my opinion there should be some rule, which enables to shorten this time very much: the train should insist on it's path only, if the (possible) path around is much longer. And vice versa: It should change the path much faster, if it sees that the detur is very small.

This is some kind of balancing: Which is more efficient now; waiting or going around?
Actually, I think it should be the other way around. If it's worked out a long route, chances are a detour will be longer, so it should wait more. Likewise, if the route is very short, it should quickly consider alternatives, since the new route may be similarly short.

Maybe it could also instantly recalculate if the next block is a blue chain signal (which signifies some exits) and the currently wanted exit is blocked, even before it arrives at the signal?

Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by Targa »

First of all, you want to use regular signals, not chain signals. Secondly, the pictures you posted show that you have two pair too many signals installed. Remove the signal pair that are on the far right and far left (if you mouse over these signals that are "before" and "after" the rail siding, you'll see they're "looking" at both sides of the fork, rather than just one. Where the track splits, you want one pair on the right side of the split, and one pair on the left side of the split. That arrangement will allow trains to take the straight path if there are no trains ahead. If you use a single signal on the right and a single signal on the left of the fork, it will still function as a two-way rail, but the trains will always take the siding when approaching from the appropriate direction (trains always stay to their right).

zytukin
Fast Inserter
Fast Inserter
Posts: 215
Joined: Sat Mar 12, 2016 12:14 am
Contact:

Re: Train signal and/or pathfinding weird thing

Post by zytukin »

Train path finding in general can be weird.

I had built this little siding just after my unloading stations, it has a station named 'temp' so I could use it to park some extra trains when I was extending the waiting area for stations to prevent trains from blocking the main line into the stations. Ended up not having to use it, otherwise there would be more signals on it so multiple trains could park on it. Oddly, when leaving the stations, half the trains will take the route through the 'temp' station. It could be that the game considers them both the same length (although realistically the curves do add some distance) or that the game looks for the path with less signals.
rail siding.jpg
rail siding.jpg (76.76 KiB) Viewed 2743 times
The real odd one. It's kinda hard to see in this picture.
The perimeter wall around my factory has a rail line alongside it so a train can loop around feeding walls and repair packs for the construction bots to use for repairs, it is a single direction loop (red arrows is the travel direction). It consists of 10 sections all divided by ponds and has stations named 'wall 1' to 'wall 10'. Near the right side center of the picture is where the unloading stations are, along with the loading station for repair packs and walls ('A' on the picture). There is a rail line that goes through the factory to the storage yard where I park trains until needed. There is a rail line coming off this line through the factory that goes north through the solar panel field (used it to bring large qtys of panels and accumulators when I was building it). It does connect to the rail line along the wall between stations 'Wall 8' and 'Wall 9' ('B' on the picture). When I first built the wall I was manually sending a train to each section to unload a full load of repair packs and walls so they would all have a good amount before I set the train to automatic and stopping at each station.

When I told the train to go from A to B on the picture, the train took the fastest route, through the factory and north though the solar fields.
When I told the train to go from A to C on the picture, the train insisted on taking the longer route, it wanted to follow the red arrows around the perimeter walls which is over 3x longer.
I had to manually drive the train into the factory before turning on automatic mode to make it take that quicker route. Nothing had changed since it went to B. No trains were in the factory (only time they go through is if I manually tell them to).
map2.jpg
map2.jpg (289.19 KiB) Viewed 2743 times

Targa
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 11, 2016 8:42 pm
Contact:

Re: Train signal and/or pathfinding weird thing

Post by Targa »

Posting your save file would help in determining why the train would choose the longer route.

Post Reply

Return to “General discussion”