遍历所有给定节点的最快路径

发布于 2024-10-08 04:40:16 字数 213 浏览 2 评论 0原文

我正在编写一个简单的游戏,目前正在做人工智能部分。 NPC 获得他需要访问的“兴趣点”列表。每个点在地图上都有一个坐标。我需要找到一条最快的路径让角色访问所有给定点。

据我了解,该任务可以描述为“在强连接的加权无向图中找到最快的遍历路径”。

我想获得一些算法的名称来计算它,或者如果没有名称 - 我自己编程的一些要点。

提前致谢。

I'm coding a simple game and currently doing the AI part. NPC gets a list of his 'interest points' which he needs to visit. Each point has a coordinate on the map. I need to find a fastest path for the character to visit all of the given points.

As far as I understand it, the task could be described as 'finding fastest traverse path in a strongly connected weighted undirected graph'.

I'd like to get either the name of some algorithm to calculate that or if there is no name - some keypoints on programming it myself.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

匿名。 2024-10-15 04:40:17

这与旅行推销员问题非常相似,尽管我不会尝试证明等价性随手。 TSP 是 NP 完全的,这意味着精确地解决问题可能不切实际,具体取决于兴趣点的数量。您可能会发现一些更有用的近似算法。

This is very similar to the Travelling Salesman problem, although I'm not going to try to prove equivalency offhand. The TSP is NP-complete, which means that solving the problem exactly may be impractical, depending on the number of interest points. There are approximation algorithms that you may find more useful.

弥繁 2024-10-15 04:40:17

请参阅上一篇有关树遍历的文章:

树遍历算法对于包含大量文件的目录结构

尽揽少女心 2024-10-15 04:40:17

我会使用类似的算法:蚂蚁算法。

I would use algorithm like: ant algorithm.

鹤仙姿 2024-10-15 04:40:17

不是直接针对点,而是我在 MMO 模拟器中所做的是将航点索引与其余路径数据一起存储。如果您的要求是演示 TSP 解决方案,请忽略此内容。如果没有,我认为值得考虑。

就我而言,这是最好的解决方案,否则服务器可能会产生数百个生物(重新)生成,并且与所有其他人工智能逻辑一起,将不得不消耗循环计算路线逻辑。

Not directly on point but what I did in an MMO emulator was to store waypoint indices along with the rest of the pathing data. If your requirement is to demonstrate solutions to TSP then ignore this. If not, it's worth consideration IMO.

In my case it was the best solution as otherwise the server could have potentially hundreds of mobs (re)spawning and along with all the other AI logic, would have to burn cycles computing route logic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文