UNPKG

abstract-astar

Version:

Versatile A* (A Star) implementation in TypeScript.

28 lines (27 loc) 1.12 kB
export declare class MinHeap<Item> { private _getValue; private readonly _heapArray; private readonly _itemToIndex; constructor(_getValue: (item: Item) => number); upsert(item: Item): void; contains(item: Item): boolean; insert(item: Item): void; removeMinimum(): Item | undefined; private _swapIndexes; /** Recursively ensures the item at the given index is less than its children. */ private _heapifyDownFromIndex; } export declare function aStar<Node>({ start, goal, estimateFromNodeToGoal, neighborsAdjacentToNode, actualCostToMove: costToMove, }: { start: Node; goal: Node; /** Provide an estimate from the given node to the goal. */ estimateFromNodeToGoal: (node: Node) => number; neighborsAdjacentToNode: (node: Node) => Node[]; actualCostToMove: ( /** A map from a node to the node before it in the path. This can be used to provide cost based on the shape of paths. */ cameFromMap: Map<Node, Node>, /** We are moving from this node. */ from: Node, /** To this node. */ to: Node) => number; }): Node[] | undefined;