(require("findPath"))(start, end, nonRoutable, punishedButRoutable) → {Array}
Heavily modified implementation of the A* algorithm
Parameters:
Name | Type | Description |
---|---|---|
start |
Object | object containing numeric attributes |
end |
Object | object containing numeric attributes |
nonRoutable |
Set | set of non routable nodes |
punishedButRoutable |
Set | set of nodes that are not optimal for routing |
Returns:
Array -array of objects containing numeric attributes x
and y
Methods
-
inner movePoint(point, direction) → {Object}
-
Helper that moves the passed point in the specified direction. It simply adds or subtracts 1 from one of the coordinates depending on the direction attribute.
Parameters:
Name Type Description point
Object object containing numeric attributes
x
andy
direction
number directions: - 0: up - 1: right - 2: down - 3: left
Returns:
Object -object containing numeric attributes
x
andy
-
inner reconstructPath(cameFrom, currentNode) → {Array}
-
helper backtracking function used by the aStar algorithm to construct the final path
Parameters:
Name Type Description cameFrom
Object object containing numeric attributes
x
andy
currentNode
Object object containing numeric attributes
x
andy
Returns:
Array -array of objects containing numeric attributes
x
andy
-
inner setHasThisPoint(set, point)
-
returns
true
if the specified set of points contains the specified point (and returnsfalse
otherwise)Parameters:
Name Type Description set
Set set of points
point
Object object containing numeric attributes
x
andy