new AStarFinder(allowDiagonal, [heuristic])
A* path-finder.
- Source:
- ./src/modules/AStar.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
Properties
-
constructor
-
The constructor of the instance.
- Source:
- ./src/modules/AStar.js, line 30
Methods
-
<protected> _calculateH(x, y) → {number}
-
Calculate the `h` value of a given position.
- Source:
- ./src/modules/AStar.js, line 162
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. Returns:
- Type
- number
-
<protected> _find() → {Array.<[number, number]>}
-
Find and return the the path.
- Source:
- ./src/modules/AStar.js, line 39
Returns:
The path, including both start and end positions.- Type
- Array.<[number, number]>
-
<protected> _inspectNodeAt(x, y, px, py, isDiagonal)
-
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/AStar.js, line 105
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 -
<protected> _inspectSurround(x, y)
-
Inspect the surrounding nodes of the given position
- Source:
- ./src/modules/AStar.js, line 175
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. -
<protected> _inspectSurroundDiagonal(x, y)
-
Inspect the surrounding nodes of the given position (including the diagonal ones).
- Source:
- ./src/modules/AStar.js, line 199
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. -
<protected> _tryUpdate(x, y, px, py, isDiagonal) → {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/AStar.js, line 138
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 Returns:
Whether this position's info has been updated.- Type
- boolean