[0.8.0] Train Pathfinding.

This subforum contains all the issues which we already resolved.
Post Reply
Gammro
Filter Inserter
Filter Inserter
Posts: 360
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

[0.8.0] Train Pathfinding.

Post by Gammro »

In my recent game, I am making a train heavy factory. This means a lot of dropoff and pickup stations to make the factory more flexible in expanding it. I recently built a coal depot and a new coal mine to connect it to. Now the train takes the correct route, MOST of the time. Sometimes, I observe the following routes from and to the depot:
Image

I understand that this is possibly because of path caching, and might not even be a bug, but more time-efficient if it accounts for other planned routes. I do hope to get an answer.

Edit: I've seen other trains behave similar, taking routes that are definitely not the shortest, but for example take all 4 loops instead of just the one that is needed to get there.
Ignore this

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by slpwnd »

There is no rail path caching. The path is always recalculated completely. The only thing that can influence the route at the moment are the one way streets. So it could be a bug. Could you post your save so we can have a look at it?

Gammro
Filter Inserter
Filter Inserter
Posts: 360
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Gammro »

Here's a bit older savegame where the situation is still like in the screenshot.

I am running these mods:
- Test mode
- Treefarm Mod
Attachments
Train Pathfinding.7z
Pathfinding savegame
(2.78 MiB) Downloaded 99 times
Ignore this

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by slpwnd »

So there is one more rule in the pathfinder I didn't mention:) When the next block is occupied or reserved (the train reserves his path 1-block ahead), then the path finder always prefers a different way. This makes sense for avoiding deadlocks on the 2-way single rail with occasional second rail for waiting trains. That is actually what is causing the issue here. If the train would be alone (I tried switching off all the other trains) it always takes the correct (shortest) path. The problem comes when he needs to stop on the signal because of some other train in the way. At that moment he looks whether there is not another way to take and it can happen that it is the "way around" in your scenario.

There is a relatively simple improvement that can be done (and will be for 0.8.1 unless we come up with something better). That is, that the train would recalculate the path also at the moment when the rail signal he is waiting at becomes free. I am saying improvement, not a fix, because it can still happen that the train will take a longer route. For instance if he needs to update the path, while he is on the roundabout. Then he can immediately take the longer (but free) path instead of waiting for the shorter one. I played with your save for a while and it happens now and then. But I consider it actually a correct behavior, because the train doesn't have a knowledge about what is happening ahead on the blocked rail and therefore he takes the shorter one.

If the train would have the knowledge, that the situation ahead will solve itself, then he could just wait for the shortest path and not recalculate. Something like Pathsignals?

P.S. Nice rail system;)

Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Neotix »

Put some signals on the circle to separate each line to other block.

It's how i'm setting signals on circle.
Image

Gammro
Filter Inserter
Filter Inserter
Posts: 360
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Gammro »

I deliberately chose not to put signals in the circle because I'm afraid it might cause deadlocks with 4 wagons behind an engine. With this setup, the intersection has to clear before a new train may enter
I'm also not yet at a point to mass produce signals.
Ignore this

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: [0.8.0] Train Pathfinding.

Post by rk84 »

You should at least use more signals in sections between circles. Because now as soon as train exits circle block it will reserve the next circle block.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Gammro
Filter Inserter
Filter Inserter
Posts: 360
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Gammro »

I've since added more signals to the tracks. At the time I posted the savegame, it was an already 20 minutes old autosave to best illustrate what happens. I know there are also some flaws in execution, but they can be improved :)

@NeoTix: What software do you use to make those drawings? They look cool, and useful.
Ignore this

Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Neotix »

I'm using AutoCad.

User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by cube »

Neotix wrote:I'm using AutoCad.
that's hardcore :-)
I have no idea what I'm talking about.

Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: [0.8.0] Train Pathfinding.

Post by Neotix »

Nope. I'm working on that software 8h every day so i'm used to it. Besides, I drew almost all important parts and copy/pasty as blocks them and snap them to grid. It's really very easy to design big structures, easier then build them in the game.

Example, design of my sorting line. I'm not tested it yet in game :P
Image

P.S Sorry for offtop :P

Post Reply

Return to “Resolved Problems and Bugs”