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

Added support for non uniform node cost

Open paulrobello opened this issue 9 years ago • 5 comments

Added optional cost member to Node which will then be used by AStarFinder and DijkstraFinder. Updated Grid with extra cost related functions and optional initialization of cost values. I have also added test cases for added cost to nodes. No changes to base API. If cost related data is omitted all will function exactly the same.

paulrobello avatar May 21 '15 16:05 paulrobello

Just a question about this great PR, do you need to tell the algorithms to look for cost or does it just happen? Just looking at your pathTests you have a property useCost: true on the AStar Cost test for instance, is this just for the testing purposes or do we need to set this in the algorithm constructor options?

rohan-deshpande avatar May 13 '16 00:05 rohan-deshpande

@rohan-deshpande the useCost is only used for tests, the additions I made will use the costs if they are provided to the constructor otherwise it just falls back to the normal equal cost routing.

paulrobello avatar Feb 15 '17 17:02 paulrobello

I tried this PR in your fork, and it could benefit from some adjustments in the Grid constructor arguments. Since it was originally designed for different argument types, you now have to pass dummy arguments for the height and width params: new pf.Grid(map, 0, 0, costs);

Or maybe this would be fine with appropriate documentation.

mx781 avatar Mar 13 '17 02:03 mx781

@qiao Any reason why this can't get merged? I've been using the fork for a while now and would like to be able to go back to the main branch

rohan-deshpande avatar Aug 29 '17 03:08 rohan-deshpande

Hi, What is the syntax for setting the cost of console nodes? thank you.

simus100 avatar Apr 05 '18 10:04 simus100