trains getting stuck
Posted: Thu Nov 19, 2020 12:45 pm
why does this happen? they keep getting stuck like this, the upper train could take the red path but it just doesn't want to
When the path includes a train stop that is not the destination -> Add a penalty of 2000.
Yes, but there is this penalty.Zavian wrote: ↑Thu Nov 19, 2020 12:57 pmhttps://wiki.factorio.com/Railway/Train_path_finding
In particular the following bit.When the path includes a train stop that is not the destination -> Add a penalty of 2000.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
The divisor can never go below 1:Zanthra wrote: ↑Sat Nov 21, 2020 4:55 amYes, but there is this penalty.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
Code: Select all
// Neighbor segment penalties
if (!neighborSegment->getBlock()->isFree(request.train))
costFromStart += (2 * neighborSegment->getLength()) / (currentNode->blockDistanceFromStart + 1);
Ah so it is distance +1 which is very different in a situation like this.Loewchen wrote: ↑Sat Nov 21, 2020 5:19 amThe divisor can never go below 1:Zanthra wrote: ↑Sat Nov 21, 2020 4:55 amYes, but there is this penalty.
Given that there is no distance to the start of the occupied block, it's effectively infinite path cost, so it will be greater cost than pathing through the train depot. At the next 30 second repath event for waiting at chain signals, that train should be taking the top path.When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.Code: Select all
// Neighbor segment penalties if (!neighborSegment->getBlock()->isFree(request.train)) costFromStart += (2 * neighborSegment->getLength()) / (currentNode->blockDistanceFromStart + 1);
Unless I am misunderstanding that one too.
When the path includes a train currently waiting at a rail signal -> Add a penalty of 100 + 0.1 for every tick the train has already waited.
Which, i'll admit, would look like they are getting stuck.
yes, it resolves itself after 30 seconds or so. I just didn't wait long enough to see that until you pointed it out.
I set it up so that trains meet at that location, and it did take more than 5 minutes to clear on it's own, which could hurt throughput a fair bit.altaykilic wrote: ↑Sat Nov 21, 2020 2:27 pmyes, it resolves itself after 30 seconds or so. I just didn't wait long enough to see that until you pointed it out.
I'll post the save when I figure out how to do it