@esengine/pathfinding 1.0.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.ts +740 -0
- package/dist/index.js +1826 -0
- package/dist/index.js.map +1 -0
- package/module.json +24 -0
- package/package.json +61 -70
- package/README.md +0 -358
- package/dist/pathfinding.cjs +0 -566
- package/dist/pathfinding.cjs.map +0 -1
- package/dist/pathfinding.d.ts +0 -152
- package/dist/pathfinding.js +0 -572
- package/dist/pathfinding.js.map +0 -1
- package/dist/pathfinding.mjs +0 -558
- package/dist/pathfinding.mjs.map +0 -1
package/dist/pathfinding.d.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @esengine/pathfinding v1.0.8
|
|
3
|
-
* TypeScript definitions
|
|
4
|
-
*/
|
|
5
|
-
interface IVector2 {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
}
|
|
9
|
-
interface IComparableVector2 extends IVector2 {
|
|
10
|
-
equals?(other: IVector2): boolean;
|
|
11
|
-
}
|
|
12
|
-
declare class Vector2Utils {
|
|
13
|
-
private static readonly HASH_MULTIPLIER;
|
|
14
|
-
private static readonly MAX_COORD;
|
|
15
|
-
static equals(a: IVector2, b: IVector2): boolean;
|
|
16
|
-
static create(x: number, y: number): IVector2;
|
|
17
|
-
static clone(vector: IVector2): IVector2;
|
|
18
|
-
static add(a: IVector2, b: IVector2): IVector2;
|
|
19
|
-
static manhattanDistance(a: IVector2, b: IVector2): number;
|
|
20
|
-
static distance(a: IVector2, b: IVector2): number;
|
|
21
|
-
static toHash(vector: IVector2): number;
|
|
22
|
-
static toKey(vector: IVector2): string;
|
|
23
|
-
static fromHash(hash: number): IVector2;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface IPriorityQueueNode {
|
|
27
|
-
priority: number;
|
|
28
|
-
}
|
|
29
|
-
declare class PriorityQueue<T extends IPriorityQueueNode> {
|
|
30
|
-
private _heap;
|
|
31
|
-
private _size;
|
|
32
|
-
get size(): number;
|
|
33
|
-
get isEmpty(): boolean;
|
|
34
|
-
clear(): void;
|
|
35
|
-
enqueue(item: T): void;
|
|
36
|
-
dequeue(): T | undefined;
|
|
37
|
-
peek(): T | undefined;
|
|
38
|
-
private _bubbleUp;
|
|
39
|
-
private _bubbleDown;
|
|
40
|
-
private _swap;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface IAstarGraph<T extends IVector2> {
|
|
44
|
-
getNeighbors(node: T): T[];
|
|
45
|
-
cost(from: T, to: T): number;
|
|
46
|
-
heuristic(node: T, goal: T): number;
|
|
47
|
-
isNodePassable(node: T): boolean;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare class AStarNode implements IPriorityQueueNode {
|
|
51
|
-
node: IVector2;
|
|
52
|
-
priority: number;
|
|
53
|
-
gCost: number;
|
|
54
|
-
hCost: number;
|
|
55
|
-
parent: AStarNode | null;
|
|
56
|
-
hash: number;
|
|
57
|
-
constructor(node: IVector2, gCost?: number, hCost?: number, parent?: AStarNode | null);
|
|
58
|
-
updateCosts(gCost: number, hCost: number, parent?: AStarNode | null): void;
|
|
59
|
-
updateNode(node: IVector2, gCost?: number, hCost?: number, parent?: AStarNode | null): void;
|
|
60
|
-
reset(): void;
|
|
61
|
-
}
|
|
62
|
-
declare class AStarPathfinder {
|
|
63
|
-
private static _nodePool;
|
|
64
|
-
private static _tempPath;
|
|
65
|
-
private static _getNode;
|
|
66
|
-
private static _recycleNode;
|
|
67
|
-
static search<T extends IVector2>(graph: IAstarGraph<T>, start: T, goal: T): {
|
|
68
|
-
found: boolean;
|
|
69
|
-
goalNode?: AStarNode;
|
|
70
|
-
openSetNodes?: AStarNode[];
|
|
71
|
-
};
|
|
72
|
-
static searchPath<T extends IVector2>(graph: IAstarGraph<T>, start: T, goal: T): T[];
|
|
73
|
-
private static reconstructPathFromNode;
|
|
74
|
-
static hasPath<T extends IVector2>(graph: IAstarGraph<T>, start: T, goal: T): boolean;
|
|
75
|
-
static clearPool(): void;
|
|
76
|
-
static getPoolStats(): {
|
|
77
|
-
poolSize: number;
|
|
78
|
-
maxPoolSize: number;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
declare class AstarGridGraph implements IAstarGraph<IVector2> {
|
|
83
|
-
dirs: IVector2[];
|
|
84
|
-
walls: IVector2[];
|
|
85
|
-
weightedNodes: IVector2[];
|
|
86
|
-
defaultWeight: number;
|
|
87
|
-
weightedNodeWeight: number;
|
|
88
|
-
private _width;
|
|
89
|
-
private _height;
|
|
90
|
-
private _neighbors;
|
|
91
|
-
private _wallsSet;
|
|
92
|
-
private _weightedNodesSet;
|
|
93
|
-
private _wallsDirty;
|
|
94
|
-
private _weightedNodesDirty;
|
|
95
|
-
constructor(width: number, height: number);
|
|
96
|
-
addWall(wall: IVector2): void;
|
|
97
|
-
addWalls(walls: IVector2[]): void;
|
|
98
|
-
clearWalls(): void;
|
|
99
|
-
addWeightedNode(node: IVector2): void;
|
|
100
|
-
addWeightedNodes(nodes: IVector2[]): void;
|
|
101
|
-
clearWeightedNodes(): void;
|
|
102
|
-
private _updateHashSets;
|
|
103
|
-
isNodeInBounds(node: IVector2): boolean;
|
|
104
|
-
isNodePassable(node: IVector2): boolean;
|
|
105
|
-
search(start: IVector2, goal: IVector2): boolean;
|
|
106
|
-
searchPath(start: IVector2, goal: IVector2): IVector2[];
|
|
107
|
-
getNeighbors(node: IVector2): IVector2[];
|
|
108
|
-
cost(from: IVector2, to: IVector2): number;
|
|
109
|
-
heuristic(node: IVector2, goal: IVector2): number;
|
|
110
|
-
getStats(): {
|
|
111
|
-
walls: number;
|
|
112
|
-
weightedNodes: number;
|
|
113
|
-
gridSize: string;
|
|
114
|
-
wallsSetSize: number;
|
|
115
|
-
weightedNodesSetSize: number;
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface IUnweightedGraph<T extends IVector2> {
|
|
120
|
-
getNeighbors(node: T): T[];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
declare class BreadthFirstPathfinder {
|
|
124
|
-
static search<T extends IVector2>(graph: IUnweightedGraph<T>, start: T, goal: T, cameFrom?: Map<number, T>): boolean;
|
|
125
|
-
static searchPath<T extends IVector2>(graph: IUnweightedGraph<T>, start: T, goal: T): T[];
|
|
126
|
-
static reconstructPath<T extends IVector2>(cameFrom: Map<number, T>, start: T, goal: T): T[];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
declare class UnweightedGraph<T extends IVector2> implements IUnweightedGraph<T> {
|
|
130
|
-
edges: Map<T, T[]>;
|
|
131
|
-
addEdgesForNode(node: T, neighbors: T[]): this;
|
|
132
|
-
getNeighbors(node: T): T[];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
declare class UnweightedGridGraph implements IUnweightedGraph<IVector2> {
|
|
136
|
-
private static readonly CARDINAL_DIRS;
|
|
137
|
-
private static readonly COMPASS_DIRS;
|
|
138
|
-
walls: IVector2[];
|
|
139
|
-
private _width;
|
|
140
|
-
private _height;
|
|
141
|
-
private _dirs;
|
|
142
|
-
private _neighbors;
|
|
143
|
-
constructor(width: number, height: number, allowDiagonalSearch?: boolean);
|
|
144
|
-
isNodeInBounds(node: IVector2): boolean;
|
|
145
|
-
isNodePassable(node: IVector2): boolean;
|
|
146
|
-
getNeighbors(node: IVector2): IVector2[];
|
|
147
|
-
searchPath(start: IVector2, goal: IVector2): IVector2[];
|
|
148
|
-
hasPath(start: IVector2, goal: IVector2): boolean;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export { AStarPathfinder, AstarGridGraph, BreadthFirstPathfinder, PriorityQueue, UnweightedGraph, UnweightedGridGraph, Vector2Utils };
|
|
152
|
-
export type { IAstarGraph, IComparableVector2, IPriorityQueueNode, IUnweightedGraph, IVector2 };
|