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

Adding non binary cost to A*

Open ricick opened this issue 11 years ago • 15 comments

Would it be possible to add a non binary cost (e.g. 0.5) to matrices, so cells can be counted as walkable but costing more, to allow taking terrain speed into account for example.

ricick avatar Jul 01 '13 03:07 ricick

This feature could be implemented for A*. However, some other algorithms in this library such as the Breadth-First-Search and the Jump-Point-Search can not use non-uniform cost. Therefore, this behavior may lead to inconsistencies between the APIs.

qiao avatar Jul 01 '13 15:07 qiao

This fork adds cost support for A*: https://github.com/johnste/PathFinding.js

MasterScrat avatar Nov 18 '13 00:11 MasterScrat

FYI - I was also looking for cost support ... Going to check out the fork. (Thank you for the great library Qiao!)

dwabyick avatar Nov 25 '14 15:11 dwabyick

Hey has anyone used this Fork and can share a bit about how it is implemented? I think this should really be part of the A* constructor, it really is necessary for more complex path finding.

rohan-deshpande avatar Nov 27 '14 02:11 rohan-deshpande

I was thinking about adding support for this as this is quite a common scenario for A*. But as pointed out by @qiao will have to think about which other finders is it relevant for.

imor avatar Nov 27 '14 03:11 imor

Any updates on merging the https://github.com/johnste/PathFinding.js fork into pathfinding?

It's two years behind and probably has a lot of merge conflicts by now...

If someone were to go through the effort of cleaning it and making another PR would it get accepted?

tlhunter avatar Mar 25 '15 18:03 tlhunter

johnste's fork only adds support for A*. If anyone is interested in doing this please keep in mind that it needs to be done for other finders as well (wherever it makes sense). Before jumping in though, a discussion about the intended plan would be useful in this thread.

imor avatar Mar 26 '15 06:03 imor

I don't really have time but I think this is a necessary feature for an A* pathfinder. I think it would be awesome if it was made part of the official repo and offered as an option for the A* algorithm (if possible).

rohan-deshpande avatar Mar 27 '15 03:03 rohan-deshpande

+1 for this

tarlepp avatar Apr 01 '15 16:04 tarlepp

I have added a fork with support for non uniform node cost https://github.com/paulrobello/PathFinding.js I have also added a pull request https://github.com/qiao/PathFinding.js/pull/100

paulrobello avatar May 21 '15 17:05 paulrobello

I like you addition paulrebello.

I note that trace has been removed as being the same as bestfirst, but in my application trace consistently outperforms bestfirst by 5-10%, what is the difference?

bentwonk avatar May 25 '15 23:05 bentwonk

+1

Shouldn't be a problem to throw an error if the cost parameter is used with an unsupported algorithm?

PSeitz avatar Jul 27 '15 16:07 PSeitz

@paulrobello thanks for your fork! Does this add cost to other algorithms other than the A*?

rohan-deshpande avatar Apr 24 '16 01:04 rohan-deshpande

Sorry just read the PR! Great stuff!

rohan-deshpande avatar Apr 24 '16 01:04 rohan-deshpande

@qiao any reason not to merge this? would be nice to get it into the npm

pajtai avatar Oct 18 '19 22:10 pajtai