Added support for non uniform node cost
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.
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 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.
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.
@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
Hi, What is the syntax for setting the cost of console nodes? thank you.