-
Notifications
You must be signed in to change notification settings - Fork 27
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
Pathfinding bug (binary domain / calc_longest_path) #12
Comments
Yup, that issue was intentional since the beginning of the PCGRL and it is well known. Getting the longest shortest path is an np problem and to solve it accurately you need to do dikjstra The way we calculate is by running dijkstra twice leading to a good approximation with A higher accuracy solution is what you have suggested. The second run of dijkstra is to be repeated In the end, the function was not designed to return the perfect result but to return fast results for RL so |
Thanks so much for the detailed explanation! I missed the memo, clearly, but nonetheless an interesting problem to think about. The current approximation sounds like a reasonable tradeoff. Perhaps we should say "Calculate the approximate longest path on the map" for the sake of future naive coders like myself 🥲 . |
Sorry about all of that, It is my fault not to comment that :) Let's add that comment :) |
The following code returns a sub-optimal path:
This prints
{'regions': 1, 'path-length': 2}
, but the maximum path length is 3 (from bottom left to top right).In
calc_longest_path
, the empty tile (0, 0) is chosen as the source of a call torun_dijkstra
. This returns the following dijkstra map:. The extremities relative to this tile are tiles (1, 1) and (2, 0), which are both 2 away from (0, 0). But (1, 1) is chosen as the source of the next call to dijkstra, which results in:
, giving a path-length of 2.
If instead (2, 0) was chosen as the source of the second call to dijkstra, we would have:
, resulting in a path-length of 3.
One obvious fix would be to call dijkstra from each of the extremities that results from the first search, then record the maximum path-length over these. Is there any faster way?
The text was updated successfully, but these errors were encountered: