@woosh/meep-engine 2.76.3 → 2.76.4

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.
@@ -116787,15 +116787,15 @@ function heuristic(index0, index1, width) {
116787
116787
  const x1 = index0 % width;
116788
116788
  const y1 = (index0 / width) | 0;
116789
116789
 
116790
- //
116791
116790
  const x2 = index1 % width;
116792
116791
  const y2 = (index1 / width) | 0;
116793
116792
 
116794
- //
116795
- const dx = Math.abs(x1 - x2);
116796
- const dy = Math.abs(y1 - y2);
116793
+ // deltas
116794
+ const dx = x2 - x1;
116795
+ const dy = y2 - y1;
116797
116796
 
116798
- return dx + dy;
116797
+ // we skip expensive SQRT, but still get a good guiding heuristic which has the same monotonic order
116798
+ return dx * dx + dy * dy;
116799
116799
  }
116800
116800
 
116801
116801
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.76.3",
8
+ "version": "2.76.4",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -166,15 +166,15 @@ function heuristic(index0, index1, width) {
166
166
  const x1 = index0 % width;
167
167
  const y1 = (index0 / width) | 0;
168
168
 
169
- //
170
169
  const x2 = index1 % width;
171
170
  const y2 = (index1 / width) | 0;
172
171
 
173
- //
174
- const dx = Math.abs(x1 - x2);
175
- const dy = Math.abs(y1 - y2);
172
+ // deltas
173
+ const dx = x2 - x1;
174
+ const dy = y2 - y1;
176
175
 
177
- return dx + dy;
176
+ // we skip expensive SQRT, but still get a good guiding heuristic which has the same monotonic order
177
+ return dx * dx + dy * dy;
178
178
  }
179
179
 
180
180
 
@@ -33,10 +33,10 @@ test("path on open 3x3 grid", () => {
33
33
  0, 0, 0
34
34
  ], 3, 3, 0, 8, 0, 1);
35
35
 
36
- expect(path).toEqual([0, 6, 8]);
36
+ expect(path).toEqual([0, 3, 5, 8]);
37
37
  });
38
38
 
39
- test("performance, 256x256 random", () => {
39
+ test.skip("performance, 256x256 random", () => {
40
40
  const FIELD_SIZE = 256;
41
41
 
42
42
  const field = new Uint8Array(FIELD_SIZE * FIELD_SIZE);