PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

Find the shortest path with least turns

Open imwithye opened this issue 11 years ago • 5 comments

Sometimes, the shortest path is not enough. It requires a shortest path with less turns. It is quite normal in the robot and maze problem. For example, the graph below is the shortest path found by A* algorithm with Manhattan distance.

screenshot 2014-10-31 16 56 15

If we consider turning is an issue here, the actual shortest path is that go down then turn left and go to the goal directly. This path is the same weight with the shortest path found above but with less turns.

PathFinding.js is a great searching library but I notice that PathFinding.js does not provide this feature directly. Is there anyway to add the feature in and is there any plan to support this feature by default?

imwithye avatar Oct 31 '14 09:10 imwithye

Hi @imwithye You can take a look at https://github.com/qiao/PathFinding.js/pull/32. This PR was not merged because the changes were done in the wrong file. If you happen to make it work please consider opening a pull request.

imor avatar Nov 04 '14 14:11 imor

Neither #32 nor #150 can find the best path with least turns. For example: example In this case, the result (yellow) is not the best path (red).

cuixiping avatar Oct 29 '19 01:10 cuixiping