CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
574 stars 85 forks source link

Trains zig zag on bi-directiona tracks #1486

Closed kianzarrin closed 2 years ago

kianzarrin commented 2 years ago

based on: https://github.com/CitiesSkylinesMods/TMPE/pull/1483#issuecomment-1075259163

For each lane transition routing manager calculates distance between similar lane index between the two lanes. Similar lane index for bidirectional train tracks can flip if you reverse the segment placement. Therefore, if you reverse the placement of bidirectional train network, then trains will PREFER to zigzag on middle nodes (to minimize cost of transition) even though all lane transitions will be created.

image in the picture I have used 3 bidirectional segments between the two train stations. the middle one is placed at reverse direction. That is why the trains would prefer to zigzag. I also have forced a node in the middle. if you zoom in you notice all lane transitions are created but the preferred transition is the zigzagged one.

in such circumstances:

Also we need to look at the code to see if there is any other situations in which we might compare inner/outer similar lane index.

kianzarrin commented 2 years ago

I used this AN asset to test lane transitions: train-tracks-2x2-bi.zip

kianzarrin commented 2 years ago

Damn it gets even more confusing when unidirectional is connected to bidirectional track.

kianzarrin commented 2 years ago

what if A) "vanilla 2x2 train station" connects to B) "normal vanilla 2x2 train network"? A) both lanes have similar lane index of 0 (because one of them is avoid forward and the other is avoid backward). B) both lanes have similar lane index of 0 (because one of them is forward and the other is backward). This means there is no penalty for zigzag since the distance is always zero. this is only important for trains who want to stop at the station though. at that point I am not sure if zigzag even matters.