probe-filters 1.0.0 → 1.0.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 CHANGED
@@ -285,6 +285,47 @@ temporal.queryWithinLast('sensor:42', 60_000); // true — seen in last m
285
285
  temporal.queryBetweenAges('sensor:42', 30_000, 90_000); // true — seen 30-90s ago
286
286
  ```
287
287
 
288
+ ### Game engine — spatial interest management
289
+
290
+ Avoid O(n²) entity distance checks. Insert positions into a SpatialFilter; query a box around the player to find candidate entities before running expensive exact checks. Remove despawned entities and adapt stale keepsake boxes to keep false positives low as entities move.
291
+
292
+ ```js
293
+ const world = new SpatialFilter({ bitsPerCoordinate: 14, coordinateSystem: 'integer' });
294
+
295
+ // Server tick: insert entity positions
296
+ world.insert([1523, 871]);
297
+ world.insert([1600, 900]);
298
+
299
+ // Entity teleports — remove old, insert new
300
+ world.delete([1523, 871]);
301
+ world.insert([1530, 875]);
302
+
303
+ // Interest query: any entity near player?
304
+ const range = 100;
305
+ if (world.queryBox([1525 - range, 870 - range],
306
+ [1525 + range, 870 + range])) {
307
+ // Candidate found — run exact distance checks
308
+ }
309
+
310
+ // Entity despawns — unconditionally remove
311
+ world.delete([1530, 875]);
312
+
313
+ // Stale keepsake boxes may leave false positives behind
314
+ world.adaptFalsePositiveBox([1525 - range, 870 - range],
315
+ [1525 + range, 870 + range]);
316
+
317
+ // Anti-cheat: has this player jumped in the last 500ms?
318
+ const actions = new TemporalFilter({
319
+ bucketDurationMs: 100, retentionDurationMs: 2_000,
320
+ });
321
+ actions.insertAt('player:42:jump', Date.now());
322
+ actions.queryWithinLast('player:42:jump', 500); // true → flag excessive input
323
+
324
+ // Merge snapshot from another server shard
325
+ const neighbor = MultiFilter.deserialize(wire);
326
+ world.mergeFrom(neighbor, 'union');
327
+ ```
328
+
288
329
  ## SEE ALSO
289
330
 
290
331
  **probe-maplets** — key-value maplet extensions providing value aggregation on top of probe-filters filters.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "probe-filters",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Dynamic approximate membership filters for point, range, spatial, and temporal queries (Aleph, Aeris, Zeno engines)",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { PointFilter } from './pointFilter.js';
1
+ export { PointFilter } from './v2/pointFilter.js';
2
2
  export { RangeFilter } from './rangeFilter.js';
3
3
  export { SpatialFilter } from './spatialFilter.js';
4
4
  export { TemporalFilter } from './temporalFilter.js';
@@ -24,7 +24,8 @@ function insertMotherHash(targetFilter, motherHash, state = 1) {
24
24
  }
25
25
 
26
26
  function mergeAlephFilters(targetFilter, sourceFilter) {
27
- for (let i = 0; i < sourceFilter.currentCapacity; i++) {
27
+ const cap = sourceFilter.physicalCapacity ?? sourceFilter.currentCapacity;
28
+ for (let i = 0; i < cap; i++) {
28
29
  const state = sourceFilter.states[i];
29
30
  if (!isLiveAlephState(state)) continue;
30
31
  insertMotherHash(targetFilter, sourceFilter.motherHashes[i], state);