Search code examples
c#path-findinga-star

A* Pathfinding Algorithm In C#, Implement Ladder System


I have already implemented A star path-finding in C# language via grid based system. But I am trying to make a system which will use a ladder to move to a shortest distance if there is any ladder available in that shortest. But i am without any clue how to do that , i have searched online and read a lot of posts still i am confused how to do that , so it will be much helpful to me how to add the ladder feature in a A star path-finding algorithm.

Image

Thanks.


Solution

  • Think of your ladders as vertices in your graph. Then you just need to apply A*, which is a best-first search. This is a well-documented algorithm. For 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.