game-algo

0.4.2 • Public • Published

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

/game-algo/

    Package Sidebar

    Install

    npm i game-algo

    Weekly Downloads

    1

    Version

    0.4.2

    License

    MIT

    Unpacked Size

    9.88 kB

    Total Files

    6

    Last publish

    Collaborators

    • vantreeseba