Hint, performance Trackbuilding

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Lifeguard78
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jul 03, 2016 11:34 pm
Contact:

Hint, performance Trackbuilding

Post by Lifeguard78 »

Hi,

after your Explanation, how Trackbuilding works today, I would suggest, to put a Segment layer in between.

So a Track is member of a Segment. A Segment is a Connection between 2 Points.
And only if A Track Action leads do a Change, that 2 connected Points are affekted, you Need to recalculate path finding.


So if you have a double sided connected Segment, and you delete a track, you get 2 new Segmentes, with open Ends.
In this case, you Need to recalculate only those paths, used by the Segment.

If you build a track. And only, if this Action leads to the Situation, that this Segments connect 2 Points with Connections to the Network, then, all paths Need to be recalculated.

To Stretch calculations, I would mark Train scedules as Calculated. Only if a new Segment closes a new Connection, I would reset this mark. So if a Train goes for new Destination, it calculates the way new, if this mark is false.

And at the end, recalculating the rest of the paths, not actualy used, is something, a backround working Task in a multithreading enviroment can handle.
Tekky
Smart Inserter
Smart Inserter
Posts: 1040
Joined: Sun Jul 31, 2016 10:53 am
Contact:

Re: Hint, performance Trackbuilding

Post by Tekky »

I believe OpenTTD, which is open source, also uses segments instead of individual track pieces when doing its pathfinding calculations.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14822
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Hint, performance Trackbuilding

Post by Rseding91 »

Tekky wrote:I believe OpenTTD, which is open source, also uses segments instead of individual track pieces when doing its pathfinding calculations.
Factorio does as well but the result path is the list of rails the train needs to travel on.

Checking which segment was removed vs if the rail still exists is the same cost just it makes it far easier to check the rails.
If you want to get ahold of me I'm almost always on Discord.
Lifeguard78
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun Jul 03, 2016 11:34 pm
Contact:

Re: Hint, performance Trackbuilding

Post by Lifeguard78 »

Well, I do have a Segment, defined between 2 (Nodes) Points.
For each Segment, I store the distance between it s endpoints, so in pathfinding I do not have to run through all the tracks. Only through the nodes and it s corresponding segments.

If you bring up another Object, calles System. If you have some not connected Train Systems, you can directly adress Trains to the System affected, while setting recalculation flag.

So if you lay a track in the Dessert, it gets a new Segment identifier, as well System identifier. As Long it is not connected to any used tracks, it does not start any calculations.
It will rais cost of deleting tracks, because you have to figure out, if you end up with 2 Systems, and then renaming the smaller Portion. But, on the other Hand, with this calculation you easily can see broken paths, if a Train has stations of different Systems.
Post Reply

Return to “Ideas and Suggestions”