screeps-clockwork 0.1.1 → 0.2.1
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/README.md +97 -4
- package/dist/index.js +270 -91
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/index.d.ts +11 -1
- package/dist/src/wasm/screeps_clockwork.d.ts +380 -0
- package/dist/src/wrappers/bfsDistanceMap.d.ts +20 -2
- package/dist/src/wrappers/bfsFlowField.d.ts +36 -3
- package/dist/src/wrappers/dijkstraDistanceMap.d.ts +18 -0
- package/dist/src/wrappers/dijkstraFlowField.d.ts +32 -0
- package/dist/src/wrappers/getRange.d.ts +9 -0
- package/package.json +62 -60
@@ -0,0 +1,380 @@
|
|
1
|
+
/* tslint:disable */
|
2
|
+
/* eslint-disable */
|
3
|
+
/**
|
4
|
+
* @returns {string}
|
5
|
+
*/
|
6
|
+
export function version(): string;
|
7
|
+
/**
|
8
|
+
* Exports the global range calculation between two positions.
|
9
|
+
* @param {number} packed_pos_1
|
10
|
+
* @param {number} packed_pos_2
|
11
|
+
* @returns {number}
|
12
|
+
*/
|
13
|
+
export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
14
|
+
/**
|
15
|
+
* WASM wrapper for the Dijkstra flow field function.
|
16
|
+
* @param {Uint32Array} start_packed
|
17
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
18
|
+
* @returns {FlowField}
|
19
|
+
*/
|
20
|
+
export function js_dijkstra_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
|
21
|
+
/**
|
22
|
+
* WASM wrapper for the Dijkstra mono flow field function.
|
23
|
+
* @param {Uint32Array} start_packed
|
24
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
25
|
+
* @returns {MonoFlowField}
|
26
|
+
*/
|
27
|
+
export function js_dijkstra_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
|
28
|
+
/**
|
29
|
+
* WASM wrapper for the BFS flow field function.
|
30
|
+
* @param {Uint32Array} start_packed
|
31
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
32
|
+
* @returns {FlowField}
|
33
|
+
*/
|
34
|
+
export function js_bfs_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
|
35
|
+
/**
|
36
|
+
* WASM wrapper for the Dijkstra distance map function.
|
37
|
+
* @param {Uint32Array} start_packed
|
38
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
39
|
+
* @returns {DistanceMap}
|
40
|
+
*/
|
41
|
+
export function js_dijkstra_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
|
42
|
+
/**
|
43
|
+
* WASM wrapper for the BFS distance map function.
|
44
|
+
* @param {Uint32Array} start_packed
|
45
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
46
|
+
* @returns {DistanceMap}
|
47
|
+
*/
|
48
|
+
export function js_bfs_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
|
49
|
+
/**
|
50
|
+
* WASM wrapper for the BFS mono flow field function.
|
51
|
+
* @param {Uint32Array} start_packed
|
52
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
53
|
+
* @returns {MonoFlowField}
|
54
|
+
*/
|
55
|
+
export function js_bfs_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
|
56
|
+
/**
|
57
|
+
* Translates `COLOR_*` and `COLORS_ALL` constants.
|
58
|
+
*/
|
59
|
+
export enum Color {
|
60
|
+
Red = 1,
|
61
|
+
Purple = 2,
|
62
|
+
Blue = 3,
|
63
|
+
Cyan = 4,
|
64
|
+
Green = 5,
|
65
|
+
Yellow = 6,
|
66
|
+
Orange = 7,
|
67
|
+
Brown = 8,
|
68
|
+
Grey = 9,
|
69
|
+
White = 10,
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Translates the `DENSITY_*` constants.
|
73
|
+
*/
|
74
|
+
export enum Density {
|
75
|
+
Low = 1,
|
76
|
+
Moderate = 2,
|
77
|
+
High = 3,
|
78
|
+
Ultra = 4,
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* Translates direction constants.
|
82
|
+
*/
|
83
|
+
export enum Direction {
|
84
|
+
Top = 1,
|
85
|
+
TopRight = 2,
|
86
|
+
Right = 3,
|
87
|
+
BottomRight = 4,
|
88
|
+
Bottom = 5,
|
89
|
+
BottomLeft = 6,
|
90
|
+
Left = 7,
|
91
|
+
TopLeft = 8,
|
92
|
+
}
|
93
|
+
/**
|
94
|
+
* Type used for when the game returns a direction to an exit.
|
95
|
+
*
|
96
|
+
* Restricted more than `Direction` in that it can't be diagonal. Used as the
|
97
|
+
* result of [`Room::find_exit_to`].
|
98
|
+
*
|
99
|
+
* Can be converted to [`Find`] for immediate use of [`Room::find`]
|
100
|
+
* and [`Direction`].
|
101
|
+
*
|
102
|
+
* [`Room::find`]: crate::objects::Room::find
|
103
|
+
* [`Room::find_exit_to`]: crate::objects::Room::find_exit_to
|
104
|
+
*/
|
105
|
+
export enum ExitDirection {
|
106
|
+
Top = 1,
|
107
|
+
Right = 3,
|
108
|
+
Bottom = 5,
|
109
|
+
Left = 7,
|
110
|
+
}
|
111
|
+
/**
|
112
|
+
* Translates `FIND_*` constants for interal API calls
|
113
|
+
*
|
114
|
+
* Unless you're storing the type of find constant to be used for a call, you
|
115
|
+
* likely want the constants which implement the `FindConstant` trait to make
|
116
|
+
* calls to find methods.
|
117
|
+
*
|
118
|
+
* This is hidden from the documentation to avoid confusion due to its narrow
|
119
|
+
* use case, but wasm_bindgen requires it remain public.
|
120
|
+
*/
|
121
|
+
export enum Find {
|
122
|
+
/**
|
123
|
+
* Find all exit positions at the top of the room
|
124
|
+
*/
|
125
|
+
ExitTop = 1,
|
126
|
+
ExitRight = 3,
|
127
|
+
ExitBottom = 5,
|
128
|
+
ExitLeft = 7,
|
129
|
+
Exit = 10,
|
130
|
+
Creeps = 101,
|
131
|
+
MyCreeps = 102,
|
132
|
+
HostileCreeps = 103,
|
133
|
+
SourcesActive = 104,
|
134
|
+
Sources = 105,
|
135
|
+
DroppedResources = 106,
|
136
|
+
Structures = 107,
|
137
|
+
MyStructures = 108,
|
138
|
+
HostileStructures = 109,
|
139
|
+
Flags = 110,
|
140
|
+
ConstructionSites = 111,
|
141
|
+
MySpawns = 112,
|
142
|
+
HostileSpawns = 113,
|
143
|
+
MyConstructionSites = 114,
|
144
|
+
HostileConstructionSites = 115,
|
145
|
+
Minerals = 116,
|
146
|
+
Nukes = 117,
|
147
|
+
Tombstones = 118,
|
148
|
+
PowerCreeps = 119,
|
149
|
+
MyPowerCreeps = 120,
|
150
|
+
HostilePowerCreeps = 121,
|
151
|
+
Deposits = 122,
|
152
|
+
Ruins = 123,
|
153
|
+
ScoreContainers = 10011,
|
154
|
+
ScoreCollectors = 10012,
|
155
|
+
SymbolContainers = 10021,
|
156
|
+
SymbolDecoders = 10022,
|
157
|
+
Reactors = 10051,
|
158
|
+
}
|
159
|
+
/**
|
160
|
+
* Translates the `EFFECT_*` constants, which are natural effect types
|
161
|
+
*/
|
162
|
+
export enum NaturalEffectType {
|
163
|
+
Invulnerability = 1001,
|
164
|
+
CollapseTimer = 1002,
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Translates the `PWR_*` constants, which are types of powers used by power
|
168
|
+
* creeps
|
169
|
+
*/
|
170
|
+
export enum PowerType {
|
171
|
+
GenerateOps = 1,
|
172
|
+
OperateSpawn = 2,
|
173
|
+
OperateTower = 3,
|
174
|
+
OperateStorage = 4,
|
175
|
+
OperateLab = 5,
|
176
|
+
OperateExtension = 6,
|
177
|
+
OperateObserver = 7,
|
178
|
+
OperateTerminal = 8,
|
179
|
+
DisruptSpawn = 9,
|
180
|
+
DisruptTower = 10,
|
181
|
+
Shield = 12,
|
182
|
+
RegenSource = 13,
|
183
|
+
RegenMineral = 14,
|
184
|
+
DisruptTerminal = 15,
|
185
|
+
OperatePower = 16,
|
186
|
+
Fortify = 17,
|
187
|
+
OperateController = 18,
|
188
|
+
OperateFactory = 19,
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Translates `TERRAIN_*` constants.
|
192
|
+
*/
|
193
|
+
export enum Terrain {
|
194
|
+
Plain = 0,
|
195
|
+
Wall = 1,
|
196
|
+
Swamp = 2,
|
197
|
+
}
|
198
|
+
/**
|
199
|
+
* A wrapper around the `LocalCostMatrix` type from the Screeps API.
|
200
|
+
* Instances can be passed between WASM and JS as a pointer, using the
|
201
|
+
* methods to get and set values, rather than copying the entire matrix.
|
202
|
+
*/
|
203
|
+
export class ClockworkCostMatrix {
|
204
|
+
free(): void;
|
205
|
+
/**
|
206
|
+
* Creates a new cost matrix within the WASM module. Optionally, a default value
|
207
|
+
* can be provided to initialize all cells in the matrix to that value.
|
208
|
+
* @param {number | undefined} [_default]
|
209
|
+
*/
|
210
|
+
constructor(_default?: number);
|
211
|
+
/**
|
212
|
+
* Gets the cost of a given position in the cost matrix.
|
213
|
+
* @param {number} x
|
214
|
+
* @param {number} y
|
215
|
+
* @returns {number}
|
216
|
+
*/
|
217
|
+
get(x: number, y: number): number;
|
218
|
+
/**
|
219
|
+
* Sets the cost of a given position in the cost matrix.
|
220
|
+
* @param {number} x
|
221
|
+
* @param {number} y
|
222
|
+
* @param {number} value
|
223
|
+
*/
|
224
|
+
set(x: number, y: number, value: number): void;
|
225
|
+
}
|
226
|
+
/**
|
227
|
+
* Maps a distance value onto individual room tile positions.
|
228
|
+
*/
|
229
|
+
export class DistanceMap {
|
230
|
+
free(): void;
|
231
|
+
/**
|
232
|
+
* Converts the distance map into a flat array of distances.
|
233
|
+
* @returns {Uint32Array}
|
234
|
+
*/
|
235
|
+
toArray(): Uint32Array;
|
236
|
+
/**
|
237
|
+
* Gets the distance value at a given position.
|
238
|
+
* @param {number} x
|
239
|
+
* @param {number} y
|
240
|
+
* @returns {number}
|
241
|
+
*/
|
242
|
+
get(x: number, y: number): number;
|
243
|
+
/**
|
244
|
+
* Sets the distance value at a given position.
|
245
|
+
* @param {number} x
|
246
|
+
* @param {number} y
|
247
|
+
* @param {number} value
|
248
|
+
*/
|
249
|
+
set(x: number, y: number, value: number): void;
|
250
|
+
}
|
251
|
+
/**
|
252
|
+
* A flow field is a 50x50 grid (representing a room), representing viable directions
|
253
|
+
* to travel to reach a particular target (or targets). A given tile may have multiple
|
254
|
+
* equally valid directions, so we represent this as a bitfield (where each bit in an
|
255
|
+
* 8-bit unsigned integer represents a direction that is either viable or not).
|
256
|
+
*/
|
257
|
+
export class FlowField {
|
258
|
+
free(): void;
|
259
|
+
/**
|
260
|
+
* Get the internal value for a given coordinate.
|
261
|
+
* @param {number} x
|
262
|
+
* @param {number} y
|
263
|
+
* @returns {number}
|
264
|
+
*/
|
265
|
+
get(x: number, y: number): number;
|
266
|
+
/**
|
267
|
+
* Set the internal value for a given coordinate.
|
268
|
+
* @param {number} x
|
269
|
+
* @param {number} y
|
270
|
+
* @param {number} value
|
271
|
+
*/
|
272
|
+
set(x: number, y: number, value: number): void;
|
273
|
+
/**
|
274
|
+
* Get the list of valid directions for a given coordinate.
|
275
|
+
* @param {number} x
|
276
|
+
* @param {number} y
|
277
|
+
* @returns {any[]}
|
278
|
+
*/
|
279
|
+
getDirections(x: number, y: number): any[];
|
280
|
+
/**
|
281
|
+
* Set the list of valid directions for a given coordinate.
|
282
|
+
* @param {number} x
|
283
|
+
* @param {number} y
|
284
|
+
* @param {any[]} directions
|
285
|
+
*/
|
286
|
+
setDirections(x: number, y: number, directions: any[]): void;
|
287
|
+
/**
|
288
|
+
* Add a direction to the list of valid directions for a given coordinate.
|
289
|
+
* @param {number} x
|
290
|
+
* @param {number} y
|
291
|
+
* @param {Direction} direction
|
292
|
+
*/
|
293
|
+
addDirection(x: number, y: number, direction: Direction): void;
|
294
|
+
}
|
295
|
+
/**
|
296
|
+
* A flow field is a 50x50 grid (representing a room), representing viable directions
|
297
|
+
* to travel to reach a particular target (or targets). A mono flow field only stores
|
298
|
+
* a single direction for each tile, so we represent this as 4 bits of an unsigned
|
299
|
+
* integer (0 for no direction, 1 for TOP, etc.).
|
300
|
+
*/
|
301
|
+
export class MonoFlowField {
|
302
|
+
free(): void;
|
303
|
+
/**
|
304
|
+
* Get the direction for a given coordinate.
|
305
|
+
* @param {number} x
|
306
|
+
* @param {number} y
|
307
|
+
* @returns {Direction | undefined}
|
308
|
+
*/
|
309
|
+
get(x: number, y: number): Direction | undefined;
|
310
|
+
/**
|
311
|
+
* Set the direction for a given coordinate.
|
312
|
+
* @param {number} x
|
313
|
+
* @param {number} y
|
314
|
+
* @param {Direction | undefined} [value]
|
315
|
+
*/
|
316
|
+
set(x: number, y: number, value?: Direction): void;
|
317
|
+
}
|
318
|
+
export class SearchGoal {
|
319
|
+
free(): void;
|
320
|
+
readonly pos: any;
|
321
|
+
readonly range: number;
|
322
|
+
}
|
323
|
+
|
324
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
325
|
+
|
326
|
+
export interface InitOutput {
|
327
|
+
readonly memory: WebAssembly.Memory;
|
328
|
+
readonly version: (a: number) => void;
|
329
|
+
readonly get_range: (a: number, b: number) => number;
|
330
|
+
readonly js_dijkstra_flow_field: (a: number, b: number, c: number) => number;
|
331
|
+
readonly js_dijkstra_mono_flow_field: (a: number, b: number, c: number) => number;
|
332
|
+
readonly js_bfs_flow_field: (a: number, b: number, c: number) => number;
|
333
|
+
readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
|
334
|
+
readonly monoflowfield_get: (a: number, b: number, c: number) => number;
|
335
|
+
readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
|
336
|
+
readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
|
337
|
+
readonly clockworkcostmatrix_new: (a: number) => number;
|
338
|
+
readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
|
339
|
+
readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
|
340
|
+
readonly __wbg_distancemap_free: (a: number, b: number) => void;
|
341
|
+
readonly distancemap_toArray: (a: number, b: number) => void;
|
342
|
+
readonly distancemap_get: (a: number, b: number, c: number) => number;
|
343
|
+
readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
|
344
|
+
readonly js_dijkstra_distance_map: (a: number, b: number, c: number) => number;
|
345
|
+
readonly __wbg_flowfield_free: (a: number, b: number) => void;
|
346
|
+
readonly flowfield_get: (a: number, b: number, c: number) => number;
|
347
|
+
readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
|
348
|
+
readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
|
349
|
+
readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
|
350
|
+
readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
|
351
|
+
readonly js_bfs_distance_map: (a: number, b: number, c: number) => number;
|
352
|
+
readonly js_bfs_mono_flow_field: (a: number, b: number, c: number) => number;
|
353
|
+
readonly __wbg_searchgoal_free: (a: number, b: number) => void;
|
354
|
+
readonly searchgoal_pos: (a: number) => number;
|
355
|
+
readonly searchgoal_range: (a: number) => number;
|
356
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
357
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
358
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
359
|
+
}
|
360
|
+
|
361
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
362
|
+
/**
|
363
|
+
* Instantiates the given `module`, which can either be bytes or
|
364
|
+
* a precompiled `WebAssembly.Module`.
|
365
|
+
*
|
366
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
367
|
+
*
|
368
|
+
* @returns {InitOutput}
|
369
|
+
*/
|
370
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
371
|
+
|
372
|
+
/**
|
373
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
374
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
375
|
+
*
|
376
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
377
|
+
*
|
378
|
+
* @returns {Promise<InitOutput>}
|
379
|
+
*/
|
380
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
@@ -1,2 +1,20 @@
|
|
1
|
-
import { ClockworkCostMatrix } from '
|
2
|
-
|
1
|
+
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
2
|
+
/**
|
3
|
+
* Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
|
4
|
+
* using a breadth-first search algorithm.
|
5
|
+
*
|
6
|
+
* The BFS algorithm doesn't include variable costs, and only considers
|
7
|
+
* values of 255 (impassible) in the provided cost matrix. Any other
|
8
|
+
* values are ignored.
|
9
|
+
*
|
10
|
+
* This might be useful for creeps with only MOVE parts and/or empty
|
11
|
+
* CARRY parts, which don't generate fatigue.
|
12
|
+
*
|
13
|
+
* Note that the `roomName` on start positions is ignored - all positions
|
14
|
+
* are assumed to be in the same room as the cost matrix.
|
15
|
+
*
|
16
|
+
* @param start - The starting positions.
|
17
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
18
|
+
* @returns The flow field.
|
19
|
+
*/
|
20
|
+
export declare function bfsDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
|
@@ -1,3 +1,36 @@
|
|
1
|
-
import { ClockworkCostMatrix } from '
|
2
|
-
|
3
|
-
|
1
|
+
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
2
|
+
/**
|
3
|
+
* Generate a [flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
|
4
|
+
* using a breadth-first search algorithm.
|
5
|
+
*
|
6
|
+
* The BFS algorithm doesn't include variable costs, and only considers
|
7
|
+
* values of 255 (impassible) in the provided cost matrix. Any other
|
8
|
+
* values are ignored.
|
9
|
+
*
|
10
|
+
* This might be useful for creeps with only MOVE parts and/or empty
|
11
|
+
* CARRY parts, which don't generate fatigue.
|
12
|
+
*
|
13
|
+
* @param start - The starting positions.
|
14
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
15
|
+
* @returns The flow field.
|
16
|
+
*/
|
17
|
+
export declare function bfsFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").FlowField;
|
18
|
+
/**
|
19
|
+
* Generate a [mono-directional flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html)
|
20
|
+
* for a set of positions using a breadth-first search algorithm.
|
21
|
+
*
|
22
|
+
* The BFS algorithm doesn't include variable costs, and only considers
|
23
|
+
* values of 255 (impassible) in the provided cost matrix. Any other
|
24
|
+
* values are ignored.
|
25
|
+
*
|
26
|
+
* This might be useful for creeps with only MOVE parts and/or empty
|
27
|
+
* CARRY parts, which don't generate fatigue.
|
28
|
+
*
|
29
|
+
* Note that the `roomName` on start positions is ignored - all positions
|
30
|
+
* are assumed to be in the same room as the cost matrix.
|
31
|
+
*
|
32
|
+
* @param start - The starting positions.
|
33
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
34
|
+
* @returns The flow field.
|
35
|
+
*/
|
36
|
+
export declare function bfsMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").MonoFlowField;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
2
|
+
/**
|
3
|
+
* Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
|
4
|
+
* using Dijkstra's algorithm.
|
5
|
+
*
|
6
|
+
* Dijkstra's algorithm includes variable costs to account for terrain or other cost functions.
|
7
|
+
*
|
8
|
+
* Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
|
9
|
+
* a cost matrix with a default value of at least 1.
|
10
|
+
*
|
11
|
+
* Note that the `roomName` on start positions is ignored - all positions
|
12
|
+
* are assumed to be in the same room as the cost matrix.
|
13
|
+
*
|
14
|
+
* @param start - The starting positions.
|
15
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
16
|
+
* @returns The flow field.
|
17
|
+
*/
|
18
|
+
export declare function dijkstraDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
2
|
+
/**
|
3
|
+
* Generate a [flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
|
4
|
+
* using Dijkstra's algorithm.
|
5
|
+
*
|
6
|
+
* Dijkstra's algorithm includes variable costs to account for terrain or other cost functions.
|
7
|
+
*
|
8
|
+
* Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
|
9
|
+
* a cost matrix with a default value of at least 1.
|
10
|
+
*
|
11
|
+
* @param start - The starting positions.
|
12
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
13
|
+
* @returns The flow field.
|
14
|
+
*/
|
15
|
+
export declare function dijkstraFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").FlowField;
|
16
|
+
/**
|
17
|
+
* Generate a [mono-directional flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html)
|
18
|
+
* for a set of positions using Dijkstra's algorithm.
|
19
|
+
*
|
20
|
+
* Dijkstra's algorithm includes variable costs to account for terrain or other cost functions.
|
21
|
+
*
|
22
|
+
* Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
|
23
|
+
* a cost matrix with a default value of at least 1.
|
24
|
+
*
|
25
|
+
* Note that the `roomName` on start positions is ignored - all positions
|
26
|
+
* are assumed to be in the same room as the cost matrix.
|
27
|
+
*
|
28
|
+
* @param start - The starting positions.
|
29
|
+
* @param costMatrix - The cost matrix to use for the flow field.
|
30
|
+
* @returns The flow field.
|
31
|
+
*/
|
32
|
+
export declare function dijkstraMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").MonoFlowField;
|
@@ -1 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Get the global range between two positions. This is different
|
3
|
+
* from the `getRange` method on `RoomPosition`, which gets the
|
4
|
+
* range only within the same room.
|
5
|
+
*
|
6
|
+
* @param pos1 - The first position.
|
7
|
+
* @param pos2 - The second position.
|
8
|
+
* @returns The range between the two positions.
|
9
|
+
*/
|
1
10
|
export declare function getRange(pos1: RoomPosition, pos2: RoomPosition): number;
|
package/package.json
CHANGED
@@ -1,62 +1,64 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
"
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"
|
60
|
-
|
61
|
-
|
2
|
+
"name": "screeps-clockwork",
|
3
|
+
"version": "0.2.1",
|
4
|
+
"description": "A WASM movement library for Screeps",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/src/index.d.ts",
|
7
|
+
"scripts": {
|
8
|
+
"build": "run-s build:lib build:src",
|
9
|
+
"build:lib": "wasm-pack build --target web --out-dir src/wasm --config build.rustflags=[\\'-Ctarget-feature=-reference-types\\',\\'-Ctarget-feature=-multivalue\\',\\'-Ctarget-feature=-sign-ext\\'] -Z build-std=std,panic_abort",
|
10
|
+
"build:src": "rollup -c",
|
11
|
+
"build:docs": "typedoc",
|
12
|
+
"watch": "run-s build watch:both",
|
13
|
+
"watch:lib": "cargo-watch -w lib -s \"npm run build:lib\"",
|
14
|
+
"watch:src": "wait-on src/wasm/screeps_clockwork_bg.wasm && rollup -cw",
|
15
|
+
"watch:pserver": "rollup -cw --environment DEST:pserver",
|
16
|
+
"watch:both": "run-p watch:lib watch:pserver"
|
17
|
+
},
|
18
|
+
"repository": {
|
19
|
+
"type": "git",
|
20
|
+
"url": "git+https://github.com/glitchassassin/screeps-clockwork.git"
|
21
|
+
},
|
22
|
+
"keywords": [
|
23
|
+
"typescript",
|
24
|
+
"screeps",
|
25
|
+
"wasm",
|
26
|
+
"pathfinding"
|
27
|
+
],
|
28
|
+
"author": "Jon Winsley <jon.winsley@gmail.com>",
|
29
|
+
"license": "SEE LICENSE IN LICENSE",
|
30
|
+
"bugs": {
|
31
|
+
"url": "https://github.com/glitchassassin/screeps-clockwork/issues"
|
32
|
+
},
|
33
|
+
"homepage": "https://github.com/glitchassassin/screeps-clockwork#readme",
|
34
|
+
"devDependencies": {
|
35
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
36
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
37
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
38
|
+
"@rollup/plugin-wasm": "^6.2.2",
|
39
|
+
"@types/node": "^22.9.3",
|
40
|
+
"@types/screeps": "^3.3.0",
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
42
|
+
"@typescript-eslint/parser": "^8.15.0",
|
43
|
+
"eslint": "^9.15.0",
|
44
|
+
"npm-run-all": "^4.1.5",
|
45
|
+
"prettier": "^3.3.3",
|
46
|
+
"rollup": "2.79.2",
|
47
|
+
"rollup-plugin-clear": "^2.0.7",
|
48
|
+
"rollup-plugin-copy": "^3.5.0",
|
49
|
+
"rollup-plugin-screeps": "^1.0.1",
|
50
|
+
"source-map": "0.6.1",
|
51
|
+
"typedoc": "^0.27.0-beta.2",
|
52
|
+
"typescript": "^5.7.2"
|
53
|
+
},
|
54
|
+
"dependencies": {
|
55
|
+
"fastestsmallesttextencoderdecoder-encodeinto": "^1.0.22"
|
56
|
+
},
|
57
|
+
"type": "module",
|
58
|
+
"files": [
|
59
|
+
"dist/**/*"
|
60
|
+
],
|
61
|
+
"publishConfig": {
|
62
|
+
"access": "public"
|
63
|
+
}
|
62
64
|
}
|