screeps-clockwork 0.6.0 → 0.7.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 +1 -0
- package/dist/index.js +201 -91
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/wasm/screeps_clockwork.d.ts +60 -40
- 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 +2 -2
Binary file
|
@@ -1,8 +1,14 @@
|
|
1
1
|
/* tslint:disable */
|
2
2
|
/* eslint-disable */
|
3
|
-
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, all_of_destinations?: Uint32Array):
|
3
|
+
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;
|
4
4
|
export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
|
5
|
-
export function
|
5
|
+
export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
|
6
|
+
export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
|
7
|
+
/**
|
8
|
+
* Creates a flow field for the given distance map.
|
9
|
+
*/
|
10
|
+
export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
|
11
|
+
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;
|
6
12
|
/**
|
7
13
|
* WASM wrapper for the BFS multiroom distance map function.
|
8
14
|
*
|
@@ -19,9 +25,7 @@ export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, ge
|
|
19
25
|
* # Returns
|
20
26
|
* A `MultiroomDistanceMap` containing the distances from the start positions
|
21
27
|
*/
|
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 js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
|
24
|
-
export function get_terrain_cost_matrix(room_name: number, plain_cost?: number, swamp_cost?: number, wall_cost?: number): ClockworkCostMatrix;
|
28
|
+
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
29
|
export function version(): string;
|
26
30
|
/**
|
27
31
|
* Exports the global range calculation between two positions.
|
@@ -31,11 +35,7 @@ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
|
|
31
35
|
* Creates a monodirectional flow field for the given distance map.
|
32
36
|
*/
|
33
37
|
export function multiroomMonoFlowField(distance_map: MultiroomDistanceMap): MultiroomMonoFlowField;
|
34
|
-
export function
|
35
|
-
/**
|
36
|
-
* Creates a flow field for the given distance map.
|
37
|
-
*/
|
38
|
-
export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
|
38
|
+
export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
|
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
|
*/
|
@@ -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
|
@@ -346,7 +346,7 @@ export class MultiroomMonoFlowField {
|
|
346
346
|
/**
|
347
347
|
* Sets the direction at a given position
|
348
348
|
*/
|
349
|
-
set(packed_pos: number, direction?: Direction): void;
|
349
|
+
set(packed_pos: number, direction?: Direction | null): void;
|
350
350
|
/**
|
351
351
|
* Gets the list of rooms in the flow field
|
352
352
|
*/
|
@@ -406,12 +406,36 @@ 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
430
|
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;
|
431
|
+
readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
|
432
|
+
readonly clockworkcostmatrix_new: (a: number) => number;
|
433
|
+
readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
|
434
|
+
readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
|
435
|
+
readonly __wbg_searchresult_free: (a: number, b: number) => void;
|
436
|
+
readonly searchresult_distance_map: (a: number) => number;
|
437
|
+
readonly searchresult_found_targets: (a: number, b: number) => void;
|
438
|
+
readonly searchresult_ops: (a: number) => number;
|
415
439
|
readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
|
416
440
|
readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
|
417
441
|
readonly multiroommonoflowfield_js_new: () => number;
|
@@ -419,13 +443,18 @@ export interface InitOutput {
|
|
419
443
|
readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
|
420
444
|
readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
|
421
445
|
readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
|
422
|
-
readonly
|
423
|
-
readonly
|
424
|
-
readonly
|
425
|
-
readonly
|
426
|
-
readonly
|
427
|
-
readonly
|
428
|
-
readonly
|
446
|
+
readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
|
447
|
+
readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
|
448
|
+
readonly multiroomflowfield_js_new: () => number;
|
449
|
+
readonly multiroomflowfield_get: (a: number, b: number) => number;
|
450
|
+
readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
|
451
|
+
readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
|
452
|
+
readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
|
453
|
+
readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
|
454
|
+
readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
|
455
|
+
readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
|
456
|
+
readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
|
457
|
+
readonly multiroomFlowField: (a: number) => number;
|
429
458
|
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;
|
430
459
|
readonly __wbg_distancemap_free: (a: number, b: number) => void;
|
431
460
|
readonly distancemap_toArray: (a: number, b: number) => void;
|
@@ -438,28 +467,11 @@ export interface InitOutput {
|
|
438
467
|
readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
|
439
468
|
readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
|
440
469
|
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
|
442
|
-
readonly
|
470
|
+
readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
|
471
|
+
readonly monoflowfield_get: (a: number, b: number, c: number) => number;
|
472
|
+
readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
|
443
473
|
readonly version: (a: number) => void;
|
444
474
|
readonly get_range: (a: number, b: number) => number;
|
445
|
-
readonly multiroomMonoFlowField: (a: number) => number;
|
446
|
-
readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
|
447
|
-
readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
|
448
|
-
readonly multiroomdistancemap_js_new: () => number;
|
449
|
-
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
|
-
readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
|
453
|
-
readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
|
454
|
-
readonly multiroomflowfield_js_new: () => number;
|
455
|
-
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
|
-
readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
|
460
|
-
readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
|
461
|
-
readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
|
462
|
-
readonly multiroomFlowField: (a: number) => number;
|
463
475
|
readonly __wbg_path_free: (a: number, b: number) => void;
|
464
476
|
readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
|
465
477
|
readonly path_add: (a: number, b: number) => void;
|
@@ -472,6 +484,14 @@ export interface InitOutput {
|
|
472
484
|
readonly pathfatigue_refresh: (a: number, b: number) => void;
|
473
485
|
readonly pathfatigue_len: (a: number) => number;
|
474
486
|
readonly pathfatigue_moveTime: (a: number, b: number) => number;
|
487
|
+
readonly multiroomMonoFlowField: (a: number) => number;
|
488
|
+
readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
|
489
|
+
readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
|
490
|
+
readonly multiroomdistancemap_js_new: () => number;
|
491
|
+
readonly multiroomdistancemap_get: (a: number, b: number) => number;
|
492
|
+
readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
|
493
|
+
readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
|
494
|
+
readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
|
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.1",
|
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",
|