📜 ⬆️ ⬇️

JavaScript Path Search Algorithms



Finding the best route for a unit to a target on an unknown map is one of the most difficult tasks when developing a game. Fortunately, there are a number of algorithms that solve this problem. There is also an excellent PathFinding.js library with support for 11 such algorithms.

The library is easy to integrate into any web game. They say it is perfectly optimized for specific architectures, while productivity increases by an order of magnitude.

At http://qiao.github.com/PathFinding.js/visual there is an online demo with nice visualization of algorithm execution. Here the speed is artificially low (for beauty).
')
Now 11 algorithms are supported:

For algorithms, three heuristics for calculating the distance are implemented: Manhattan (distance of city blocks), Euclidean metric and Chebyshev distance . Each of them uses a heuristic analysis to determine the prospects of a possible direction of the future path, that is, what is the distance from the neighboring squares to the target, in accordance with the definition of distance.

Source: https://habr.com/ru/post/238001/


All Articles