astar-typescript icon indicating copy to clipboard operation
astar-typescript copied to clipboard

Feature Request: "Get as close as possible" option when the path is blocked

Open sefabaser opened this issue 5 years ago • 1 comments

Sample Code

let finder = new AStarFinder({
  grid: {
    matrix: [
      [0, 0, 0, 0],
      [0, 1, 1, 0],
      [0, 1, 0, 1],
      [0, 1, 1, 0]
    ]
  },
  heuristic: 'Manhatten',
  diagonalAllowed: false
});

console.log(finder.findPath({ x: 0, y: 0 }, { x: 3, y: 3 }));

Current Behaviour

Because the path is blocked to target there is no path is found. output: []

Expected Behaviour

Having an option "getAsCloseAsPossible". Which will find to the path to x: 3, y: 1 position. output: [[1, 0], [2, 0], [3, 0], [3, 1]]

Note: It is, of course, possible to find an alternative target position manually. But the next available position to the target is the position x: 2, y: 2 which is also not reachable. The complexity of finding the closest available position is lower on finding it in the shortest path algorithm.

sefabaser avatar Jul 05 '20 13:07 sefabaser

Still, this feature is needed, any progress?

sefabaser avatar Feb 13 '22 11:02 sefabaser

@sefabaser Thank you for your input. The Feature was implemented in the latest version 1.2.7. Maybe you can check it out and see if it works for you?

digitsensitive avatar Apr 26 '23 22:04 digitsensitive

It does not work.

thilidric avatar Oct 10 '23 20:10 thilidric