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
package/README.md
CHANGED
@@ -93,6 +93,7 @@ To set up the local Screeps server, you'll need to have docker installed:
|
|
93
93
|
|
94
94
|
```bash
|
95
95
|
cp .env.sample .env # fill this out with the path to your Screeps .nw package and Steam key
|
96
|
+
cp screeps.sample.json screeps.json # optionally, override this to connect to your own local Screeps server
|
96
97
|
./reset-docker.sh
|
97
98
|
```
|
98
99
|
|
package/dist/index.js
CHANGED
@@ -188,9 +188,9 @@ function addBorrowedObject(obj) {
|
|
188
188
|
* @param {number} max_rooms
|
189
189
|
* @param {number} max_ops
|
190
190
|
* @param {number} max_path_cost
|
191
|
-
* @param {Uint32Array |
|
192
|
-
* @param {Uint32Array |
|
193
|
-
* @returns {
|
191
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
192
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
193
|
+
* @returns {SearchResult}
|
194
194
|
*/
|
195
195
|
function js_astar_multiroom_distance_map(start_packed, get_cost_matrix, max_rooms, max_ops, max_path_cost, any_of_destinations, all_of_destinations) {
|
196
196
|
try {
|
@@ -201,12 +201,17 @@ function js_astar_multiroom_distance_map(start_packed, get_cost_matrix, max_room
|
|
201
201
|
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
202
202
|
var len2 = WASM_VECTOR_LEN;
|
203
203
|
const ret = wasm.js_astar_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_rooms, max_ops, max_path_cost, ptr1, len1, ptr2, len2);
|
204
|
-
return
|
204
|
+
return SearchResult.__wrap(ret);
|
205
205
|
} finally {
|
206
206
|
heap[stack_pointer++] = undefined;
|
207
207
|
}
|
208
208
|
}
|
209
209
|
|
210
|
+
function getArrayU32FromWasm0(ptr, len) {
|
211
|
+
ptr = ptr >>> 0;
|
212
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
213
|
+
}
|
214
|
+
|
210
215
|
function _assertClass(instance, klass) {
|
211
216
|
if (!(instance instanceof klass)) {
|
212
217
|
throw new Error(`expected instance of ${klass.name}`);
|
@@ -237,33 +242,14 @@ function getArrayU16FromWasm0(ptr, len) {
|
|
237
242
|
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
238
243
|
}
|
239
244
|
/**
|
240
|
-
* @param {
|
241
|
-
* @param {
|
242
|
-
* @
|
243
|
-
* @param {number} max_rooms
|
244
|
-
* @param {number} max_path_cost
|
245
|
-
* @param {Uint32Array | undefined} [any_of_destinations]
|
246
|
-
* @param {Uint32Array | undefined} [all_of_destinations]
|
247
|
-
* @returns {MultiroomDistanceMap}
|
245
|
+
* @param {number} start
|
246
|
+
* @param {MultiroomFlowField} flow_field
|
247
|
+
* @returns {Path}
|
248
248
|
*/
|
249
|
-
function
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
var ptr1 = isLikeNone(any_of_destinations) ? 0 : passArray32ToWasm0(any_of_destinations, wasm.__wbindgen_malloc);
|
254
|
-
var len1 = WASM_VECTOR_LEN;
|
255
|
-
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
256
|
-
var len2 = WASM_VECTOR_LEN;
|
257
|
-
const ret = wasm.js_dijkstra_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
258
|
-
return MultiroomDistanceMap.__wrap(ret);
|
259
|
-
} finally {
|
260
|
-
heap[stack_pointer++] = undefined;
|
261
|
-
}
|
262
|
-
}
|
263
|
-
|
264
|
-
function getArrayU32FromWasm0(ptr, len) {
|
265
|
-
ptr = ptr >>> 0;
|
266
|
-
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
249
|
+
function js_path_to_multiroom_flow_field_origin(start, flow_field) {
|
250
|
+
_assertClass(flow_field, MultiroomFlowField);
|
251
|
+
const ret = wasm.js_path_to_multiroom_flow_field_origin(start, flow_field.__wbg_ptr);
|
252
|
+
return Path.__wrap(ret);
|
267
253
|
}
|
268
254
|
|
269
255
|
function getArrayJsValueFromWasm0(ptr, len) {
|
@@ -285,6 +271,55 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
285
271
|
WASM_VECTOR_LEN = array.length;
|
286
272
|
return ptr;
|
287
273
|
}
|
274
|
+
/**
|
275
|
+
* @param {number} room_name
|
276
|
+
* @param {number | null} [plain_cost]
|
277
|
+
* @param {number | null} [swamp_cost]
|
278
|
+
* @param {number | null} [wall_cost]
|
279
|
+
* @returns {ClockworkCostMatrix}
|
280
|
+
*/
|
281
|
+
function get_terrain_cost_matrix(room_name, plain_cost, swamp_cost, wall_cost) {
|
282
|
+
const ret = wasm.get_terrain_cost_matrix(room_name, isLikeNone(plain_cost) ? 0xFFFFFF : plain_cost, isLikeNone(swamp_cost) ? 0xFFFFFF : swamp_cost, isLikeNone(wall_cost) ? 0xFFFFFF : wall_cost);
|
283
|
+
return ClockworkCostMatrix.__wrap(ret);
|
284
|
+
}
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Creates a flow field for the given distance map.
|
288
|
+
* @param {MultiroomDistanceMap} distance_map
|
289
|
+
* @returns {MultiroomFlowField}
|
290
|
+
*/
|
291
|
+
function multiroomFlowField(distance_map) {
|
292
|
+
_assertClass(distance_map, MultiroomDistanceMap);
|
293
|
+
var ptr0 = distance_map.__destroy_into_raw();
|
294
|
+
const ret = wasm.multiroomFlowField(ptr0);
|
295
|
+
return MultiroomFlowField.__wrap(ret);
|
296
|
+
}
|
297
|
+
|
298
|
+
/**
|
299
|
+
* @param {Uint32Array} start_packed
|
300
|
+
* @param {Function} get_cost_matrix
|
301
|
+
* @param {number} max_ops
|
302
|
+
* @param {number} max_rooms
|
303
|
+
* @param {number} max_path_cost
|
304
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
305
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
306
|
+
* @returns {SearchResult}
|
307
|
+
*/
|
308
|
+
function js_dijkstra_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, max_rooms, max_path_cost, any_of_destinations, all_of_destinations) {
|
309
|
+
try {
|
310
|
+
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
312
|
+
var ptr1 = isLikeNone(any_of_destinations) ? 0 : passArray32ToWasm0(any_of_destinations, wasm.__wbindgen_malloc);
|
313
|
+
var len1 = WASM_VECTOR_LEN;
|
314
|
+
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
315
|
+
var len2 = WASM_VECTOR_LEN;
|
316
|
+
const ret = wasm.js_dijkstra_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
317
|
+
return SearchResult.__wrap(ret);
|
318
|
+
} finally {
|
319
|
+
heap[stack_pointer++] = undefined;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
288
323
|
/**
|
289
324
|
* WASM wrapper for the BFS multiroom distance map function.
|
290
325
|
*
|
@@ -305,9 +340,9 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
305
340
|
* @param {number} max_ops
|
306
341
|
* @param {number} max_rooms
|
307
342
|
* @param {number} max_path_cost
|
308
|
-
* @param {Uint32Array |
|
309
|
-
* @param {Uint32Array |
|
310
|
-
* @returns {
|
343
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
344
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
345
|
+
* @returns {SearchResult}
|
311
346
|
*/
|
312
347
|
function js_bfs_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, max_rooms, max_path_cost, any_of_destinations, all_of_destinations) {
|
313
348
|
try {
|
@@ -318,35 +353,12 @@ function js_bfs_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, m
|
|
318
353
|
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
319
354
|
var len2 = WASM_VECTOR_LEN;
|
320
355
|
const ret = wasm.js_bfs_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
321
|
-
return
|
356
|
+
return SearchResult.__wrap(ret);
|
322
357
|
} finally {
|
323
358
|
heap[stack_pointer++] = undefined;
|
324
359
|
}
|
325
360
|
}
|
326
361
|
|
327
|
-
/**
|
328
|
-
* @param {number} start
|
329
|
-
* @param {MultiroomDistanceMap} distance_map
|
330
|
-
* @returns {Path}
|
331
|
-
*/
|
332
|
-
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
333
|
-
_assertClass(distance_map, MultiroomDistanceMap);
|
334
|
-
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
335
|
-
return Path.__wrap(ret);
|
336
|
-
}
|
337
|
-
|
338
|
-
/**
|
339
|
-
* @param {number} room_name
|
340
|
-
* @param {number | undefined} [plain_cost]
|
341
|
-
* @param {number | undefined} [swamp_cost]
|
342
|
-
* @param {number | undefined} [wall_cost]
|
343
|
-
* @returns {ClockworkCostMatrix}
|
344
|
-
*/
|
345
|
-
function get_terrain_cost_matrix(room_name, plain_cost, swamp_cost, wall_cost) {
|
346
|
-
const ret = wasm.get_terrain_cost_matrix(room_name, isLikeNone(plain_cost) ? 0xFFFFFF : plain_cost, isLikeNone(swamp_cost) ? 0xFFFFFF : swamp_cost, isLikeNone(wall_cost) ? 0xFFFFFF : wall_cost);
|
347
|
-
return ClockworkCostMatrix.__wrap(ret);
|
348
|
-
}
|
349
|
-
|
350
362
|
/**
|
351
363
|
* @returns {string}
|
352
364
|
*/
|
@@ -392,25 +404,13 @@ function multiroomMonoFlowField(distance_map) {
|
|
392
404
|
|
393
405
|
/**
|
394
406
|
* @param {number} start
|
395
|
-
* @param {MultiroomFlowField} flow_field
|
396
|
-
* @returns {Path}
|
397
|
-
*/
|
398
|
-
function js_path_to_multiroom_flow_field_origin(start, flow_field) {
|
399
|
-
_assertClass(flow_field, MultiroomFlowField);
|
400
|
-
const ret = wasm.js_path_to_multiroom_flow_field_origin(start, flow_field.__wbg_ptr);
|
401
|
-
return Path.__wrap(ret);
|
402
|
-
}
|
403
|
-
|
404
|
-
/**
|
405
|
-
* Creates a flow field for the given distance map.
|
406
407
|
* @param {MultiroomDistanceMap} distance_map
|
407
|
-
* @returns {
|
408
|
+
* @returns {Path}
|
408
409
|
*/
|
409
|
-
function
|
410
|
+
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
410
411
|
_assertClass(distance_map, MultiroomDistanceMap);
|
411
|
-
|
412
|
-
|
413
|
-
return MultiroomFlowField.__wrap(ret);
|
412
|
+
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
413
|
+
return Path.__wrap(ret);
|
414
414
|
}
|
415
415
|
|
416
416
|
/**
|
@@ -600,7 +600,7 @@ class ClockworkCostMatrix {
|
|
600
600
|
/**
|
601
601
|
* Creates a new cost matrix within the WASM module. Optionally, a default value
|
602
602
|
* can be provided to initialize all cells in the matrix to that value.
|
603
|
-
* @param {number |
|
603
|
+
* @param {number | null} [_default]
|
604
604
|
*/
|
605
605
|
constructor(_default) {
|
606
606
|
const ret = wasm.clockworkcostmatrix_new(isLikeNone(_default) ? 0xFFFFFF : _default);
|
@@ -828,7 +828,7 @@ class MonoFlowField {
|
|
828
828
|
* Set the direction for a given coordinate.
|
829
829
|
* @param {number} x
|
830
830
|
* @param {number} y
|
831
|
-
* @param {Direction |
|
831
|
+
* @param {Direction | null} [value]
|
832
832
|
*/
|
833
833
|
set(x, y, value) {
|
834
834
|
wasm.monoflowfield_set(this.__wbg_ptr, x, y, isLikeNone(value) ? 0 : value);
|
@@ -1081,7 +1081,7 @@ class MultiroomMonoFlowField {
|
|
1081
1081
|
/**
|
1082
1082
|
* Sets the direction at a given position
|
1083
1083
|
* @param {number} packed_pos
|
1084
|
-
* @param {Direction |
|
1084
|
+
* @param {Direction | null} [direction]
|
1085
1085
|
*/
|
1086
1086
|
set(packed_pos, direction) {
|
1087
1087
|
wasm.multiroommonoflowfield_set(this.__wbg_ptr, packed_pos, isLikeNone(direction) ? 0 : direction);
|
@@ -1216,26 +1216,91 @@ class Path {
|
|
1216
1216
|
? { register: () => {}, unregister: () => {} }
|
1217
1217
|
: new FinalizationRegistry(ptr => wasm.__wbg_searchgoal_free(ptr >>> 0, 1));
|
1218
1218
|
|
1219
|
+
const SearchResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
1220
|
+
? { register: () => {}, unregister: () => {} }
|
1221
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_searchresult_free(ptr >>> 0, 1));
|
1222
|
+
/**
|
1223
|
+
* A distance map search returns both the distance map (filled out
|
1224
|
+
* with all tiles explored) and the targets found. These aren't necessarily
|
1225
|
+
* the same positions specified as targets - if the target range is 5, then
|
1226
|
+
* this is the first position in range 5 of the target. If multiple targets
|
1227
|
+
* are specified, and you care about matching the found target with one of
|
1228
|
+
* the original targets, you can iterate through your list and figure out the
|
1229
|
+
* ones that are in range of the found target(s).
|
1230
|
+
*/
|
1231
|
+
class SearchResult {
|
1232
|
+
|
1233
|
+
static __wrap(ptr) {
|
1234
|
+
ptr = ptr >>> 0;
|
1235
|
+
const obj = Object.create(SearchResult.prototype);
|
1236
|
+
obj.__wbg_ptr = ptr;
|
1237
|
+
SearchResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
1238
|
+
return obj;
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
__destroy_into_raw() {
|
1242
|
+
const ptr = this.__wbg_ptr;
|
1243
|
+
this.__wbg_ptr = 0;
|
1244
|
+
SearchResultFinalization.unregister(this);
|
1245
|
+
return ptr;
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
free() {
|
1249
|
+
const ptr = this.__destroy_into_raw();
|
1250
|
+
wasm.__wbg_searchresult_free(ptr, 0);
|
1251
|
+
}
|
1252
|
+
/**
|
1253
|
+
* @returns {MultiroomDistanceMap}
|
1254
|
+
*/
|
1255
|
+
get distance_map() {
|
1256
|
+
const ret = wasm.searchresult_distance_map(this.__wbg_ptr);
|
1257
|
+
return MultiroomDistanceMap.__wrap(ret);
|
1258
|
+
}
|
1259
|
+
/**
|
1260
|
+
* @returns {Uint32Array}
|
1261
|
+
*/
|
1262
|
+
get found_targets() {
|
1263
|
+
try {
|
1264
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
1265
|
+
wasm.searchresult_found_targets(retptr, this.__wbg_ptr);
|
1266
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
1267
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
1268
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
1269
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
1270
|
+
return v1;
|
1271
|
+
} finally {
|
1272
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
1273
|
+
}
|
1274
|
+
}
|
1275
|
+
/**
|
1276
|
+
* @returns {number}
|
1277
|
+
*/
|
1278
|
+
get ops() {
|
1279
|
+
const ret = wasm.searchresult_ops(this.__wbg_ptr);
|
1280
|
+
return ret >>> 0;
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
|
1219
1284
|
function __wbg_get_imports() {
|
1220
1285
|
const imports = {};
|
1221
1286
|
imports.wbg = {};
|
1222
|
-
imports.wbg.
|
1287
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
1223
1288
|
const ret = getObject(arg0).buffer;
|
1224
1289
|
return addHeapObject(ret);
|
1225
1290
|
};
|
1226
|
-
imports.wbg.
|
1291
|
+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
|
1227
1292
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
1228
1293
|
return addHeapObject(ret);
|
1229
1294
|
}, arguments) };
|
1230
|
-
imports.wbg.
|
1295
|
+
imports.wbg.__wbg_ceil_2a411b0e70cc0baf = function(arg0) {
|
1231
1296
|
const ret = Math.ceil(arg0);
|
1232
1297
|
return ret;
|
1233
1298
|
};
|
1234
|
-
imports.wbg.
|
1299
|
+
imports.wbg.__wbg_clockworkcostmatrixgetpointer_ac59edc2cad584d6 = function(arg0) {
|
1235
1300
|
const ret = clockworkcostmatrix_get_pointer(takeObject(arg0));
|
1236
1301
|
return ret;
|
1237
1302
|
};
|
1238
|
-
imports.wbg.
|
1303
|
+
imports.wbg.__wbg_create_cfe43ccc88c64e0a = function(arg0) {
|
1239
1304
|
const ret = Object.create(getObject(arg0));
|
1240
1305
|
return addHeapObject(ret);
|
1241
1306
|
};
|
@@ -1262,7 +1327,7 @@ function __wbg_get_imports() {
|
|
1262
1327
|
const ret = getObject(arg0).get(arg1, arg2);
|
1263
1328
|
return ret;
|
1264
1329
|
};
|
1265
|
-
imports.wbg.
|
1330
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
1266
1331
|
const ret = getObject(arg0)[arg1 >>> 0];
|
1267
1332
|
return addHeapObject(ret);
|
1268
1333
|
};
|
@@ -1270,11 +1335,11 @@ function __wbg_get_imports() {
|
|
1270
1335
|
const ret = getObject(arg0)[getObject(arg1)];
|
1271
1336
|
return addHeapObject(ret);
|
1272
1337
|
};
|
1273
|
-
imports.wbg.
|
1338
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
1274
1339
|
const ret = getObject(arg0).length;
|
1275
1340
|
return ret;
|
1276
1341
|
};
|
1277
|
-
imports.wbg.
|
1342
|
+
imports.wbg.__wbg_log_223889c5580129ef = function(arg0, arg1) {
|
1278
1343
|
console.log(getStringFromWasm0(arg0, arg1));
|
1279
1344
|
};
|
1280
1345
|
imports.wbg.__wbg_lookFor_04c5885fea38e9b2 = function() { return handleError(function (arg0, arg1) {
|
@@ -1289,7 +1354,7 @@ function __wbg_get_imports() {
|
|
1289
1354
|
const ret = new Room.Terrain(getObject(arg0));
|
1290
1355
|
return addHeapObject(ret);
|
1291
1356
|
}, arguments) };
|
1292
|
-
imports.wbg.
|
1357
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
1293
1358
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
1294
1359
|
return addHeapObject(ret);
|
1295
1360
|
};
|
@@ -1827,6 +1892,21 @@ class ClockworkMultiroomDistanceMap {
|
|
1827
1892
|
}
|
1828
1893
|
}
|
1829
1894
|
|
1895
|
+
function fromPackedSearchResult(result) {
|
1896
|
+
const foundTargets = result.found_targets.reduce((acc, pos) => {
|
1897
|
+
acc.push(fromPacked(pos));
|
1898
|
+
return acc;
|
1899
|
+
}, []);
|
1900
|
+
const distanceMap = new ClockworkMultiroomDistanceMap(result.distance_map);
|
1901
|
+
const ops = result.ops;
|
1902
|
+
result.free();
|
1903
|
+
return {
|
1904
|
+
distanceMap,
|
1905
|
+
foundTargets,
|
1906
|
+
ops
|
1907
|
+
};
|
1908
|
+
}
|
1909
|
+
|
1830
1910
|
/**
|
1831
1911
|
* Create a distance map for the given start positions, using a breadth-first search.
|
1832
1912
|
* This does not factor in terrain costs (treating anything less than 255 in the cost
|
@@ -1848,8 +1928,18 @@ function astarMultiroomDistanceMap(start, { costMatrixCallback, maxRooms = MAX_U
|
|
1848
1928
|
throw new Error('At least one of maxRooms, maxOps, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
1849
1929
|
}
|
1850
1930
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
1851
|
-
const result = js_astar_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxRooms, maxOps, maxPathCost, anyOfDestinations
|
1852
|
-
|
1931
|
+
const result = js_astar_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxRooms, maxOps, maxPathCost, anyOfDestinations
|
1932
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
1933
|
+
acc.push(pos.__packedPos, range);
|
1934
|
+
return acc;
|
1935
|
+
}, []))
|
1936
|
+
: undefined, allOfDestinations
|
1937
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
1938
|
+
acc.push(pos.__packedPos, range);
|
1939
|
+
return acc;
|
1940
|
+
}, []))
|
1941
|
+
: undefined);
|
1942
|
+
return fromPackedSearchResult(result);
|
1853
1943
|
}
|
1854
1944
|
|
1855
1945
|
/**
|
@@ -1873,8 +1963,18 @@ function bfsMultiroomDistanceMap(start, { costMatrixCallback, maxOps = MAX_USIZE
|
|
1873
1963
|
throw new Error('At least one of maxOps, maxRooms, maxRoomDistance, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
1874
1964
|
}
|
1875
1965
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
1876
|
-
const result = js_bfs_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
1877
|
-
|
1966
|
+
const result = js_bfs_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
1967
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
1968
|
+
acc.push(pos.__packedPos, range);
|
1969
|
+
return acc;
|
1970
|
+
}, []))
|
1971
|
+
: undefined, allOfDestinations
|
1972
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
1973
|
+
acc.push(pos.__packedPos, range);
|
1974
|
+
return acc;
|
1975
|
+
}, []))
|
1976
|
+
: undefined);
|
1977
|
+
return fromPackedSearchResult(result);
|
1878
1978
|
}
|
1879
1979
|
|
1880
1980
|
/**
|
@@ -1897,8 +1997,18 @@ function dijkstraMultiroomDistanceMap(start, { costMatrixCallback, maxOps = MAX_
|
|
1897
1997
|
throw new Error('At least one of maxOps, maxRooms, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
1898
1998
|
}
|
1899
1999
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
1900
|
-
const result = js_dijkstra_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
1901
|
-
|
2000
|
+
const result = js_dijkstra_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
2001
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
2002
|
+
acc.push(pos.__packedPos, range);
|
2003
|
+
return acc;
|
2004
|
+
}, []))
|
2005
|
+
: undefined, allOfDestinations
|
2006
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
2007
|
+
acc.push(pos.__packedPos, range);
|
2008
|
+
return acc;
|
2009
|
+
}, []))
|
2010
|
+
: undefined);
|
2011
|
+
return fromPackedSearchResult(result);
|
1902
2012
|
}
|
1903
2013
|
|
1904
2014
|
/**
|