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

more goals in sequence?

Open Simus100 opened this issue 7 years ago • 4 comments

hi, is it possible to create a path composed of several objectives? I would like some advice on how to implement the code by building a path that is obliged to go through a specific node before reaching the final goal..

Simus100 avatar Mar 22 '18 16:03 Simus100

I guess the simplest would be to only create paths from your start point to the first goal, then from the first to the second etc. and concatenate everything to the whole path. This should be the best if you need to go through every one of your goals.

Alternatively, if you have a weighted algorithm you could add a special weight value for your goals so the algorithm prioritizes your goals, if they are on the path but it does not assure you to go through all goals.

brean avatar Mar 22 '18 17:03 brean

Hi, thanks for the reply.. Any advice on how to implement the concatenation in the code?? i have done various tests but don't work.

Simus100 avatar Mar 23 '18 11:03 Simus100

The path is just a list of points in an array so you should be able to use the buildin-javascript concat (see here where array1 and array2 are the 2 paths you like to concat )

brean avatar Mar 23 '18 11:03 brean

sorry for the stupid question but I can not find the exact point in the pathfinding-browser.js where you can insert the result path in my array and concatenate it with another

Simus100 avatar Apr 05 '18 12:04 Simus100