0.4.2 • Published 5 years ago
game-algo v0.4.2
A bunch of random utils for game development in js.
AStar
A* Search algorithm implementation.
Kind: global class
aStar.reset(graph, start, goal)
Reset astar runner so you can use a diff graph, start or goal.
Kind: instance method of AStar
Param |
---|
graph |
start |
goal |
aStar.reconstructPath(current)
Rebuild path from.
Kind: instance method of AStar
Param |
---|
current |
aStar.heuristicCostEstimate(start, goal)
Calculate the heuristic cost.
Kind: instance method of AStar
Param |
---|
start |
goal |
aStar.distBetween(v1, v2)
Calculate distance between two nodes
Kind: instance method of AStar
Param | Type |
---|---|
v1 | * |
v2 | * |
aStar.step() ⇒ Boolean | Array
Take a single step through the algorithm, this is mostly exposed for doing demos/visualization.
Kind: instance method of AStar
Returns: Boolean | Array - A bool indicating it's still running, or an array of the shortest path.
aStar.run(graph, start, goal)
Find the shortest path from one node to another in a graph.
Kind: instance method of AStar
Param |
---|
graph |
start |
goal |