malwoden
Version:
   
44 lines (43 loc) • 1.74 kB
TypeScript
import { Vector2 } from "../struct";
import { TerrainCallback, IsBlockedCallback } from "./pathfinding-common";
interface DijkstraConfig {
isBlockedCallback?: IsBlockedCallback;
getTerrainCallback?: TerrainCallback;
topology: "four" | "eight";
}
/**
* Dijkstra's algorithm is a breadth first search to find the goal.
* This makes it slower than AStar in most cases, as it doesn't know
* how to 'guess' if a tile is closer to the goal or not. However in
* most cases the difference in speed is negligible, and this
* version of Dijkstra's algorithm can occasionally result in more
* 'normal' looking paths.
*/
export declare class Dijkstra {
readonly topology: "four" | "eight";
private readonly _isBlocked?;
private readonly _getDistance;
/**
* @param config - General parameters for the AStar Pathfinder
* @param config.isBlockedCallback - Return true if the position is blocked.
* @param config.getTerrainCallback - Provide terrain costs for movement (optional)
* @param config.topology - four | eight
*/
constructor(config: DijkstraConfig);
private getDistance;
private getNeighbors;
private computePathBack;
/**
* Computes a given path from a start and end point. If not path is found,
* it will return undefined. Both the start + end points will be returned
* in the path.
*
* @param start Vector2 - The starting point
* @param end Vector2 - The ending point
*
* @returns RangeVector2[] | undefined - Returns the path,
* including start + end, or undefined if no path is found.
*/
compute(start: Vector2, end: Vector2): Vector2[] | undefined;
}
export {};