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

TravelManager.singleSourceShortestPath does not find the shortest path #2

Open
totof99 opened this issue Oct 7, 2024 · 0 comments
Open

Comments

@totof99
Copy link

totof99 commented Oct 7, 2024

Hi,
I found a strange behavior when astronauts plan their path, ignoring a teleporter.
In function singleSourceShortestPath, if the graph has two ways to reach the same target building, the first path visited is considered the shortest distance, even if a path later is shorter.

Here an example:
5
4 100000
0 20 35
1 1 1 1 1 1 1 1 1 1
2 25 30
2 25 40
1 35 35
0 0
0 0
0 0
0 0

The first turn, print "TUBE 0 1;POD 1 0 1 0;TUBE 0 2;POD 100 0 2 0;TUBE 1 3;POD 200 1 3 1;TELEPORT 2 3"

we have:
0 <-> 1<-> 3
0 <-> 2 -> 3
The cost of path [0, 1, 3] should be 2 (2 tubes).
And the cost of path [0 2, 3] should be 1 (1 tube + 1 TP).
But astronauts always take path [0, 1, 3].

In singleSourceShortestPath, both path are evaluated to 2, because building 1 is evaluated first, then building 3 (from building 1), and then only building 2. Since the algorithm does not refresh distances, building 3 is never assigned the smaller path from building 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant