C#中的A*寻路算法,实现阶梯系统

A* Pathfinding Algorithm In C#, Implement Ladder System

我已经通过基于网格的系统用 C# 语言实现了星寻路。但是我正在尝试制作一个系统,如果在最短距离内有可用的梯子,它将使用梯子移动到最短距离。但我不知道该怎么做,我在网上搜索并阅读了很多帖子,但我仍然很困惑该怎么做,所以如何在 A 星路径中添加阶梯功能对我很有帮助-查找算法。

Image

谢谢。

将阶梯想象成图表中的顶点。然后你只需要应用 A*,这是一个最佳优先搜索。这是一个有据可查的算法。对于 example:

A* is an informed search algorithm, or a best-first search, meaning that it solves problems by searching among all possible paths to the solution (goal) for the one that incurs the smallest cost (least distance travelled, shortest time, etc.), and among these paths it first considers the ones that appear to lead most quickly to the solution. It is formulated in terms of weighted graphs: starting from a specific node of a graph, it constructs a tree of paths starting from that node, expanding paths one step at a time, until one of its paths ends at the predetermined goal node.