Reputation: 12305
I currently have another question to do with path finding in Java. However I feel this is a separate question.
I'm making a game. The path-finding will need to be able to deal with multiple possible end points. All the path finding algorithms and tutorials I have found only have one end point.
Would this alteration be easy to tweak into an already existing bit of code, or am I better off trying to write my own from scratch?
Upvotes: 1
Views: 2324
Reputation: 45117
I don't know much about games but Floyd-Warshall is a multiple endpoint shortest path algorithm.
Upvotes: 1
Reputation: 269647
If you are using A*
, but have multiple vertexes in your graph that can be considered goals, you could estimate the distance to each goal, and use the minimum. A*
will work as long as you don't over-estimate the true distance to the goal.
This special behavior might lead you to write your own A*
implementation, however. It isn't a lot of code; maybe a day or two of homework for a college student, IIRC.
Upvotes: 4