Implementation details on the train pathfinding (same path)

Things that are not directly connected with Factorio.

Implementation details on the train pathfinding (same path)

Postby harmony » Fri May 04, 2018 4:13 pm

Hey

was wondering if anyone has some info on how all the wagons of a train are kept on the same path.
Trying to implement my own train project (not planning on selling anyhting) and it's something I'm stuck at, the only thing I can currently do is make them pick a random turn at intersections

Image
works fine when there's no intersection obviously

Image
harmony
Manual Inserter
Manual Inserter
 
Posts: 1
Joined: Fri May 04, 2018 3:58 pm

Re: Implementation details on the train pathfinding (same path)

Postby betrok » Fri May 04, 2018 11:24 pm

I do not know how exactly the pathfinding works in factorio, but basically you have to build the weighted graph from your railroad.
The vertexes will represent intersections and possible other notable points such as stops. Weight of the edges can contain length of the section itself and stuff like a penalty for red signals.

harmony wrote:was wondering if anyone has some info on how all the wagons of a train are kept on the same path.

Well, all the wagons just follow the first one. Save the calculated path and use it for all of them.
betrok
Long Handed Inserter
Long Handed Inserter
 
Posts: 99
Joined: Wed Feb 28, 2018 12:08 pm

Re: Implementation details on the train pathfinding (same path)

Postby Jap2.0 » Fri May 04, 2018 11:57 pm

There are 10 types of people: those who get this joke and those who don't.
Jap2.0
Smart Inserter
Smart Inserter
 
Posts: 1538
Joined: Tue Jun 20, 2017 12:02 am


Return to Off topic

Who is online

Users browsing this forum: No registered users and 1 guest