具有多个可能终点的二维路径查找?
我目前还有另一个问题与Java中的路径查找有关。 但我觉得这是一个单独的问题。
我正在制作一个游戏。 寻路需要能够处理多个可能的端点。 我发现的所有寻路算法和教程都只有一个终点。
这种改变是否很容易调整到已经存在的代码中,或者我最好尝试从头开始编写自己的代码?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用
A*
,但图形中有多个可被视为目标的顶点,您可以估计到每个目标的距离,并使用最小值。 只要您不高估到目标的真实距离,A*
就会起作用。但是,这种特殊行为可能会导致您编写自己的
A*
实现。 代码并不多; 对于大学生来说,IIRC 可能需要一两天的家庭作业。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.我对游戏了解不多,但 Floyd-Warshall 是一个多端点最短路径算法。
I don't know much about games but Floyd-Warshall is a multiple endpoint shortest path algorithm.