screeps-clockwork 0.6.0 → 0.7.2
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 +1 -0
- package/dist/index.js +425 -313
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/wasm/screeps_clockwork.d.ts +123 -103
- package/dist/src/wrappers/astarDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/bfsDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/dijkstraDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/searchResult.d.ts +7 -0
- package/package.json +4 -4
- package/dist/src/wrappers/distanceMap.d.ts +0 -24
|
Binary file
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export function version(): string;
|
|
4
|
+
/**
|
|
5
|
+
* Exports the global range calculation between two positions.
|
|
6
|
+
*/
|
|
7
|
+
export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
|
6
8
|
/**
|
|
7
9
|
* WASM wrapper for the BFS multiroom distance map function.
|
|
8
10
|
*
|
|
@@ -19,23 +21,21 @@ export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, ge
|
|
|
19
21
|
* # Returns
|
|
20
22
|
* A `MultiroomDistanceMap` containing the distances from the start positions
|
|
21
23
|
*/
|
|
22
|
-
export function js_bfs_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array, all_of_destinations?: Uint32Array):
|
|
23
|
-
export function
|
|
24
|
-
export function
|
|
25
|
-
export function version(): string;
|
|
26
|
-
/**
|
|
27
|
-
* Exports the global range calculation between two positions.
|
|
28
|
-
*/
|
|
29
|
-
export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
|
24
|
+
export function js_bfs_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
|
|
25
|
+
export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
|
|
26
|
+
export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
|
|
30
27
|
/**
|
|
31
28
|
* Creates a monodirectional flow field for the given distance map.
|
|
32
29
|
*/
|
|
33
30
|
export function multiroomMonoFlowField(distance_map: MultiroomDistanceMap): MultiroomMonoFlowField;
|
|
34
|
-
export function
|
|
31
|
+
export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
|
|
35
32
|
/**
|
|
36
33
|
* Creates a flow field for the given distance map.
|
|
37
34
|
*/
|
|
38
35
|
export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
|
|
36
|
+
export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
|
|
37
|
+
export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
|
|
38
|
+
export function js_astar_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_rooms: number, max_ops: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
|
|
39
39
|
/**
|
|
40
40
|
* Translates `COLOR_*` and `COLORS_ALL` constants.
|
|
41
41
|
*/
|
|
@@ -189,7 +189,7 @@ export class ClockworkCostMatrix {
|
|
|
189
189
|
* Creates a new cost matrix within the WASM module. Optionally, a default value
|
|
190
190
|
* can be provided to initialize all cells in the matrix to that value.
|
|
191
191
|
*/
|
|
192
|
-
constructor(_default?: number);
|
|
192
|
+
constructor(_default?: number | null);
|
|
193
193
|
/**
|
|
194
194
|
* Gets the cost of a given position in the cost matrix.
|
|
195
195
|
*/
|
|
@@ -205,10 +205,6 @@ export class ClockworkCostMatrix {
|
|
|
205
205
|
export class DistanceMap {
|
|
206
206
|
private constructor();
|
|
207
207
|
free(): void;
|
|
208
|
-
/**
|
|
209
|
-
* Converts the distance map into a flat array of distances.
|
|
210
|
-
*/
|
|
211
|
-
toArray(): Uint32Array;
|
|
212
208
|
/**
|
|
213
209
|
* Gets the distance value at a given position.
|
|
214
210
|
*/
|
|
@@ -217,6 +213,10 @@ export class DistanceMap {
|
|
|
217
213
|
* Sets the distance value at a given position.
|
|
218
214
|
*/
|
|
219
215
|
set(x: number, y: number, value: number): void;
|
|
216
|
+
/**
|
|
217
|
+
* Converts the distance map into a flat array of distances.
|
|
218
|
+
*/
|
|
219
|
+
toArray(): Uint32Array;
|
|
220
220
|
}
|
|
221
221
|
/**
|
|
222
222
|
* A flow field is a 50x50 grid (representing a room), representing viable directions
|
|
@@ -228,13 +228,9 @@ export class FlowField {
|
|
|
228
228
|
private constructor();
|
|
229
229
|
free(): void;
|
|
230
230
|
/**
|
|
231
|
-
*
|
|
232
|
-
*/
|
|
233
|
-
get(x: number, y: number): number;
|
|
234
|
-
/**
|
|
235
|
-
* Set the internal value for a given coordinate.
|
|
231
|
+
* Add a direction to the list of valid directions for a given coordinate.
|
|
236
232
|
*/
|
|
237
|
-
|
|
233
|
+
addDirection(x: number, y: number, direction: Direction): void;
|
|
238
234
|
/**
|
|
239
235
|
* Get the list of valid directions for a given coordinate.
|
|
240
236
|
*/
|
|
@@ -244,9 +240,13 @@ export class FlowField {
|
|
|
244
240
|
*/
|
|
245
241
|
setDirections(x: number, y: number, directions: any[]): void;
|
|
246
242
|
/**
|
|
247
|
-
*
|
|
243
|
+
* Get the internal value for a given coordinate.
|
|
248
244
|
*/
|
|
249
|
-
|
|
245
|
+
get(x: number, y: number): number;
|
|
246
|
+
/**
|
|
247
|
+
* Set the internal value for a given coordinate.
|
|
248
|
+
*/
|
|
249
|
+
set(x: number, y: number, value: number): void;
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* A flow field is a 50x50 grid (representing a room), representing viable directions
|
|
@@ -264,7 +264,7 @@ export class MonoFlowField {
|
|
|
264
264
|
/**
|
|
265
265
|
* Set the direction for a given coordinate.
|
|
266
266
|
*/
|
|
267
|
-
set(x: number, y: number, value?: Direction): void;
|
|
267
|
+
set(x: number, y: number, value?: Direction | null): void;
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
270
270
|
* Maps distance values across multiple rooms, storing a DistanceMap for each room
|
|
@@ -272,25 +272,25 @@ export class MonoFlowField {
|
|
|
272
272
|
export class MultiroomDistanceMap {
|
|
273
273
|
free(): void;
|
|
274
274
|
/**
|
|
275
|
-
*
|
|
275
|
+
* Gets the DistanceMap for a given room
|
|
276
276
|
*/
|
|
277
|
-
|
|
277
|
+
get_room(room_name: number): DistanceMap | undefined;
|
|
278
278
|
/**
|
|
279
|
-
* Gets the
|
|
279
|
+
* Gets the list of rooms in the map
|
|
280
280
|
*/
|
|
281
|
-
|
|
281
|
+
get_rooms(): Uint16Array;
|
|
282
282
|
/**
|
|
283
|
-
*
|
|
283
|
+
* Gets the distance value at a given position
|
|
284
284
|
*/
|
|
285
|
-
|
|
285
|
+
get(packed_pos: number): number;
|
|
286
286
|
/**
|
|
287
|
-
*
|
|
287
|
+
* Creates a new empty multiroom distance map (JavaScript constructor)
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
constructor();
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
291
|
+
* Sets the distance value at a given position
|
|
292
292
|
*/
|
|
293
|
-
|
|
293
|
+
set(packed_pos: number, value: number): void;
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Maps flow field values across multiple rooms, storing a FlowField for each room
|
|
@@ -298,25 +298,17 @@ export class MultiroomDistanceMap {
|
|
|
298
298
|
export class MultiroomFlowField {
|
|
299
299
|
free(): void;
|
|
300
300
|
/**
|
|
301
|
-
*
|
|
302
|
-
*/
|
|
303
|
-
constructor();
|
|
304
|
-
/**
|
|
305
|
-
* Gets the flow field value at a given position
|
|
306
|
-
*/
|
|
307
|
-
get(packed_pos: number): number;
|
|
308
|
-
/**
|
|
309
|
-
* Sets the flow field value at a given position
|
|
301
|
+
* Gets the FlowField for a given room
|
|
310
302
|
*/
|
|
311
|
-
|
|
303
|
+
getRoom(room_name: number): FlowField | undefined;
|
|
312
304
|
/**
|
|
313
305
|
* Gets the list of rooms in the flow field
|
|
314
306
|
*/
|
|
315
307
|
getRooms(): Uint16Array;
|
|
316
308
|
/**
|
|
317
|
-
*
|
|
309
|
+
* Adds a direction to the list of valid directions at a given position (JavaScript)
|
|
318
310
|
*/
|
|
319
|
-
|
|
311
|
+
addDirection(packed_pos: number, direction: Direction): void;
|
|
320
312
|
/**
|
|
321
313
|
* Gets the list of valid directions at a given position (JavaScript)
|
|
322
314
|
*/
|
|
@@ -326,9 +318,17 @@ export class MultiroomFlowField {
|
|
|
326
318
|
*/
|
|
327
319
|
setDirections(packed_pos: number, directions: any[]): void;
|
|
328
320
|
/**
|
|
329
|
-
*
|
|
321
|
+
* Gets the flow field value at a given position
|
|
330
322
|
*/
|
|
331
|
-
|
|
323
|
+
get(packed_pos: number): number;
|
|
324
|
+
/**
|
|
325
|
+
* Creates a new empty multiroom flow field (JavaScript constructor)
|
|
326
|
+
*/
|
|
327
|
+
constructor();
|
|
328
|
+
/**
|
|
329
|
+
* Sets the flow field value at a given position
|
|
330
|
+
*/
|
|
331
|
+
set(packed_pos: number, value: number): void;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
334
|
* Maps monodirectional flow field values across multiple rooms, storing a MonoFlowField for each room
|
|
@@ -336,25 +336,25 @@ export class MultiroomFlowField {
|
|
|
336
336
|
export class MultiroomMonoFlowField {
|
|
337
337
|
free(): void;
|
|
338
338
|
/**
|
|
339
|
-
*
|
|
339
|
+
* Gets the MonoFlowField for a given room
|
|
340
340
|
*/
|
|
341
|
-
|
|
341
|
+
getRoom(room_name: number): MonoFlowField | undefined;
|
|
342
342
|
/**
|
|
343
|
-
* Gets the
|
|
343
|
+
* Gets the list of rooms in the flow field
|
|
344
344
|
*/
|
|
345
|
-
|
|
345
|
+
getRooms(): Uint16Array;
|
|
346
346
|
/**
|
|
347
|
-
*
|
|
347
|
+
* Gets the direction at a given position
|
|
348
348
|
*/
|
|
349
|
-
|
|
349
|
+
get(packed_pos: number): Direction | undefined;
|
|
350
350
|
/**
|
|
351
|
-
*
|
|
351
|
+
* Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
|
|
352
352
|
*/
|
|
353
|
-
|
|
353
|
+
constructor();
|
|
354
354
|
/**
|
|
355
|
-
*
|
|
355
|
+
* Sets the direction at a given position
|
|
356
356
|
*/
|
|
357
|
-
|
|
357
|
+
set(packed_pos: number, direction?: Direction | null): void;
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* A list of positions representing a path.
|
|
@@ -362,9 +362,7 @@ export class MultiroomMonoFlowField {
|
|
|
362
362
|
export class Path {
|
|
363
363
|
private constructor();
|
|
364
364
|
free(): void;
|
|
365
|
-
|
|
366
|
-
get(index: number): number | undefined;
|
|
367
|
-
len(): number;
|
|
365
|
+
to_array(): Uint32Array;
|
|
368
366
|
/**
|
|
369
367
|
* Given a position, find the index of the next adjacent position
|
|
370
368
|
* in the path. If the position is not in the path, the target is
|
|
@@ -372,8 +370,10 @@ export class Path {
|
|
|
372
370
|
* the position is neither on nor adjacent to the path, return None.
|
|
373
371
|
*/
|
|
374
372
|
find_next_index(packed_position: number): number | undefined;
|
|
375
|
-
to_array(): Uint32Array;
|
|
376
373
|
to_array_reversed(): Uint32Array;
|
|
374
|
+
add(packed_position: number): void;
|
|
375
|
+
get(index: number): number | undefined;
|
|
376
|
+
len(): number;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Tracks fatigue cost for each position in a path. Used to calculate move time
|
|
@@ -381,6 +381,7 @@ export class Path {
|
|
|
381
381
|
*/
|
|
382
382
|
export class PathFatigue {
|
|
383
383
|
free(): void;
|
|
384
|
+
len(): number;
|
|
384
385
|
constructor(path: Path);
|
|
385
386
|
/**
|
|
386
387
|
* Refreshes fatigue cost for each position in the path. If the PathFatigue
|
|
@@ -391,7 +392,6 @@ export class PathFatigue {
|
|
|
391
392
|
* When there is vision, this also accounts for roads at the position.
|
|
392
393
|
*/
|
|
393
394
|
refresh(path: Path): void;
|
|
394
|
-
len(): number;
|
|
395
395
|
/**
|
|
396
396
|
* Calculates the total move time for the path, given a fatigue ratio.
|
|
397
397
|
*
|
|
@@ -406,72 +406,92 @@ export class SearchGoal {
|
|
|
406
406
|
readonly pos: any;
|
|
407
407
|
readonly range: number;
|
|
408
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* A distance map search returns both the distance map (filled out
|
|
411
|
+
* with all tiles explored) and the targets found. These aren't necessarily
|
|
412
|
+
* the same positions specified as targets - if the target range is 5, then
|
|
413
|
+
* this is the first position in range 5 of the target. If multiple targets
|
|
414
|
+
* are specified, and you care about matching the found target with one of
|
|
415
|
+
* the original targets, you can iterate through your list and figure out the
|
|
416
|
+
* ones that are in range of the found target(s).
|
|
417
|
+
*/
|
|
418
|
+
export class SearchResult {
|
|
419
|
+
private constructor();
|
|
420
|
+
free(): void;
|
|
421
|
+
readonly distance_map: MultiroomDistanceMap;
|
|
422
|
+
readonly found_targets: Uint32Array;
|
|
423
|
+
readonly ops: number;
|
|
424
|
+
}
|
|
409
425
|
|
|
410
426
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
411
427
|
|
|
412
428
|
export interface InitOutput {
|
|
413
429
|
readonly memory: WebAssembly.Memory;
|
|
414
|
-
readonly
|
|
415
|
-
readonly
|
|
416
|
-
readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
|
|
417
|
-
readonly multiroommonoflowfield_js_new: () => number;
|
|
418
|
-
readonly multiroommonoflowfield_get: (a: number, b: number) => number;
|
|
419
|
-
readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
|
|
420
|
-
readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
|
|
421
|
-
readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
|
|
422
|
-
readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
|
|
423
|
-
readonly monoflowfield_get: (a: number, b: number, c: number) => number;
|
|
424
|
-
readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
|
|
425
|
-
readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
|
|
426
|
-
readonly clockworkcostmatrix_new: (a: number) => number;
|
|
427
|
-
readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
|
|
428
|
-
readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
|
|
430
|
+
readonly get_range: (a: number, b: number) => number;
|
|
431
|
+
readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
429
432
|
readonly js_dijkstra_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
433
|
+
readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
|
|
434
|
+
readonly version: (a: number) => void;
|
|
430
435
|
readonly __wbg_distancemap_free: (a: number, b: number) => void;
|
|
431
|
-
readonly
|
|
436
|
+
readonly __wbg_flowfield_free: (a: number, b: number) => void;
|
|
432
437
|
readonly distancemap_get: (a: number, b: number, c: number) => number;
|
|
433
438
|
readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
|
|
434
|
-
readonly
|
|
439
|
+
readonly distancemap_toArray: (a: number, b: number) => void;
|
|
440
|
+
readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
|
|
435
441
|
readonly flowfield_get: (a: number, b: number, c: number) => number;
|
|
436
|
-
readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
|
|
437
442
|
readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
|
|
443
|
+
readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
|
|
438
444
|
readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
439
|
-
readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
|
|
440
|
-
readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
441
|
-
readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
|
|
442
|
-
readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
|
|
443
|
-
readonly version: (a: number) => void;
|
|
444
|
-
readonly get_range: (a: number, b: number) => number;
|
|
445
445
|
readonly multiroomMonoFlowField: (a: number) => number;
|
|
446
|
-
readonly
|
|
446
|
+
readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
|
|
447
|
+
readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
|
|
448
|
+
readonly clockworkcostmatrix_new: (a: number) => number;
|
|
449
|
+
readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
|
|
450
|
+
readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
|
|
451
|
+
readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
|
|
452
|
+
readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
|
|
453
|
+
readonly monoflowfield_get: (a: number, b: number, c: number) => number;
|
|
454
|
+
readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
|
|
455
|
+
readonly multiroomFlowField: (a: number) => number;
|
|
456
|
+
readonly multiroommonoflowfield_get: (a: number, b: number) => number;
|
|
457
|
+
readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
|
|
458
|
+
readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
|
|
459
|
+
readonly multiroommonoflowfield_js_new: () => number;
|
|
460
|
+
readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
|
|
447
461
|
readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
|
|
448
|
-
readonly
|
|
462
|
+
readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
|
|
463
|
+
readonly __wbg_searchresult_free: (a: number, b: number) => void;
|
|
464
|
+
readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
|
|
465
|
+
readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
|
|
449
466
|
readonly multiroomdistancemap_get: (a: number, b: number) => number;
|
|
450
|
-
readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
|
|
451
|
-
readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
|
|
452
467
|
readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
|
|
453
|
-
readonly
|
|
454
|
-
readonly
|
|
468
|
+
readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
|
|
469
|
+
readonly multiroomdistancemap_js_new: () => number;
|
|
470
|
+
readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
|
|
471
|
+
readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
|
|
455
472
|
readonly multiroomflowfield_get: (a: number, b: number) => number;
|
|
456
|
-
readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
|
|
457
|
-
readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
|
|
458
|
-
readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
|
|
459
473
|
readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
|
|
474
|
+
readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
|
|
475
|
+
readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
|
|
476
|
+
readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
|
|
460
477
|
readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
|
|
461
|
-
readonly
|
|
462
|
-
readonly
|
|
478
|
+
readonly searchresult_distance_map: (a: number) => number;
|
|
479
|
+
readonly searchresult_found_targets: (a: number, b: number) => void;
|
|
480
|
+
readonly searchresult_ops: (a: number) => number;
|
|
481
|
+
readonly multiroomflowfield_js_new: () => number;
|
|
482
|
+
readonly js_astar_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
463
483
|
readonly __wbg_path_free: (a: number, b: number) => void;
|
|
464
484
|
readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
|
|
465
485
|
readonly path_add: (a: number, b: number) => void;
|
|
486
|
+
readonly path_find_next_index: (a: number, b: number) => number;
|
|
466
487
|
readonly path_get: (a: number, b: number) => number;
|
|
467
488
|
readonly path_len: (a: number) => number;
|
|
468
|
-
readonly path_find_next_index: (a: number, b: number) => number;
|
|
469
489
|
readonly path_to_array: (a: number, b: number) => void;
|
|
470
490
|
readonly path_to_array_reversed: (a: number, b: number) => void;
|
|
471
|
-
readonly pathfatigue_new: (a: number) => number;
|
|
472
|
-
readonly pathfatigue_refresh: (a: number, b: number) => void;
|
|
473
491
|
readonly pathfatigue_len: (a: number) => number;
|
|
474
492
|
readonly pathfatigue_moveTime: (a: number, b: number) => number;
|
|
493
|
+
readonly pathfatigue_new: (a: number) => number;
|
|
494
|
+
readonly pathfatigue_refresh: (a: number, b: number) => void;
|
|
475
495
|
readonly __wbg_searchgoal_free: (a: number, b: number) => void;
|
|
476
496
|
readonly searchgoal_pos: (a: number) => number;
|
|
477
497
|
readonly searchgoal_range: (a: number) => number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
|
2
|
-
import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
|
|
3
2
|
/**
|
|
4
3
|
* Create a distance map for the given start positions, using a breadth-first search.
|
|
5
4
|
* This does not factor in terrain costs (treating anything less than 255 in the cost
|
|
@@ -21,6 +20,16 @@ export declare function astarMultiroomDistanceMap(start: RoomPosition[], { costM
|
|
|
21
20
|
maxRooms?: number;
|
|
22
21
|
maxOps?: number;
|
|
23
22
|
maxPathCost?: number;
|
|
24
|
-
anyOfDestinations?:
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
anyOfDestinations?: {
|
|
24
|
+
pos: RoomPosition;
|
|
25
|
+
range: number;
|
|
26
|
+
}[];
|
|
27
|
+
allOfDestinations?: {
|
|
28
|
+
pos: RoomPosition;
|
|
29
|
+
range: number;
|
|
30
|
+
}[];
|
|
31
|
+
}): {
|
|
32
|
+
distanceMap: import("./multiroomDistanceMap").ClockworkMultiroomDistanceMap;
|
|
33
|
+
foundTargets: RoomPosition[];
|
|
34
|
+
ops: number;
|
|
35
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
|
2
|
-
import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
|
|
3
2
|
/**
|
|
4
3
|
* Create a distance map for the given start positions, using a breadth-first search.
|
|
5
4
|
* This does not factor in terrain costs (treating anything less than 255 in the cost
|
|
@@ -21,6 +20,16 @@ export declare function bfsMultiroomDistanceMap(start: RoomPosition[], { costMat
|
|
|
21
20
|
maxOps?: number;
|
|
22
21
|
maxRooms?: number;
|
|
23
22
|
maxPathCost?: number;
|
|
24
|
-
anyOfDestinations?:
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
anyOfDestinations?: {
|
|
24
|
+
pos: RoomPosition;
|
|
25
|
+
range: number;
|
|
26
|
+
}[];
|
|
27
|
+
allOfDestinations?: {
|
|
28
|
+
pos: RoomPosition;
|
|
29
|
+
range: number;
|
|
30
|
+
}[];
|
|
31
|
+
}): {
|
|
32
|
+
distanceMap: import("./multiroomDistanceMap").ClockworkMultiroomDistanceMap;
|
|
33
|
+
foundTargets: RoomPosition[];
|
|
34
|
+
ops: number;
|
|
35
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
|
|
2
|
-
import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
|
|
3
2
|
/**
|
|
4
3
|
* Create a distance map for the given start positions, using Dijkstra's algorithm to
|
|
5
4
|
* factor in terrain costs (0-255, where 255 is impassable).
|
|
@@ -20,6 +19,16 @@ export declare function dijkstraMultiroomDistanceMap(start: RoomPosition[], { co
|
|
|
20
19
|
maxOps?: number;
|
|
21
20
|
maxRooms?: number;
|
|
22
21
|
maxPathCost?: number;
|
|
23
|
-
anyOfDestinations?:
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
anyOfDestinations?: {
|
|
23
|
+
pos: RoomPosition;
|
|
24
|
+
range: number;
|
|
25
|
+
}[];
|
|
26
|
+
allOfDestinations?: {
|
|
27
|
+
pos: RoomPosition;
|
|
28
|
+
range: number;
|
|
29
|
+
}[];
|
|
30
|
+
}): {
|
|
31
|
+
distanceMap: import("./multiroomDistanceMap").ClockworkMultiroomDistanceMap;
|
|
32
|
+
foundTargets: RoomPosition[];
|
|
33
|
+
ops: number;
|
|
34
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SearchResult } from '../wasm/screeps_clockwork';
|
|
2
|
+
import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
|
|
3
|
+
export declare function fromPackedSearchResult(result: SearchResult): {
|
|
4
|
+
distanceMap: ClockworkMultiroomDistanceMap;
|
|
5
|
+
foundTargets: RoomPosition[];
|
|
6
|
+
ops: number;
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screeps-clockwork",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "A WASM movement library for Screeps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
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
10
|
"build:src": "rollup -c",
|
|
11
11
|
"build:docs": "typedoc",
|
|
12
|
-
"build:pserver": "run-s build:
|
|
12
|
+
"build:pserver": "run-s build:lib build:src && rollup -c --environment DEST:pserver",
|
|
13
13
|
"watch": "run-s build watch:both",
|
|
14
14
|
"watch:lib": "cargo-watch -w lib -s \"npm run build:lib\"",
|
|
15
15
|
"watch:src": "wait-on src/wasm/screeps_clockwork_bg.wasm && rollup -cw",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
38
38
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
39
39
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
40
|
-
"@types/node": "^
|
|
40
|
+
"@types/node": "^24.0.3",
|
|
41
41
|
"@types/screeps": "^3.3.0",
|
|
42
42
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
43
43
|
"@typescript-eslint/parser": "^8.17.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"rollup-plugin-screeps": "^1.0.1",
|
|
51
51
|
"source-map": "0.6.1",
|
|
52
52
|
"tslib": "^2.8.1",
|
|
53
|
-
"typedoc": "^0.
|
|
53
|
+
"typedoc": "^0.28.5",
|
|
54
54
|
"typescript": "^5.7.2"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DistanceMap } from '../wasm/screeps_clockwork';
|
|
2
|
-
/**
|
|
3
|
-
* A distance map for a single room.
|
|
4
|
-
*/
|
|
5
|
-
export declare class ClockworkDistanceMap {
|
|
6
|
-
private _map;
|
|
7
|
-
constructor(_map: DistanceMap);
|
|
8
|
-
/**
|
|
9
|
-
* Gets the distance value at a given position.
|
|
10
|
-
*/
|
|
11
|
-
get(x: number, y: number): number;
|
|
12
|
-
/**
|
|
13
|
-
* Sets the distance value at a given position.
|
|
14
|
-
*/
|
|
15
|
-
set(x: number, y: number, value: number): void;
|
|
16
|
-
/**
|
|
17
|
-
* Converts the distance map into a flat array of distances.
|
|
18
|
-
*/
|
|
19
|
-
toArray(): Uint32Array;
|
|
20
|
-
/**
|
|
21
|
-
* Frees the memory allocated for this distance map.
|
|
22
|
-
*/
|
|
23
|
-
free(): void;
|
|
24
|
-
}
|