Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trains prefer to stay in lane at all intersections #1483

Merged
merged 13 commits into from
Mar 24, 2022

Conversation

kianzarrin
Copy link
Collaborator

@kianzarrin kianzarrin commented Mar 21, 2022

fixes #1475
TMPE.zip

  • I check if the lane is a track only lane. that is train/metro/monorail/tram but mixed tram/car does not count.
  • I also check if both source/target segments have equal number of tracks.
  • if both of the above conditions are met then : Routing manager only creates one lane transition which is between the two lanes with equal similar Lane Index.
  • user can override the above behavior using lane connections

PS: Created TrackUtils class even though it has only one function. I might add more stuff to it in future if I deal with Continues junction barrier stuff (#1223) or if I bring Hide-Unconnectred-Tracks to TMPE. (maybe I should call it DirectConnectUtils)
PS2: I used $"{varaible}" to log stuff because it was more reliable. I hope you don't mind: #1484

EDIT: for bidirectional/station tracks I fall back to original code.

@kianzarrin kianzarrin added BUG Defect detected LANE ROUTING Feature: Lane arrows / connectors labels Mar 21, 2022
@kianzarrin kianzarrin self-assigned this Mar 21, 2022
verbose log
@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Mar 21, 2022

Test ✔️
image

@kianzarrin kianzarrin linked an issue Mar 22, 2022 that may be closed by this pull request
@kianzarrin kianzarrin added the Dependent This issue is blocked by another issue. label Mar 22, 2022
@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Mar 22, 2022

Test: lane connection tool can be used to change lane connections ✔️
image

@kianzarrin kianzarrin marked this pull request as ready for review March 22, 2022 00:55
TLM/TLM/Util/TrackUtils.cs Show resolved Hide resolved
TLM/TLM/Util/TrackUtils.cs Outdated Show resolved Hide resolved
Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looking fine

Base automatically changed from rman-warnings to master March 22, 2022 13:12
@kianzarrin kianzarrin removed the Dependent This issue is blocked by another issue. label Mar 22, 2022
@kianzarrin
Copy link
Collaborator Author

This logic fails for bi-directional tracks. it actually makes thing worse:
image
I need to reverse lane transitions for bi-directional tracks.

The rest of the code also use similar lane index and to calculate distance or something and does not care about bi-directional tracks problem.

I suspect if you put bidirectional roads in reverse direction trains will prefer to criss-cross even in the original code.

@kianzarrin
Copy link
Collaborator Author

kianzarrin commented Mar 22, 2022

I will ignore (i.e. fall back to old code) bi-directional lanes in this PR. I created #1486 to cover bi-directional problems for all of routing manager (note that the code already had problem with bidirectional lanes even before this PR).

@kianzarrin
Copy link
Collaborator Author

Its working as expected now: all lane transitions are created for bi-directional tracks
image

@originalfoo
Copy link
Member

will this PR benefit from some of the extensions you added in #1487

@kianzarrin
Copy link
Collaborator Author

@aubergine10

will this PR benefit from some of the extensions you added in #1487

No. All I need here is to ignore train/bidirectional lanes which I can detect using IsBidirectional(). I have deleted that in the next PR because its just a workaround for work that is outside of scope of this PR (#1483 (comment)).

In any case if you think the code is good you can approve this PR.

@kianzarrin kianzarrin merged commit 1c25aae into master Mar 24, 2022
@kianzarrin kianzarrin deleted the 1475-track-stayinlane branch March 24, 2022 23:42
@originalfoo originalfoo added this to the 11.6.5.2 milestone Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Defect detected LANE ROUTING Feature: Lane arrows / connectors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trains switch lanes too much
4 participants