Class: BiAStarFinder

PFBiAStarFinder

new BiAStarFinder(allowDiagonal, [heuristic])

Bi-directional A* path-finder.

Source:
./src/modules/BiAStar.js, line 11
Parameters:
Name Type Argument Description
allowDiagonal boolean Whether diagonal movement is allowed.
heuristic function(number, number): number <optional>
Heuristic function being used to estimate the distance(defaults to manhattan).

Extends

Requires

  • module:PF.Heap
  • module:PF.Heuristic

Methods

<protected> _calculateH(x, y, which) → {number}

Calculate the `h` value of a given position.

Source:
./src/modules/BiAStar.js, line 323
Parameters:
Name Type Description
x number The x coordinate of the position.
y number The y coordinate of the position.
which string Inspection by `source` or `target`.
Returns:
The heuristic value.
Type
number

<protected> _constructPath(x1, y1, x2, y2, which) → {Array.<Array.<number>>}

Construct the path according to the nodes' parents.

Source:
./src/modules/BiAStar.js, line 276
Parameters:
Name Type Description
x1 number X coordinate of one of the meeting nodes.
y1 number Y coordinate of one of the meeting nodes.
x2 number X coordinate of the other meeting node.
y2 number Y coordinate of the other meeting node.
which string Construction initiated by `source` or `target`.
Returns:
The path, including both start and end positions.
Type
Array.<Array.<number>>

_expand(which) → {boolean}

Expand one of the queues.

Source:
./src/modules/BiAStar.js, line 106
Parameters:
Name Type Description
which string Expand `source` or `target`.
Returns:
Whether the path has been found.
Type
boolean

_expandSource() → {boolean}

Expand the source open list.

Source:
./src/modules/BiAStar.js, line 87
Returns:
Whether the path has been found.
Type
boolean

_expandTarget() → {boolean}

Expand the target open list.

Source:
./src/modules/BiAStar.js, line 96
Returns:
Whether the path has been found.
Type
boolean

<protected> _find() → {Array.<[number, number]>}

Find and return the the path.

Source:
./src/modules/BiAStar.js, line 26
Returns:
The path, including both start and end positions.
Type
Array.<[number, number]>

<protected> _inspectNodeAt(x, y, px, py, isDiagonal, which) → {boolean}

Push the position into the open list if this position is not in the list. Otherwise, if the position can be accessed with a lower cost from the given parent position, then update its parent and cost

Source:
./src/modules/BiAStar.js, line 205
Parameters:
Name Type Description
x number The x coordinate of the position.
y number The y coordinate of the position.
px number The x coordinate of the parent position.
py number The y coordinate of the parent position.
isDiagonal boolean Whether [x, y] and [px, py] is diagonal
which string Inspection by 'source' or 'target'.
Returns:
Whether the path has been found.
Type
boolean

<protected> _inspectSurround(x, y, which) → {boolean}

Inspect the surrounding nodes of the given position

Source:
./src/modules/BiAStar.js, line 129
Parameters:
Name Type Description
x number The x coordinate of the position.
y number The y coordinate of the position.
which string Inspection by 'source' or 'target'.
Returns:
Whether the path has been found.
Type
boolean

<protected> _inspectSurroundDiagonal(x, y, which) → {boolean}

Inspect the surrounding nodes of the given position (including the diagonal ones).

Source:
./src/modules/BiAStar.js, line 159
Parameters:
Name Type Description
x number The x coordinate of the position.
y number The y coordinate of the position.
which string Inspection by 'source' or 'target'.
Returns:
Whether the path has been found.
Type
boolean

<protected> _tryUpdate(x, y, px, py, isDiagonal, which) → {boolean}

Try to update the position's info with the given parent. If this position can be accessed from the given parent with lower `g` cost, then this position's parent, `g` and `f` values will be updated.

Source:
./src/modules/BiAStar.js, line 248
Parameters:
Name Type Description
x number The x coordinate of the position.
y number The y coordinate of the position.
px number The x coordinate of the parent position.
py number The y coordinate of the parent position.
isDiagonal boolean Whether [x, y] and [px, py] is diagonal
which string Inspection by 'source' or 'target'.
Returns:
Whether this position's info has been updated.
Type
boolean