5 Questions about train pathfinding + complaints

Post all other topics which do not belong to any other category.
Post Reply
Jupiter
Fast Inserter
Fast Inserter
Posts: 174
Joined: Thu Jun 23, 2016 2:38 pm
Contact:

5 Questions about train pathfinding + complaints

Post by Jupiter »

I am going to complain about train behavior (Yes, I know. I'm not the first and will not be the last to complain about it) and I have some questions.

According to the wiki (https://wiki.factorio.com/index.php?tit ... th_finding) every path is assigned a penalty or cost depending on the length of the path. First a question:
1. Is a single curved piece considered to be of 1 length (being equal with a straight rail piece in path finding)? Or 4 because it costs 4 straights to build 1 curve?

The wiki also says that it penalizes occupied blocks based on the length of the block and its distance from the starting point.
2. Is the length counted as number of rail-pieces or actual tiles? And what about curves?
3. Is the starting point the place where the train originally came from or his current position?
4. Is the distance counted up to the signal with which the occupied block starts? Or somewhere's in the middle? The wiki talks about 'the block distance' from the starting point. This does not mean the number of blocks between the start and the occupied block right?
5. And does the rail-piece right next to this signal count for the distance or for the length of the block? What about the ending signal's rail-piece?

Regarding question 4. If 'block distance' does not mean number of blocks then the formula for the penalty would become penalty = 2 * length / distance_in_tiles. But this is typically a very small number, lower than 1. How can this ever have a noticeable effect on the total penalty of a blocked path?

Now the complaining. The wiki seems to be telling just half the story. I did some experimenting and found out that the distance between starting point and occupied block doesn't matter at all. The only noticeable effect seems to come from the number of occupied blocks along a certain path, not their distance to the start or their length.

This is clearly not desired behavior:
Image

In this img there are wagons on both paths and there is a wagon at the exit near the trainstop that blocks both paths.

It shows that the distance (between occupied blocks and start point) has little effect on the penalty.
Also, you can flip the path the train chooses by adding additional signals alongside the wagons on either of the paths. The effect this has is that you are subdividing up the existing occupied blocks into smaller ones without increasing the number of occupied rail-pieces. What I see happening is, the more occupied blocks a path has (when keeping number of occupied rail-pieces the same) the less likely a train is to choose it. Only when the number of occupied blocks is the same for both paths the train will take the shorter path. Otherwise it just takes the path with the least occupied blocks regardless of path length.

Post Reply

Return to “General discussion”