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

Is it correct to call grid.clone() before each new search?

Open mikolalysenko opened this issue 9 years ago • 2 comments

I am not sure if I am using this library correctly, but I would like to try comparing the performance of a new library I have written for 2D path searching to PathFinding.js. However, this library seems to have a serious flaw which is that you must completely reallocate the entire grid before each call to one of the search routines (thus defeating the whole purpose of optimizations like A*, which seek to reduce the number of cells visited). Is this actually the intended usage or am I just calling this library incorrectly like a bozo?!?

mikolalysenko avatar Apr 22 '15 06:04 mikolalysenko

You have to have a new grid before running a finder on it. You can do it either using the clone method or create a new Grid each time. The slowness of the clone method is a know issue. See #33. Sorry.

imor avatar Apr 26 '15 15:04 imor

Maybe you could use a free list or something to track the cells which get visited and clear them out when the search completes. Otherwise, it seems a bit foolish to even bother implementing an algorithm like A* or Jump-Point-Search.

mikolalysenko avatar Apr 26 '15 16:04 mikolalysenko