shortest-path icon indicating copy to clipboard operation
shortest-path copied to clipboard

Add alternative routes and tile distance display

Open sasoder opened this issue 1 year ago • 7 comments

Fixes #169, maybe some aspect of #120

Adds two new features to help players compare different travel options:

image
  • Alternative paths: show multiple teleport options after the best path. Configurable count (0-10) via new "Show alt. paths" setting. image

  • Path length: all paths can now show their tile distance in parentheses for easier comparison. image

sasoder avatar Jul 27 '25 21:07 sasoder

This is a nice addition!

Would it not make more sense to list the alternative paths in ascending order from shortest at the top to longest at the bottom, similar to how most people read a book?

  • It uses async pathfinding with iterative A* with tp options used in the better path removed.

Is there any particular reason why are you using A*? Could you not simply let the BFS pathfinder continue running once it found the shortest path?

private final Set<TransportId> excludedTransportIds;

Why are you creating a new TransportId class instead of using Set<Transport> excludedTransports to keep track of the excluded transports?

Skretzo avatar Jul 28 '25 18:07 Skretzo

Thank you!

During testing I actually started with shortest at the top, but found that always having the best teleport in the same place on the tile made it much less confusing, since the number of lines and their height changes as you adjust the alternatives count.

You're right on the other parts, I replaced TransportId with Set<Transport> now, much cleaner.

Let me know if you want to have the order reversed and I can change that as well. Making it a different color is also pretty nice actually, lmk:

image

image

sasoder avatar Jul 28 '25 20:07 sasoder

During testing I actually started with shortest at the top, but found that always having the best teleport in the same place on the tile made it much less confusing, since the number of lines and their height changes as you adjust the alternatives count.

Good point. Keep it the way you did it with the shortest at the bottom.

Making it a different color is also pretty nice actually, lmk:

A different colour for the shortest path is a nice addition. You could also make that configurable too, since the white text is already configurable.

Skretzo avatar Jul 28 '25 23:07 Skretzo

@Skretzo I ended up reworking it from scratch by aligning more with the existing codebase + your suggestions. It also solved some bugs. You can now also select a color for the best path if alternatives are showing!

image image image

sasoder avatar Jul 29 '25 20:07 sasoder

This is a fantastic change! Let me know if there's anything I can do to help push this into the next published build. I also want to bump this!

BeniReydman avatar Aug 27 '25 23:08 BeniReydman

This is a fantastic change! Let me know if there's anything I can do to help push this into the next published build. I also want to bump this!

Hehe, I have not made it easy for other people to contribute, since I keep changing the code. So they constantly need to fix the conflicts. I have a few things I want to test myself, but haven't had the time to do it yet.

Skretzo avatar Aug 27 '25 23:08 Skretzo

@Skretzo let me know if you're down to merge the pr if I resolve the conflicts and I'll get on it :) or are you currently working on architectural changes that might affect it?

I'm currently pretty low on time so happy for @BeniReydman to co-author if that helps move things forward

sasoder avatar Aug 28 '25 15:08 sasoder