(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 pointObject object containing numeric attributes
xandydirectionnumber directions: - 0: up - 1: right - 2: down - 3: left
Returns:
Object -object containing numeric attributes
xandy -
inner reconstructPath(cameFrom, currentNode) → {Array}
-
helper backtracking function used by the aStar algorithm to construct the final path
Parameters:
Name Type Description cameFromObject object containing numeric attributes
xandycurrentNodeObject object containing numeric attributes
xandyReturns:
Array -array of objects containing numeric attributes
xandy -
inner setHasThisPoint(set, point)
-
returns
trueif the specified set of points contains the specified point (and returnsfalseotherwise)Parameters:
Name Type Description setSet set of points
pointObject object containing numeric attributes
xandy