screeps-clockwork 0.4.0 → 0.5.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.
Binary file
@@ -5,11 +5,12 @@ export * from './wrappers/bfsDistanceMap';
5
5
  export * from './wrappers/bfsFlowField';
6
6
  export * from './wrappers/dijkstraDistanceMap';
7
7
  export * from './wrappers/dijkstraFlowField';
8
+ export * from './wrappers/flowField';
8
9
  export * from './wrappers/getRange';
10
+ export * from './wrappers/monoFlowField';
11
+ export * from './wrappers/multiroomFlowField';
12
+ export * from './wrappers/multiroomMonoFlowField';
9
13
  export * from './wrappers/path';
10
- export * from './wrappers/pathtoDistanceMapOrigin';
11
- export * from './wrappers/pathtoFlowFieldOrigin';
12
- export * from './wrappers/pathtoMonoFlowFieldOrigin';
13
14
  /**
14
15
  * The `initialize` function should be called in your main loop before
15
16
  * using any other screeps-clockwork functions. Depending on available
@@ -0,0 +1 @@
1
+ export declare const MAX_USIZE = 4294967295;
@@ -1 +1,3 @@
1
1
  export declare function fromPacked(packedPos: number): RoomPosition;
2
+ export declare function fromPackedRoomName(packedRoomName: number): string;
3
+ export declare function packRoomName(room: string): number;
@@ -1,76 +1,55 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * WASM wrapper for the Dijkstra flow field function.
5
- * @param {Uint32Array} start_packed
6
- * @param {ClockworkCostMatrix} cost_matrix
7
- * @returns {FlowField}
4
+ * WASM wrapper for the BFS multiroom flow field function.
8
5
  */
9
- export function js_dijkstra_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
10
- /**
11
- * @param {number} start
12
- * @param {MonoFlowField} flow_field
13
- * @returns {Path}
14
- */
15
- export function js_path_to_mono_flow_field_origin(start: number, flow_field: MonoFlowField): Path;
6
+ export function js_bfs_multiroom_flow_field(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomFlowField;
16
7
  /**
17
8
  * WASM wrapper for the Dijkstra distance map function.
18
- * @param {Uint32Array} start_packed
19
- * @param {ClockworkCostMatrix} cost_matrix
20
- * @returns {DistanceMap}
21
9
  */
22
10
  export function js_dijkstra_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
11
+ export function js_path_to_flow_field_origin(start: number, flow_field: FlowField): Path;
23
12
  /**
24
- * WASM wrapper for the BFS mono flow field function.
25
- * @param {Uint32Array} start_packed
26
- * @param {ClockworkCostMatrix} cost_matrix
27
- * @returns {MonoFlowField}
13
+ * WASM wrapper for the BFS distance map function.
28
14
  */
29
- export function js_bfs_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
15
+ export function js_bfs_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
16
+ export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomDistanceMap;
17
+ export function js_dijkstra_multiroom_flow_field(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomFlowField;
30
18
  /**
31
- * @param {number} start
32
- * @param {DistanceMap} distance_map
33
- * @returns {Path}
19
+ * WASM wrapper for the BFS multiroom distance map function.
34
20
  */
35
- export function js_path_to_distance_map_origin(start: number, distance_map: DistanceMap): Path;
21
+ export function js_bfs_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomDistanceMap;
36
22
  /**
37
- * @returns {string}
23
+ * WASM wrapper for the Dijkstra flow field function.
38
24
  */
39
- export function version(): string;
25
+ export function js_dijkstra_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
26
+ export function js_dijkstra_multiroom_mono_flow_field(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomMonoFlowField;
27
+ export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
40
28
  /**
41
- * Exports the global range calculation between two positions.
42
- * @param {number} packed_pos_1
43
- * @param {number} packed_pos_2
44
- * @returns {number}
29
+ * WASM wrapper for the BFS flow field function.
45
30
  */
46
- export function get_range(packed_pos_1: number, packed_pos_2: number): number;
31
+ export function js_bfs_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
32
+ export function js_path_to_mono_flow_field_origin(start: number, flow_field: MonoFlowField): Path;
33
+ export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
47
34
  /**
48
- * WASM wrapper for the BFS distance map function.
49
- * @param {Uint32Array} start_packed
50
- * @param {ClockworkCostMatrix} cost_matrix
51
- * @returns {DistanceMap}
35
+ * WASM wrapper for the BFS multiroom monodirectional flow field function.
52
36
  */
53
- export function js_bfs_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
37
+ export function js_bfs_multiroom_mono_flow_field(start_packed: Uint32Array, get_cost_matrix: Function, max_tiles: number, max_rooms: number, max_room_distance: number, max_tile_distance: number): MultiroomMonoFlowField;
54
38
  /**
55
- * WASM wrapper for the BFS flow field function.
56
- * @param {Uint32Array} start_packed
57
- * @param {ClockworkCostMatrix} cost_matrix
58
- * @returns {FlowField}
39
+ * WASM wrapper for the BFS mono flow field function.
59
40
  */
60
- export function js_bfs_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
41
+ export function js_bfs_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
42
+ export function js_path_to_distance_map_origin(start: number, distance_map: DistanceMap): Path;
43
+ export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
61
44
  /**
62
45
  * WASM wrapper for the Dijkstra mono flow field function.
63
- * @param {Uint32Array} start_packed
64
- * @param {ClockworkCostMatrix} cost_matrix
65
- * @returns {MonoFlowField}
66
46
  */
67
47
  export function js_dijkstra_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
48
+ export function version(): string;
68
49
  /**
69
- * @param {number} start
70
- * @param {FlowField} flow_field
71
- * @returns {Path}
50
+ * Exports the global range calculation between two positions.
72
51
  */
73
- export function js_path_to_flow_field_origin(start: number, flow_field: FlowField): Path;
52
+ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
74
53
  /**
75
54
  * Translates `COLOR_*` and `COLORS_ALL` constants.
76
55
  */
@@ -223,21 +202,14 @@ export class ClockworkCostMatrix {
223
202
  /**
224
203
  * Creates a new cost matrix within the WASM module. Optionally, a default value
225
204
  * can be provided to initialize all cells in the matrix to that value.
226
- * @param {number | undefined} [_default]
227
205
  */
228
206
  constructor(_default?: number);
229
207
  /**
230
208
  * Gets the cost of a given position in the cost matrix.
231
- * @param {number} x
232
- * @param {number} y
233
- * @returns {number}
234
209
  */
235
210
  get(x: number, y: number): number;
236
211
  /**
237
212
  * Sets the cost of a given position in the cost matrix.
238
- * @param {number} x
239
- * @param {number} y
240
- * @param {number} value
241
213
  */
242
214
  set(x: number, y: number, value: number): void;
243
215
  }
@@ -245,24 +217,18 @@ export class ClockworkCostMatrix {
245
217
  * Maps a distance value onto individual room tile positions.
246
218
  */
247
219
  export class DistanceMap {
220
+ private constructor();
248
221
  free(): void;
249
222
  /**
250
223
  * Converts the distance map into a flat array of distances.
251
- * @returns {Uint32Array}
252
224
  */
253
225
  toArray(): Uint32Array;
254
226
  /**
255
227
  * Gets the distance value at a given position.
256
- * @param {number} x
257
- * @param {number} y
258
- * @returns {number}
259
228
  */
260
229
  get(x: number, y: number): number;
261
230
  /**
262
231
  * Sets the distance value at a given position.
263
- * @param {number} x
264
- * @param {number} y
265
- * @param {number} value
266
232
  */
267
233
  set(x: number, y: number, value: number): void;
268
234
  }
@@ -273,40 +239,26 @@ export class DistanceMap {
273
239
  * 8-bit unsigned integer represents a direction that is either viable or not).
274
240
  */
275
241
  export class FlowField {
242
+ private constructor();
276
243
  free(): void;
277
244
  /**
278
245
  * Get the internal value for a given coordinate.
279
- * @param {number} x
280
- * @param {number} y
281
- * @returns {number}
282
246
  */
283
247
  get(x: number, y: number): number;
284
248
  /**
285
249
  * Set the internal value for a given coordinate.
286
- * @param {number} x
287
- * @param {number} y
288
- * @param {number} value
289
250
  */
290
251
  set(x: number, y: number, value: number): void;
291
252
  /**
292
253
  * Get the list of valid directions for a given coordinate.
293
- * @param {number} x
294
- * @param {number} y
295
- * @returns {any[]}
296
254
  */
297
255
  getDirections(x: number, y: number): any[];
298
256
  /**
299
257
  * Set the list of valid directions for a given coordinate.
300
- * @param {number} x
301
- * @param {number} y
302
- * @param {any[]} directions
303
258
  */
304
259
  setDirections(x: number, y: number, directions: any[]): void;
305
260
  /**
306
261
  * Add a direction to the list of valid directions for a given coordinate.
307
- * @param {number} x
308
- * @param {number} y
309
- * @param {Direction} direction
310
262
  */
311
263
  addDirection(x: number, y: number, direction: Direction): void;
312
264
  }
@@ -317,56 +269,124 @@ export class FlowField {
317
269
  * integer (0 for no direction, 1 for TOP, etc.).
318
270
  */
319
271
  export class MonoFlowField {
272
+ private constructor();
320
273
  free(): void;
321
274
  /**
322
275
  * Get the direction for a given coordinate.
323
- * @param {number} x
324
- * @param {number} y
325
- * @returns {Direction | undefined}
326
276
  */
327
277
  get(x: number, y: number): Direction | undefined;
328
278
  /**
329
279
  * Set the direction for a given coordinate.
330
- * @param {number} x
331
- * @param {number} y
332
- * @param {Direction | undefined} [value]
333
280
  */
334
281
  set(x: number, y: number, value?: Direction): void;
335
282
  }
336
283
  /**
337
- * A list of positions representing a path.
284
+ * Maps distance values across multiple rooms, storing a DistanceMap for each room
338
285
  */
339
- export class Path {
286
+ export class MultiroomDistanceMap {
340
287
  free(): void;
341
288
  /**
342
- * @param {number} packed_position
289
+ * Creates a new empty multiroom distance map (JavaScript constructor)
343
290
  */
344
- add(packed_position: number): void;
291
+ constructor();
345
292
  /**
346
- * @param {number} index
347
- * @returns {number | undefined}
293
+ * Gets the distance value at a given position
348
294
  */
349
- get(index: number): number | undefined;
295
+ get(packed_pos: number): number;
296
+ /**
297
+ * Sets the distance value at a given position
298
+ */
299
+ set(packed_pos: number, value: number): void;
300
+ /**
301
+ * Gets the list of rooms in the map
302
+ */
303
+ get_rooms(): Uint16Array;
304
+ /**
305
+ * Gets the DistanceMap for a given room
306
+ */
307
+ get_room(room_name: number): DistanceMap | undefined;
308
+ }
309
+ /**
310
+ * Maps flow field values across multiple rooms, storing a FlowField for each room
311
+ */
312
+ export class MultiroomFlowField {
313
+ free(): void;
314
+ /**
315
+ * Creates a new empty multiroom flow field (JavaScript constructor)
316
+ */
317
+ constructor();
318
+ /**
319
+ * Gets the flow field value at a given position
320
+ */
321
+ get(packed_pos: number): number;
322
+ /**
323
+ * Sets the flow field value at a given position
324
+ */
325
+ set(packed_pos: number, value: number): void;
326
+ /**
327
+ * Gets the list of rooms in the flow field
328
+ */
329
+ getRooms(): Uint16Array;
330
+ /**
331
+ * Gets the FlowField for a given room
332
+ */
333
+ getRoom(room_name: number): FlowField | undefined;
334
+ /**
335
+ * Gets the list of valid directions at a given position (JavaScript)
336
+ */
337
+ getDirections(packed_pos: number): any[];
338
+ /**
339
+ * Sets the list of valid directions at a given position (JavaScript)
340
+ */
341
+ setDirections(packed_pos: number, directions: any[]): void;
342
+ /**
343
+ * Adds a direction to the list of valid directions at a given position (JavaScript)
344
+ */
345
+ addDirection(packed_pos: number, direction: Direction): void;
346
+ }
347
+ /**
348
+ * Maps monodirectional flow field values across multiple rooms, storing a MonoFlowField for each room
349
+ */
350
+ export class MultiroomMonoFlowField {
351
+ free(): void;
352
+ /**
353
+ * Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
354
+ */
355
+ constructor();
350
356
  /**
351
- * @returns {number}
357
+ * Gets the direction at a given position
352
358
  */
359
+ get(packed_pos: number): Direction | undefined;
360
+ /**
361
+ * Sets the direction at a given position
362
+ */
363
+ set(packed_pos: number, direction?: Direction): void;
364
+ /**
365
+ * Gets the list of rooms in the flow field
366
+ */
367
+ getRooms(): Uint16Array;
368
+ /**
369
+ * Gets the MonoFlowField for a given room
370
+ */
371
+ getRoom(room_name: number): MonoFlowField | undefined;
372
+ }
373
+ /**
374
+ * A list of positions representing a path.
375
+ */
376
+ export class Path {
377
+ private constructor();
378
+ free(): void;
379
+ add(packed_position: number): void;
380
+ get(index: number): number | undefined;
353
381
  len(): number;
354
382
  /**
355
383
  * Given a position, find the index of the next adjacent position
356
384
  * in the path. If the position is not in the path, the target is
357
385
  * the next adjacent position closest to the end of the path. If
358
386
  * the position is neither on nor adjacent to the path, return None.
359
- * @param {number} packed_position
360
- * @returns {number | undefined}
361
387
  */
362
388
  find_next_index(packed_position: number): number | undefined;
363
- /**
364
- * @returns {Uint32Array}
365
- */
366
389
  to_array(): Uint32Array;
367
- /**
368
- * @returns {Uint32Array}
369
- */
370
390
  to_array_reversed(): Uint32Array;
371
391
  }
372
392
  /**
@@ -375,9 +395,6 @@ export class Path {
375
395
  */
376
396
  export class PathFatigue {
377
397
  free(): void;
378
- /**
379
- * @param {Path} path
380
- */
381
398
  constructor(path: Path);
382
399
  /**
383
400
  * Refreshes fatigue cost for each position in the path. If the PathFatigue
@@ -386,24 +403,19 @@ export class PathFatigue {
386
403
  * list *has* been initialized, only positions with vision will be updated.
387
404
  *
388
405
  * When there is vision, this also accounts for roads at the position.
389
- * @param {Path} path
390
406
  */
391
407
  refresh(path: Path): void;
392
- /**
393
- * @returns {number}
394
- */
395
408
  len(): number;
396
409
  /**
397
410
  * Calculates the total move time for the path, given a fatigue ratio.
398
411
  *
399
412
  * For unboosted creeps, the ratio is `Math.floor(moveParts * 2 / fatigueParts)`
400
413
  * where `fatigue_parts` are any part except MOVE and empty CARRY parts.
401
- * @param {number} fatigue_ratio
402
- * @returns {number}
403
414
  */
404
415
  moveTime(fatigue_ratio: number): number;
405
416
  }
406
417
  export class SearchGoal {
418
+ private constructor();
407
419
  free(): void;
408
420
  readonly pos: any;
409
421
  readonly range: number;
@@ -413,53 +425,84 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
413
425
 
414
426
  export interface InitOutput {
415
427
  readonly memory: WebAssembly.Memory;
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;
428
- readonly js_dijkstra_flow_field: (a: number, b: number, c: number) => number;
428
+ readonly js_bfs_multiroom_flow_field: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
429
+ readonly js_dijkstra_distance_map: (a: number, b: number, c: number) => number;
430
+ readonly js_path_to_flow_field_origin: (a: number, b: number) => number;
429
431
  readonly __wbg_flowfield_free: (a: number, b: number) => void;
430
432
  readonly flowfield_get: (a: number, b: number, c: number) => number;
431
433
  readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
432
434
  readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
433
435
  readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
434
436
  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;
436
- readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
437
- readonly monoflowfield_get: (a: number, b: number, c: number) => number;
438
- readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
437
+ readonly js_bfs_distance_map: (a: number, b: number, c: number) => number;
438
+ readonly js_dijkstra_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
439
+ readonly js_dijkstra_multiroom_flow_field: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
440
+ readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
441
+ readonly js_dijkstra_flow_field: (a: number, b: number, c: number) => number;
442
+ readonly js_dijkstra_multiroom_mono_flow_field: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
443
+ readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
439
444
  readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
440
445
  readonly clockworkcostmatrix_new: (a: number) => number;
441
446
  readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
442
447
  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;
448
+ readonly js_bfs_flow_field: (a: number, b: number, c: number) => number;
449
+ readonly js_path_to_mono_flow_field_origin: (a: number, b: number) => number;
450
+ readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
451
+ readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
452
+ readonly multiroomdistancemap_js_new: () => number;
453
+ readonly multiroomdistancemap_get: (a: number, b: number) => number;
454
+ readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
455
+ readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
456
+ readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
457
+ readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
458
+ readonly multiroommonoflowfield_get: (a: number, b: number) => number;
459
+ readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
460
+ readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
461
+ readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
462
+ readonly multiroommonoflowfield_js_new: () => number;
463
+ readonly js_bfs_multiroom_mono_flow_field: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
464
+ readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
465
+ readonly monoflowfield_get: (a: number, b: number, c: number) => number;
466
+ readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
444
467
  readonly js_bfs_mono_flow_field: (a: number, b: number, c: number) => number;
445
468
  readonly js_path_to_distance_map_origin: (a: number, b: number) => number;
469
+ readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
470
+ readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
471
+ readonly multiroomflowfield_js_new: () => number;
472
+ readonly multiroomflowfield_get: (a: number, b: number) => number;
473
+ readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
474
+ readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
475
+ readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
476
+ readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
477
+ readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
478
+ readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
479
+ readonly js_dijkstra_mono_flow_field: (a: number, b: number, c: number) => number;
446
480
  readonly __wbg_distancemap_free: (a: number, b: number) => void;
447
481
  readonly distancemap_toArray: (a: number, b: number) => void;
448
482
  readonly distancemap_get: (a: number, b: number, c: number) => number;
449
483
  readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
484
+ readonly __wbg_path_free: (a: number, b: number) => void;
485
+ readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
486
+ readonly path_add: (a: number, b: number) => void;
487
+ readonly path_get: (a: number, b: number) => number;
488
+ readonly path_len: (a: number) => number;
489
+ readonly path_find_next_index: (a: number, b: number) => number;
490
+ readonly path_to_array: (a: number, b: number) => void;
491
+ readonly path_to_array_reversed: (a: number, b: number) => void;
492
+ readonly pathfatigue_new: (a: number) => number;
493
+ readonly pathfatigue_refresh: (a: number, b: number) => void;
494
+ readonly pathfatigue_moveTime: (a: number, b: number) => number;
450
495
  readonly version: (a: number) => void;
451
496
  readonly get_range: (a: number, b: number) => number;
452
- readonly js_bfs_distance_map: (a: number, b: number, c: number) => number;
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;
497
+ readonly pathfatigue_len: (a: number) => number;
456
498
  readonly __wbg_searchgoal_free: (a: number, b: number) => void;
457
499
  readonly searchgoal_pos: (a: number) => number;
458
500
  readonly searchgoal_range: (a: number) => number;
459
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
501
+ readonly __wbindgen_exn_store: (a: number) => void;
460
502
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
461
503
  readonly __wbindgen_malloc: (a: number, b: number) => number;
462
- readonly __wbindgen_exn_store: (a: number) => void;
504
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
505
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
463
506
  }
464
507
 
465
508
  export type SyncInitInput = BufferSource | WebAssembly.Module;
@@ -1,4 +1,6 @@
1
1
  import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
+ import { ClockworkDistanceMap } from './distanceMap';
3
+ import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
2
4
  /**
3
5
  * Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
6
  * using a breadth-first search algorithm.
@@ -17,4 +19,28 @@ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
17
19
  * @param costMatrix - The cost matrix to use for the flow field.
18
20
  * @returns The flow field.
19
21
  */
20
- export declare function bfsDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
22
+ export declare function bfsDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): ClockworkDistanceMap;
23
+ /**
24
+ * Create a distance map for the given start positions, using a breadth-first search.
25
+ * This does not factor in terrain costs (treating anything less than 255 in the cost
26
+ * matrix as passable), so it's faster but less useful than Dijkstra's algorithm.
27
+ *
28
+ * This calculates a distance map across multiple rooms, with a few configurable limits:
29
+ * - `maxTiles`: The maximum number of tiles to explore.
30
+ * - `maxRooms`: The maximum number of rooms to explore.
31
+ * - `maxRoomDistance`: Don't explore rooms further (in Manhattan distance) than this.
32
+ * - `maxTileDistance`: Don't explore tiles further (in Chebyshev distance) than this.
33
+ *
34
+ * At least one of these limits must be set.
35
+ *
36
+ * @param start - The starting positions.
37
+ * @param options - The options for the distance map.
38
+ * @returns A multi-room distance map.
39
+ */
40
+ export declare function bfsMultiroomDistanceMap(start: RoomPosition[], { costMatrixCallback, maxTiles, maxRooms, maxRoomDistance, maxTileDistance }: {
41
+ costMatrixCallback: (room: string) => ClockworkCostMatrix | undefined;
42
+ maxTiles?: number;
43
+ maxRooms?: number;
44
+ maxRoomDistance?: number;
45
+ maxTileDistance?: number;
46
+ }): ClockworkMultiroomDistanceMap;
@@ -1,4 +1,8 @@
1
1
  import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
+ import { ClockworkFlowField } from './flowField';
3
+ import { ClockworkMonoFlowField } from './monoFlowField';
4
+ import { ClockworkMultiroomFlowField } from './multiroomFlowField';
5
+ import { ClockworkMultiroomMonoFlowField } from './multiroomMonoFlowField';
2
6
  /**
3
7
  * Generate a [flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
8
  * using a breadth-first search algorithm.
@@ -14,7 +18,7 @@ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
14
18
  * @param costMatrix - The cost matrix to use for the flow field.
15
19
  * @returns The flow field.
16
20
  */
17
- export declare function bfsFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").FlowField;
21
+ export declare function bfsFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): ClockworkFlowField;
18
22
  /**
19
23
  * Generate a [mono-directional flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html)
20
24
  * for a set of positions using a breadth-first search algorithm.
@@ -33,4 +37,48 @@ export declare function bfsFlowField(start: RoomPosition[], costMatrix: Clockwor
33
37
  * @param costMatrix - The cost matrix to use for the flow field.
34
38
  * @returns The flow field.
35
39
  */
36
- export declare function bfsMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").MonoFlowField;
40
+ export declare function bfsMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): ClockworkMonoFlowField;
41
+ /**
42
+ * Generate a multiroom flow field for a set of positions using a breadth-first search algorithm.
43
+ *
44
+ * The BFS algorithm doesn't include variable costs, and only considers
45
+ * values of 255 (impassible) in the provided cost matrix. Any other
46
+ * values are ignored.
47
+ *
48
+ * This might be useful for creeps with only MOVE parts and/or empty
49
+ * CARRY parts, which don't generate fatigue.
50
+ *
51
+ * @param start - The starting positions.
52
+ * @param costMatrixCallback - A function that returns a cost matrix for a given room name.
53
+ * @param options - Options for the flow field generation.
54
+ * @returns The flow field.
55
+ */
56
+ export declare function bfsMultiroomFlowField(start: RoomPosition[], { costMatrixCallback, maxTiles, maxRooms, maxRoomDistance, maxTileDistance }: {
57
+ costMatrixCallback: (roomName: string) => ClockworkCostMatrix | undefined;
58
+ maxTiles?: number;
59
+ maxRooms?: number;
60
+ maxRoomDistance?: number;
61
+ maxTileDistance?: number;
62
+ }): ClockworkMultiroomFlowField;
63
+ /**
64
+ * Generate a multiroom mono-directional flow field for a set of positions using a breadth-first search algorithm.
65
+ *
66
+ * The BFS algorithm doesn't include variable costs, and only considers
67
+ * values of 255 (impassible) in the provided cost matrix. Any other
68
+ * values are ignored.
69
+ *
70
+ * This might be useful for creeps with only MOVE parts and/or empty
71
+ * CARRY parts, which don't generate fatigue.
72
+ *
73
+ * @param start - The starting positions.
74
+ * @param getCostMatrix - A function that returns a cost matrix for a given room name.
75
+ * @param options - Options for the flow field generation.
76
+ * @returns The flow field.
77
+ */
78
+ export declare function bfsMultiroomMonoFlowField(start: RoomPosition[], { costMatrixCallback, maxTiles, maxRooms, maxRoomDistance, maxTileDistance }: {
79
+ costMatrixCallback: (roomName: string) => ClockworkCostMatrix | undefined;
80
+ maxTiles?: number;
81
+ maxRooms?: number;
82
+ maxRoomDistance?: number;
83
+ maxTileDistance?: number;
84
+ }): ClockworkMultiroomMonoFlowField;
@@ -1,4 +1,6 @@
1
1
  import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
+ import { ClockworkDistanceMap } from './distanceMap';
3
+ import { ClockworkMultiroomDistanceMap } from './multiroomDistanceMap';
2
4
  /**
3
5
  * Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
6
  * using Dijkstra's algorithm.
@@ -15,4 +17,27 @@ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
15
17
  * @param costMatrix - The cost matrix to use for the flow field.
16
18
  * @returns The flow field.
17
19
  */
18
- export declare function dijkstraDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
20
+ export declare function dijkstraDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): ClockworkDistanceMap;
21
+ /**
22
+ * Create a distance map for the given start positions, using Dijkstra's algorithm to
23
+ * factor in terrain costs (0-255, where 255 is impassable).
24
+ *
25
+ * This calculates a distance map across multiple rooms, with a few configurable limits:
26
+ * - `maxTiles`: The maximum number of tiles to explore.
27
+ * - `maxRooms`: The maximum number of rooms to explore.
28
+ * - `maxRoomDistance`: Don't explore rooms further (in Manhattan distance) than this.
29
+ * - `maxTileDistance`: Don't explore tiles further (in accumulated cost) than this.
30
+ *
31
+ * At least one of these limits must be set.
32
+ *
33
+ * @param start - The starting positions.
34
+ * @param options - The options for the distance map.
35
+ * @returns A multi-room distance map.
36
+ */
37
+ export declare function dijkstraMultiroomDistanceMap(start: RoomPosition[], { costMatrixCallback, maxTiles, maxRooms, maxRoomDistance, maxTileDistance }: {
38
+ costMatrixCallback: (room: string) => ClockworkCostMatrix | undefined;
39
+ maxTiles?: number;
40
+ maxRooms?: number;
41
+ maxRoomDistance?: number;
42
+ maxTileDistance?: number;
43
+ }): ClockworkMultiroomDistanceMap;