screeps-clockwork 0.2.1 → 0.4.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/README.md +11 -1
- package/dist/index.js +386 -93
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/utils/fromPacked.d.ts +1 -0
- package/dist/src/wasm/screeps_clockwork.d.ts +140 -36
- package/dist/src/wrappers/path.d.ts +26 -0
- package/dist/src/wrappers/pathtoDistanceMapOrigin.d.ts +3 -0
- package/dist/src/wrappers/pathtoFlowFieldOrigin.d.ts +3 -0
- package/dist/src/wrappers/pathtoMonoFlowFieldOrigin.d.ts +3 -0
- package/package.json +1 -1
@@ -1,16 +1,5 @@
|
|
1
1
|
/* tslint:disable */
|
2
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
3
|
/**
|
15
4
|
* WASM wrapper for the Dijkstra flow field function.
|
16
5
|
* @param {Uint32Array} start_packed
|
@@ -19,26 +8,42 @@ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
|
19
8
|
*/
|
20
9
|
export function js_dijkstra_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
|
21
10
|
/**
|
22
|
-
*
|
23
|
-
* @param {
|
24
|
-
* @
|
25
|
-
* @returns {MonoFlowField}
|
11
|
+
* @param {number} start
|
12
|
+
* @param {MonoFlowField} flow_field
|
13
|
+
* @returns {Path}
|
26
14
|
*/
|
27
|
-
export function
|
15
|
+
export function js_path_to_mono_flow_field_origin(start: number, flow_field: MonoFlowField): Path;
|
28
16
|
/**
|
29
|
-
* WASM wrapper for the
|
17
|
+
* WASM wrapper for the Dijkstra distance map function.
|
30
18
|
* @param {Uint32Array} start_packed
|
31
19
|
* @param {ClockworkCostMatrix} cost_matrix
|
32
|
-
* @returns {
|
20
|
+
* @returns {DistanceMap}
|
33
21
|
*/
|
34
|
-
export function
|
22
|
+
export function js_dijkstra_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
|
35
23
|
/**
|
36
|
-
* WASM wrapper for the
|
24
|
+
* WASM wrapper for the BFS mono flow field function.
|
37
25
|
* @param {Uint32Array} start_packed
|
38
26
|
* @param {ClockworkCostMatrix} cost_matrix
|
39
|
-
* @returns {
|
27
|
+
* @returns {MonoFlowField}
|
40
28
|
*/
|
41
|
-
export function
|
29
|
+
export function js_bfs_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
|
30
|
+
/**
|
31
|
+
* @param {number} start
|
32
|
+
* @param {DistanceMap} distance_map
|
33
|
+
* @returns {Path}
|
34
|
+
*/
|
35
|
+
export function js_path_to_distance_map_origin(start: number, distance_map: DistanceMap): Path;
|
36
|
+
/**
|
37
|
+
* @returns {string}
|
38
|
+
*/
|
39
|
+
export function version(): string;
|
40
|
+
/**
|
41
|
+
* Exports the global range calculation between two positions.
|
42
|
+
* @param {number} packed_pos_1
|
43
|
+
* @param {number} packed_pos_2
|
44
|
+
* @returns {number}
|
45
|
+
*/
|
46
|
+
export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
42
47
|
/**
|
43
48
|
* WASM wrapper for the BFS distance map function.
|
44
49
|
* @param {Uint32Array} start_packed
|
@@ -47,12 +52,25 @@ export function js_dijkstra_distance_map(start_packed: Uint32Array, cost_matrix:
|
|
47
52
|
*/
|
48
53
|
export function js_bfs_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
|
49
54
|
/**
|
50
|
-
* WASM wrapper for the BFS
|
55
|
+
* WASM wrapper for the BFS flow field function.
|
56
|
+
* @param {Uint32Array} start_packed
|
57
|
+
* @param {ClockworkCostMatrix} cost_matrix
|
58
|
+
* @returns {FlowField}
|
59
|
+
*/
|
60
|
+
export function js_bfs_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
|
61
|
+
/**
|
62
|
+
* WASM wrapper for the Dijkstra mono flow field function.
|
51
63
|
* @param {Uint32Array} start_packed
|
52
64
|
* @param {ClockworkCostMatrix} cost_matrix
|
53
65
|
* @returns {MonoFlowField}
|
54
66
|
*/
|
55
|
-
export function
|
67
|
+
export function js_dijkstra_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
|
68
|
+
/**
|
69
|
+
* @param {number} start
|
70
|
+
* @param {FlowField} flow_field
|
71
|
+
* @returns {Path}
|
72
|
+
*/
|
73
|
+
export function js_path_to_flow_field_origin(start: number, flow_field: FlowField): Path;
|
56
74
|
/**
|
57
75
|
* Translates `COLOR_*` and `COLORS_ALL` constants.
|
58
76
|
*/
|
@@ -315,6 +333,76 @@ export class MonoFlowField {
|
|
315
333
|
*/
|
316
334
|
set(x: number, y: number, value?: Direction): void;
|
317
335
|
}
|
336
|
+
/**
|
337
|
+
* A list of positions representing a path.
|
338
|
+
*/
|
339
|
+
export class Path {
|
340
|
+
free(): void;
|
341
|
+
/**
|
342
|
+
* @param {number} packed_position
|
343
|
+
*/
|
344
|
+
add(packed_position: number): void;
|
345
|
+
/**
|
346
|
+
* @param {number} index
|
347
|
+
* @returns {number | undefined}
|
348
|
+
*/
|
349
|
+
get(index: number): number | undefined;
|
350
|
+
/**
|
351
|
+
* @returns {number}
|
352
|
+
*/
|
353
|
+
len(): number;
|
354
|
+
/**
|
355
|
+
* Given a position, find the index of the next adjacent position
|
356
|
+
* in the path. If the position is not in the path, the target is
|
357
|
+
* the next adjacent position closest to the end of the path. If
|
358
|
+
* the position is neither on nor adjacent to the path, return None.
|
359
|
+
* @param {number} packed_position
|
360
|
+
* @returns {number | undefined}
|
361
|
+
*/
|
362
|
+
find_next_index(packed_position: number): number | undefined;
|
363
|
+
/**
|
364
|
+
* @returns {Uint32Array}
|
365
|
+
*/
|
366
|
+
to_array(): Uint32Array;
|
367
|
+
/**
|
368
|
+
* @returns {Uint32Array}
|
369
|
+
*/
|
370
|
+
to_array_reversed(): Uint32Array;
|
371
|
+
}
|
372
|
+
/**
|
373
|
+
* Tracks fatigue cost for each position in a path. Used to calculate move time
|
374
|
+
* for a given creep build.
|
375
|
+
*/
|
376
|
+
export class PathFatigue {
|
377
|
+
free(): void;
|
378
|
+
/**
|
379
|
+
* @param {Path} path
|
380
|
+
*/
|
381
|
+
constructor(path: Path);
|
382
|
+
/**
|
383
|
+
* Refreshes fatigue cost for each position in the path. If the PathFatigue
|
384
|
+
* has not been initialized yet, every position's fatigue cost will be set,
|
385
|
+
* even if there is no vision in the room, based on terrain costs. If the
|
386
|
+
* list *has* been initialized, only positions with vision will be updated.
|
387
|
+
*
|
388
|
+
* When there is vision, this also accounts for roads at the position.
|
389
|
+
* @param {Path} path
|
390
|
+
*/
|
391
|
+
refresh(path: Path): void;
|
392
|
+
/**
|
393
|
+
* @returns {number}
|
394
|
+
*/
|
395
|
+
len(): number;
|
396
|
+
/**
|
397
|
+
* Calculates the total move time for the path, given a fatigue ratio.
|
398
|
+
*
|
399
|
+
* For unboosted creeps, the ratio is `Math.floor(moveParts * 2 / fatigueParts)`
|
400
|
+
* where `fatigue_parts` are any part except MOVE and empty CARRY parts.
|
401
|
+
* @param {number} fatigue_ratio
|
402
|
+
* @returns {number}
|
403
|
+
*/
|
404
|
+
moveTime(fatigue_ratio: number): number;
|
405
|
+
}
|
318
406
|
export class SearchGoal {
|
319
407
|
free(): void;
|
320
408
|
readonly pos: any;
|
@@ -325,11 +413,26 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
325
413
|
|
326
414
|
export interface InitOutput {
|
327
415
|
readonly memory: WebAssembly.Memory;
|
328
|
-
readonly
|
329
|
-
readonly
|
416
|
+
readonly __wbg_path_free: (a: number, b: number) => void;
|
417
|
+
readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
|
418
|
+
readonly path_add: (a: number, b: number) => void;
|
419
|
+
readonly path_get: (a: number, b: number, c: number) => void;
|
420
|
+
readonly path_len: (a: number) => number;
|
421
|
+
readonly path_find_next_index: (a: number, b: number, c: number) => void;
|
422
|
+
readonly path_to_array: (a: number, b: number) => void;
|
423
|
+
readonly path_to_array_reversed: (a: number, b: number) => void;
|
424
|
+
readonly pathfatigue_new: (a: number) => number;
|
425
|
+
readonly pathfatigue_refresh: (a: number, b: number) => void;
|
426
|
+
readonly pathfatigue_moveTime: (a: number, b: number) => number;
|
427
|
+
readonly pathfatigue_len: (a: number) => number;
|
330
428
|
readonly js_dijkstra_flow_field: (a: number, b: number, c: number) => number;
|
331
|
-
readonly
|
332
|
-
readonly
|
429
|
+
readonly __wbg_flowfield_free: (a: number, b: number) => void;
|
430
|
+
readonly flowfield_get: (a: number, b: number, c: number) => number;
|
431
|
+
readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
|
432
|
+
readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
|
433
|
+
readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
|
434
|
+
readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
|
435
|
+
readonly js_path_to_mono_flow_field_origin: (a: number, b: number) => number;
|
333
436
|
readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
|
334
437
|
readonly monoflowfield_get: (a: number, b: number, c: number) => number;
|
335
438
|
readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
|
@@ -337,25 +440,26 @@ export interface InitOutput {
|
|
337
440
|
readonly clockworkcostmatrix_new: (a: number) => number;
|
338
441
|
readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
|
339
442
|
readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
|
443
|
+
readonly js_dijkstra_distance_map: (a: number, b: number, c: number) => number;
|
444
|
+
readonly js_bfs_mono_flow_field: (a: number, b: number, c: number) => number;
|
445
|
+
readonly js_path_to_distance_map_origin: (a: number, b: number) => number;
|
340
446
|
readonly __wbg_distancemap_free: (a: number, b: number) => void;
|
341
447
|
readonly distancemap_toArray: (a: number, b: number) => void;
|
342
448
|
readonly distancemap_get: (a: number, b: number, c: number) => number;
|
343
449
|
readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
|
344
|
-
readonly
|
345
|
-
readonly
|
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;
|
450
|
+
readonly version: (a: number) => void;
|
451
|
+
readonly get_range: (a: number, b: number) => number;
|
351
452
|
readonly js_bfs_distance_map: (a: number, b: number, c: number) => number;
|
352
|
-
readonly
|
453
|
+
readonly js_bfs_flow_field: (a: number, b: number, c: number) => number;
|
454
|
+
readonly js_dijkstra_mono_flow_field: (a: number, b: number, c: number) => number;
|
455
|
+
readonly js_path_to_flow_field_origin: (a: number, b: number) => number;
|
353
456
|
readonly __wbg_searchgoal_free: (a: number, b: number) => void;
|
354
457
|
readonly searchgoal_pos: (a: number) => number;
|
355
458
|
readonly searchgoal_range: (a: number) => number;
|
356
459
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
357
460
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
358
461
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
462
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
359
463
|
}
|
360
464
|
|
361
465
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Path as ClockworkPath } from '../wasm/screeps_clockwork';
|
2
|
+
export declare class Path {
|
3
|
+
private readonly path;
|
4
|
+
constructor(path: ClockworkPath);
|
5
|
+
[Symbol.iterator](): {
|
6
|
+
next: () => {
|
7
|
+
value: RoomPosition;
|
8
|
+
done: boolean;
|
9
|
+
};
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Iterate over the path in reverse order
|
13
|
+
*/
|
14
|
+
reversed(): Generator<never, {
|
15
|
+
next: () => {
|
16
|
+
value: RoomPosition;
|
17
|
+
done: boolean;
|
18
|
+
};
|
19
|
+
}, unknown>;
|
20
|
+
get(index: number): RoomPosition;
|
21
|
+
get length(): number;
|
22
|
+
findNextIndex(index: number): number | undefined;
|
23
|
+
toArray(): RoomPosition[];
|
24
|
+
toArrayReversed(): RoomPosition[];
|
25
|
+
free(): void;
|
26
|
+
}
|