Relequestual
Relequestual

Reputation: 12305

2d path finding with multiple possible end points?

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

Answers (2)

JP Alioto
JP Alioto

Reputation: 45117

I don't know much about games but Floyd-Warshall is a multiple endpoint shortest path algorithm.

Upvotes: 1

erickson
erickson

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

Related Questions