bard-legends-framework 0.9.5 → 0.9.7
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/dist/_interfaces/index.d.ts +2 -2
- package/dist/_interfaces/index.js +2 -3
- package/dist/game-entities/attachable/attachable.d.ts +6 -6
- package/dist/game-entities/attachable/attachable.js +28 -30
- package/dist/game-entities/attachable/attachable.spec.js +129 -128
- package/dist/game-entities/attachable/attachable.store.d.ts +5 -5
- package/dist/game-entities/attachable/attachable.store.js +34 -32
- package/dist/game-entities/attachable/attachable.test.js +132 -131
- package/dist/game-entities/attachable/destroyable.d.ts +13 -13
- package/dist/game-entities/attachable/destroyable.js +64 -69
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.js +125 -116
- package/dist/game-entities/attachable/helpers/referance-variable.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/referance-variable.js +47 -48
- package/dist/game-entities/attachable/interfaces.d.ts +6 -6
- package/dist/game-entities/attachable/interfaces.js +2 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +0 -1
- package/dist/game-entities/controller/controller.js +0 -1
- package/dist/game-entities/controller/controller.spec.js +128 -125
- package/dist/game-entities/entity/entity.spec.js +263 -293
- package/dist/game-entities/entity/helpers/view-creation.helper.d.ts +7 -7
- package/dist/game-entities/entity/helpers/view-creation.helper.js +48 -48
- package/dist/game-entities/scene/scene.spec.js +219 -223
- package/dist/game-entities/service/service.js +0 -4
- package/dist/game-entities/service/service.spec.js +265 -237
- package/dist/game-entities/service/service.test.js +4 -2
- package/dist/game-entities/update-loop.d.ts +18 -18
- package/dist/game-entities/update-loop.js +46 -28
- package/dist/game-entities/view/view.js +1 -1
- package/dist/game-entities/view/view.spec.js +490 -506
- package/dist/game-entities/view/view.test.js +1 -1
- package/dist/lib/animator/animations.d.ts +13 -13
- package/dist/lib/animator/animations.js +43 -40
- package/dist/lib/animator/animator.d.ts +41 -41
- package/dist/lib/animator/animator.js +194 -197
- package/dist/lib/animator/animator.spec.js +699 -612
- package/dist/lib/animator/index.js +24 -19
- package/dist/lib/libraries/animator/animations.d.ts +13 -13
- package/dist/lib/libraries/animator/animations.js +43 -40
- package/dist/lib/libraries/animator/animator.d.ts +41 -41
- package/dist/lib/libraries/animator/animator.js +194 -197
- package/dist/lib/libraries/animator/animator.spec.js +699 -612
- package/dist/lib/libraries/animator/index.js +24 -19
- package/dist/lib/libraries/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/libraries/path-finder/path-finder.js +19 -20
- package/dist/lib/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/path-finder/path-finder.js +19 -20
- package/dist/lib/services/keyboard/keyboard.d.ts +4 -4
- package/dist/lib/services/keyboard/keyboard.js +39 -31
- package/dist/lib/services/mouse/mouse.service.d.ts +8 -8
- package/dist/lib/services/mouse/mouse.service.js +65 -53
- package/dist/lib/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/lib/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/lib/update-loop.d.ts +10 -10
- package/dist/lib/update-loop.js +35 -27
- package/dist/physics/entitity-types/immovable-physics-entity.d.ts +6 -6
- package/dist/physics/entitity-types/immovable-physics-entity.js +23 -24
- package/dist/physics/entitity-types/movable-entity.d.ts +6 -6
- package/dist/physics/entitity-types/movable-entity.js +21 -22
- package/dist/physics/entitity-types/movable-physics-entity.d.ts +14 -14
- package/dist/physics/entitity-types/movable-physics-entity.js +83 -88
- package/dist/physics/entitity-types/physics-entity.d.ts +23 -23
- package/dist/physics/entitity-types/physics-entity.js +97 -88
- package/dist/physics/helpers/closest-available-space.helper.d.ts +16 -16
- package/dist/physics/helpers/closest-available-space.helper.js +98 -96
- package/dist/physics/helpers/closest-available-space.helper.spec.js +115 -68
- package/dist/physics/helpers/p2js.helper.d.ts +3 -3
- package/dist/physics/helpers/p2js.helper.js +21 -22
- package/dist/physics/helpers/shape-factory.d.ts +9 -4
- package/dist/physics/helpers/shape-factory.js +99 -75
- package/dist/physics/libs/p2js.helper.js +1 -1
- package/dist/physics/libs/position-to-grid-position-converter.d.ts +3 -3
- package/dist/physics/libs/position-to-grid-position-converter.js +15 -13
- package/dist/physics/module//360/237/223/220services/availability-grid.service.d.ts +10 -5
- package/dist/physics/module//360/237/223/220services/availability-grid.service.js +77 -57
- package/dist/physics/module//360/237/223/220services/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/border.service.js +57 -37
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/collisions.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/collisions.service.js +110 -98
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.d.ts +28 -6
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.js +121 -89
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/materials.service.d.ts +16 -11
- package/dist/physics/module//360/237/223/220services/materials.service.js +118 -108
- package/dist/physics/module//360/237/223/220services/path-finder.service.d.ts +19 -8
- package/dist/physics/module//360/237/223/220services/path-finder.service.js +121 -82
- package/dist/physics/module//360/237/223/220services/physics-world.service.d.ts +30 -15
- package/dist/physics/module//360/237/223/220services/physics-world.service.js +122 -100
- package/dist/physics/module//360/237/223/220services/ray-casting.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/ray-casting.service.js +87 -86
- package/dist/physics/module//360/237/223/220services/shape-creation.service.d.ts +9 -4
- package/dist/physics/module//360/237/223/220services/shape-creation.service.js +113 -84
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +2 -1
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.d.ts +8 -8
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js +32 -33
- package/dist/physics/physics-world.d.ts +50 -34
- package/dist/physics/physics-world.js +142 -133
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.d.ts +3 -3
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js +15 -13
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.d.ts +9 -9
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js +82 -77
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.d.ts +18 -14
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js +91 -79
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.d.ts +11 -11
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js +84 -76
- package/dist/physics/sub-elements/collisions/physics-collision.d.ts +7 -7
- package/dist/physics/sub-elements/collisions/physics-collision.js +43 -44
- package/dist/physics/sub-elements/elements/physics-body-groups.d.ts +11 -11
- package/dist/physics/sub-elements/elements/physics-body-groups.js +54 -54
- package/dist/physics/sub-elements/elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/elements/physics-world-borders.d.ts +3 -3
- package/dist/physics/sub-elements/elements/physics-world-borders.js +69 -45
- package/dist/physics/sub-elements/physics-body-groups.d.ts +8 -8
- package/dist/physics/sub-elements/physics-body-groups.js +41 -42
- package/dist/physics/sub-elements/physics-collision.d.ts +16 -16
- package/dist/physics/sub-elements/physics-collision.js +141 -121
- package/dist/physics/sub-elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/physics-world-borders.d.ts +2 -2
- package/dist/physics/sub-elements/physics-world-borders.js +25 -26
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.d.ts +15 -11
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js +59 -59
- package/dist/physics/sub-elements/raycasting/physics-explosion.d.ts +13 -6
- package/dist/physics/sub-elements/raycasting/physics-explosion.js +108 -73
- package/dist/physics/sub-elements/raycasting/ray-cast.d.ts +19 -19
- package/dist/physics/sub-elements/raycasting/ray-cast.js +93 -98
- package/dist/pixi/display-object/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/components/filters.js +106 -81
- package/dist/pixi/display-object/components/glow-effect.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-effect.js +33 -36
- package/dist/pixi/display-object/components/glow-filter.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-filter.js +33 -36
- package/dist/pixi/display-object/container-attributes.js +1 -1
- package/dist/pixi/display-object/display-object-attributes.d.ts +41 -41
- package/dist/pixi/display-object/display-object-attributes.js +148 -150
- package/dist/pixi/display-object/display-object.d.ts +17 -17
- package/dist/pixi/display-object/display-object.js +79 -75
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.js +89 -77
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +30 -30
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.js +62 -53
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.js +93 -81
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.d.ts +12 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.js +120 -109
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +32 -32
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.js +92 -85
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +28 -28
- package/dist/pixi/display-object/filters/templates/plane.template.js +20 -20
- package/dist/pixi/display-object/filters.js +20 -4
- package/dist/pixi/display-object/objects/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/objects/components/filters.js +106 -81
- package/dist/pixi/display-object/objects/container.d.ts +2 -2
- package/dist/pixi/display-object/objects/container.js +39 -30
- package/dist/pixi/display-object/objects/graphics.d.ts +28 -28
- package/dist/pixi/display-object/objects/graphics.js +218 -202
- package/dist/pixi/display-object/objects/helpers/filters.d.ts +25 -25
- package/dist/pixi/display-object/objects/helpers/filters.js +150 -124
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.d.ts +7 -7
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.js +114 -95
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.d.ts +5 -5
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.js +81 -57
- package/dist/pixi/display-object/objects/sprite.d.ts +43 -43
- package/dist/pixi/display-object/objects/sprite.js +248 -233
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +9 -9
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +1 -1
- package/dist/pixi/display-object/objects/text.d.ts +25 -25
- package/dist/pixi/display-object/objects/text.js +111 -102
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.d.ts +13 -9
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js +96 -67
- package/dist/pixi/game.d.ts +1 -1
- package/dist/pixi/game.js +2 -2
- package/dist/pixi/helpers/glow-sprite-generator.d.ts +6 -6
- package/dist/pixi/helpers/glow-sprite-generator.js +99 -84
- package/dist/pixi/helpers/pixi-container.helper.d.ts +1 -1
- package/dist/pixi/helpers/pixi-container.helper.js +10 -8
- package/dist/pixi/helpers/screen-position-to-stage.helper.d.ts +1 -1
- package/dist/pixi/helpers/screen-position-to-stage.helper.js +12 -12
- package/dist/pixi/helpers/screen-position-to-stage.helper.test.js +174 -79
- package/dist/pixi/modules/CAMERA/index.d.ts +1 -1
- package/dist/pixi/modules/CAMERA/index.js +3 -3
- package/dist/services/keyboard/keyboard.d.ts +4 -4
- package/dist/services/keyboard/keyboard.js +39 -31
- package/dist/services/mouse/mouse.service.d.ts +8 -8
- package/dist/services/mouse/mouse.service.js +65 -53
- package/dist/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/utilities/libraries/animator/animating-content/state-animation.d.ts +29 -26
- package/dist/utilities/libraries/animator/animating-content/state-animation.js +159 -165
- package/dist/utilities/libraries/animator/animating-content/state-animation.test.js +386 -375
- package/dist/utilities/libraries/animator/animator.spec.js +765 -656
- package/dist/utilities/libraries/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/grid/grid.d.ts +35 -31
- package/dist/utilities/libraries/data-structures/grid/grid.js +128 -117
- package/dist/utilities/libraries/data-structures/grid/grid.spec.js +176 -138
- package/dist/utilities/libraries/data-structures/grid/grid.test.js +218 -141
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.d.ts +3 -3
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.js +15 -13
- package/dist/utilities/libraries/data-structures/queue/queue.d.ts +21 -21
- package/dist/utilities/libraries/data-structures/queue/queue.js +63 -66
- package/dist/utilities/libraries/data-structures/queue/queue.test.js +54 -55
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.spec.js +122 -68
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.spec.js +140 -135
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.spec.js +293 -229
- package/dist/utilities/libraries/path-finder/path-finder.d.ts +7 -7
- package/dist/utilities/libraries/path-finder/path-finder.js +113 -109
- package/dist/utilities/libraries/path-finder/path-finder.spec.js +131 -106
- package/dist/utilities/services/keyboard/keyboard.d.ts +4 -4
- package/dist/utilities/services/keyboard/keyboard.js +42 -34
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +12 -12
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +168 -73
- package/dist/utilities/services/mouse/mouse-target-focus.service.d.ts +15 -15
- package/dist/utilities/services/mouse/mouse-target-focus.service.js +79 -76
- package/dist/utilities/services/mouse/mouse.service.d.ts +9 -9
- package/dist/utilities/services/mouse/mouse.service.js +86 -72
- package/dist/utilities/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/utilities/services/mouse/mouser-target-focus.service.js +83 -81
- package/package.json +6 -12
|
@@ -1,58 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const queue_1 = require("./queue");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const vitest_1 = require('vitest');
|
|
3
|
+
const queue_1 = require('./queue');
|
|
5
4
|
(0, vitest_1.describe)('Queue', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
(0, vitest_1.test)('should return false when queue is not empty', () => {
|
|
12
|
-
let queue = new queue_1.Queue(1);
|
|
13
|
-
(0, vitest_1.expect)(queue.isEmpty).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
(0, vitest_1.test)('should add elements to the queue', () => {
|
|
16
|
-
let queue = new queue_1.Queue();
|
|
17
|
-
queue.add(1, 2, 3);
|
|
18
|
-
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
19
|
-
(0, vitest_1.expect)(queue.pop()).toBe(2);
|
|
20
|
-
(0, vitest_1.expect)(queue.pop()).toBe(3);
|
|
21
|
-
});
|
|
22
|
-
(0, vitest_1.test)('should add elements to the queue with first element', () => {
|
|
23
|
-
let queue = new queue_1.Queue(1);
|
|
24
|
-
queue.add(2, 3);
|
|
25
|
-
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
26
|
-
(0, vitest_1.expect)(queue.pop()).toBe(2);
|
|
27
|
-
(0, vitest_1.expect)(queue.pop()).toBe(3);
|
|
28
|
-
});
|
|
29
|
-
(0, vitest_1.test)('peek should return the first element in the queue without removing it', () => {
|
|
30
|
-
let queue = new queue_1.Queue(1);
|
|
31
|
-
(0, vitest_1.expect)(queue.peek()).toBe(1);
|
|
32
|
-
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
(0, vitest_1.describe)('Duplicate', () => {
|
|
36
|
-
(0, vitest_1.test)('empty queue', () => {
|
|
37
|
-
let queue = new queue_1.Queue();
|
|
38
|
-
let duplicate = queue.duplicate();
|
|
39
|
-
(0, vitest_1.expect)(duplicate.pop()).toBe(undefined);
|
|
40
|
-
});
|
|
41
|
-
(0, vitest_1.test)('queue with elements', () => {
|
|
42
|
-
let queue = new queue_1.Queue(1);
|
|
43
|
-
queue.add(2, 3);
|
|
44
|
-
let duplicate = queue.duplicate();
|
|
45
|
-
(0, vitest_1.expect)(duplicate.pop()).toBe(1);
|
|
46
|
-
(0, vitest_1.expect)(duplicate.pop()).toBe(2);
|
|
47
|
-
(0, vitest_1.expect)(duplicate.pop()).toBe(3);
|
|
48
|
-
});
|
|
49
|
-
(0, vitest_1.test)('duplicate with deep copy', () => {
|
|
50
|
-
let queue = new queue_1.Queue({ value: 1 });
|
|
51
|
-
let duplicate = queue.duplicate(item => ({ value: item.value }));
|
|
52
|
-
(0, vitest_1.expect)(duplicate.peek()).toStrictEqual({ value: 1 });
|
|
53
|
-
(0, vitest_1.expect)(queue.peek()).toStrictEqual({ value: 1 });
|
|
54
|
-
(0, vitest_1.expect)(duplicate.peek() !== queue.peek()).toBeTruthy();
|
|
55
|
-
});
|
|
5
|
+
(0, vitest_1.describe)('Basic', () => {
|
|
6
|
+
(0, vitest_1.test)('should return undefined when queue is empty', () => {
|
|
7
|
+
const queue = new queue_1.Queue();
|
|
8
|
+
(0, vitest_1.expect)(queue.pop()).toBe(undefined);
|
|
56
9
|
});
|
|
10
|
+
(0, vitest_1.test)('should return false when queue is not empty', () => {
|
|
11
|
+
const queue = new queue_1.Queue(1);
|
|
12
|
+
(0, vitest_1.expect)(queue.isEmpty).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
(0, vitest_1.test)('should add elements to the queue', () => {
|
|
15
|
+
const queue = new queue_1.Queue();
|
|
16
|
+
queue.add(1, 2, 3);
|
|
17
|
+
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
18
|
+
(0, vitest_1.expect)(queue.pop()).toBe(2);
|
|
19
|
+
(0, vitest_1.expect)(queue.pop()).toBe(3);
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.test)('should add elements to the queue with first element', () => {
|
|
22
|
+
const queue = new queue_1.Queue(1);
|
|
23
|
+
queue.add(2, 3);
|
|
24
|
+
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
25
|
+
(0, vitest_1.expect)(queue.pop()).toBe(2);
|
|
26
|
+
(0, vitest_1.expect)(queue.pop()).toBe(3);
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.test)('peek should return the first element in the queue without removing it', () => {
|
|
29
|
+
const queue = new queue_1.Queue(1);
|
|
30
|
+
(0, vitest_1.expect)(queue.peek()).toBe(1);
|
|
31
|
+
(0, vitest_1.expect)(queue.pop()).toBe(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.describe)('Duplicate', () => {
|
|
35
|
+
(0, vitest_1.test)('empty queue', () => {
|
|
36
|
+
const queue = new queue_1.Queue();
|
|
37
|
+
const duplicate = queue.duplicate();
|
|
38
|
+
(0, vitest_1.expect)(duplicate.pop()).toBe(undefined);
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.test)('queue with elements', () => {
|
|
41
|
+
const queue = new queue_1.Queue(1);
|
|
42
|
+
queue.add(2, 3);
|
|
43
|
+
const duplicate = queue.duplicate();
|
|
44
|
+
(0, vitest_1.expect)(duplicate.pop()).toBe(1);
|
|
45
|
+
(0, vitest_1.expect)(duplicate.pop()).toBe(2);
|
|
46
|
+
(0, vitest_1.expect)(duplicate.pop()).toBe(3);
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.test)('duplicate with deep copy', () => {
|
|
49
|
+
const queue = new queue_1.Queue({ value: 1 });
|
|
50
|
+
const duplicate = queue.duplicate(item => ({ value: item.value }));
|
|
51
|
+
(0, vitest_1.expect)(duplicate.peek()).toStrictEqual({ value: 1 });
|
|
52
|
+
(0, vitest_1.expect)(queue.peek()).toStrictEqual({ value: 1 });
|
|
53
|
+
(0, vitest_1.expect)(duplicate.peek() !== queue.peek()).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
57
56
|
});
|
|
58
|
-
//# sourceMappingURL=queue.test.js.map
|
|
57
|
+
//# sourceMappingURL=queue.test.js.map
|
|
@@ -1,70 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const grid_1 = require("../../data-structures/grid/grid");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const vitest_1 = require('vitest');
|
|
3
|
+
const closest_available_space_helper_1 = require('./closest-available-space.helper');
|
|
4
|
+
const grid_1 = require('../../data-structures/grid/grid');
|
|
6
5
|
(0, vitest_1.describe)('findClosestAvailableSpace', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
(0, vitest_1.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
6
|
+
let grid;
|
|
7
|
+
(0, vitest_1.beforeEach)(() => {
|
|
8
|
+
grid = grid_1.Grid.createNew({ x: 10, y: 10 }, true);
|
|
9
|
+
});
|
|
10
|
+
(0, vitest_1.test)('should return no change vector if the location is available', () => {
|
|
11
|
+
const boundingBox = {
|
|
12
|
+
topLeft: { x: 50, y: 50 },
|
|
13
|
+
bottomRight: { x: 60, y: 60 }
|
|
14
|
+
};
|
|
15
|
+
(0, vitest_1.expect)(
|
|
16
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
17
|
+
).toEqual({ x: 0, y: 0 });
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.test)('should support object positions outside of the world size', () => {
|
|
20
|
+
let boundingBox = {
|
|
21
|
+
topLeft: { x: -5, y: -5 },
|
|
22
|
+
bottomRight: { x: 5, y: 5 }
|
|
23
|
+
};
|
|
24
|
+
(0, vitest_1.expect)(
|
|
25
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
26
|
+
).toEqual({ x: 5, y: 5 });
|
|
27
|
+
boundingBox = {
|
|
28
|
+
topLeft: { x: -5, y: -5 },
|
|
29
|
+
bottomRight: { x: 15, y: 15 }
|
|
30
|
+
};
|
|
31
|
+
(0, vitest_1.expect)(
|
|
32
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
33
|
+
).toEqual({ x: 5, y: 5 });
|
|
34
|
+
boundingBox = {
|
|
35
|
+
topLeft: { x: 95, y: 95 },
|
|
36
|
+
bottomRight: { x: 105, y: 105 }
|
|
37
|
+
};
|
|
38
|
+
(0, vitest_1.expect)(
|
|
39
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
40
|
+
).toEqual({ x: -5, y: -5 });
|
|
41
|
+
boundingBox = {
|
|
42
|
+
topLeft: { x: 85, y: 85 },
|
|
43
|
+
bottomRight: { x: 105, y: 105 }
|
|
44
|
+
};
|
|
45
|
+
(0, vitest_1.expect)(
|
|
46
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
47
|
+
).toEqual({ x: -5, y: -5 });
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.test)('should find the no change vector space next to an existing object', () => {
|
|
50
|
+
grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } }, false);
|
|
51
|
+
const boundingBox = {
|
|
52
|
+
topLeft: { x: 10, y: 10 },
|
|
53
|
+
bottomRight: { x: 20, y: 20 }
|
|
54
|
+
};
|
|
55
|
+
(0, vitest_1.expect)(
|
|
56
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
57
|
+
).toEqual({ x: 0, y: 0 });
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.test)('should find the closest available space if trying to spawn in occupied space', () => {
|
|
60
|
+
grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } }, false);
|
|
61
|
+
const boundingBox = {
|
|
62
|
+
topLeft: { x: 5, y: 5 },
|
|
63
|
+
bottomRight: { x: 15, y: 15 }
|
|
64
|
+
};
|
|
65
|
+
(0, vitest_1.expect)(
|
|
66
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
67
|
+
).toEqual({ x: -5, y: 15 });
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.test)('should find the closest available space if trying to spawn in crowded space', () => {
|
|
70
|
+
// Crowded space
|
|
71
|
+
// 0 1 2 3 4 5 6 7 8 9
|
|
72
|
+
// 0 □ 1 1 1 2 2 □ □ □ □
|
|
73
|
+
// 1 □ 1 1 1 2 2 □ □ □ □
|
|
74
|
+
// 2 □ 1 1 1 2 2 □ □ □ □
|
|
75
|
+
// 3 3 3 3 ■ ■ ■ □ □ □ □
|
|
76
|
+
// 4 □ □ □ ■ ■ ■ □ □ □ □
|
|
77
|
+
// 5 □ □ 4 ■ ■ ■ 6 6 6 □
|
|
78
|
+
// 6 □ □ 4 5 5 5 □ □ □ □
|
|
79
|
+
grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 3, y: 2 } }, false); // 1
|
|
80
|
+
grid.setArea({ topLeft: { x: 4, y: 0 }, bottomRight: { x: 5, y: 2 } }, false); // 2
|
|
81
|
+
grid.setArea({ topLeft: { x: 0, y: 3 }, bottomRight: { x: 1, y: 3 } }, false); // 3
|
|
82
|
+
grid.setArea({ topLeft: { x: 2, y: 5 }, bottomRight: { x: 2, y: 6 } }, false); // 4
|
|
83
|
+
grid.setArea({ topLeft: { x: 3, y: 6 }, bottomRight: { x: 5, y: 6 } }, false); // 5
|
|
84
|
+
grid.setArea({ topLeft: { x: 6, y: 5 }, bottomRight: { x: 8, y: 5 } }, false); // 6
|
|
85
|
+
const boundingBox = {
|
|
86
|
+
topLeft: { x: 10, y: 20 },
|
|
87
|
+
bottomRight: { x: 40, y: 50 }
|
|
88
|
+
};
|
|
89
|
+
(0, vitest_1.expect)(
|
|
90
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
91
|
+
).toEqual({ x: 20, y: 10 });
|
|
92
|
+
});
|
|
93
|
+
(0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 1', () => {
|
|
94
|
+
grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
|
|
95
|
+
const boundingBox = {
|
|
96
|
+
topLeft: { x: 4, y: 2 },
|
|
97
|
+
bottomRight: { x: 12, y: 20 }
|
|
98
|
+
};
|
|
99
|
+
(0, vitest_1.expect)(
|
|
100
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
101
|
+
).toEqual({ x: -3, y: -1 });
|
|
102
|
+
});
|
|
103
|
+
(0, vitest_1.test)('should not fooled by initial position occupying more space in grid and find narrower gap 2', () => {
|
|
104
|
+
grid.setArea({ topLeft: { x: 1, y: 0 }, bottomRight: { x: 4, y: 3 } }, false);
|
|
105
|
+
const boundingBox = {
|
|
106
|
+
topLeft: { x: -6, y: -8 },
|
|
107
|
+
bottomRight: { x: 2, y: 10 }
|
|
108
|
+
};
|
|
109
|
+
(0, vitest_1.expect)(
|
|
110
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
111
|
+
).toEqual({ x: 7, y: 9 });
|
|
112
|
+
});
|
|
113
|
+
(0, vitest_1.test)('should return undefined if there is no available space', () => {
|
|
114
|
+
grid.setArea({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 9, y: 9 } }, false);
|
|
115
|
+
const boundingBox = {
|
|
116
|
+
topLeft: { x: 0, y: 0 },
|
|
117
|
+
bottomRight: { x: 10, y: 10 }
|
|
118
|
+
};
|
|
119
|
+
(0, vitest_1.expect)(
|
|
120
|
+
closest_available_space_helper_1.ClosestAvailableSpaceHelper.findByConvertingGridSpace(grid, boundingBox, 10)
|
|
121
|
+
).toBeUndefined();
|
|
122
|
+
});
|
|
69
123
|
});
|
|
70
|
-
//# sourceMappingURL=closest-available-space.helper.spec.js.map
|
|
124
|
+
//# sourceMappingURL=closest-available-space.helper.spec.js.map
|
|
@@ -1,146 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const path_finder_1 = require("./path-finder");
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const vitest_1 = require('vitest');
|
|
3
|
+
const grid_1 = require('../../data-structures/grid/grid');
|
|
4
|
+
const path_finder_1 = require('./path-finder');
|
|
6
5
|
(0, vitest_1.describe)('PATH_FINDER', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
(0, vitest_1.test)('basic 1', () => {
|
|
7
|
+
const grid = grid_1.Grid.createByValues([[true]]);
|
|
8
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
|
|
9
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
10
|
+
directPathAvailable: true,
|
|
11
|
+
path: [{ x: 0, y: 0 }]
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
});
|
|
14
|
+
(0, vitest_1.test)('basic 2', () => {
|
|
15
|
+
const grid = grid_1.Grid.createByValues([[false]]);
|
|
16
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 0, y: 0 }, { includeDiagonals: true });
|
|
17
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
18
|
+
directPathAvailable: true,
|
|
19
|
+
path: [{ x: 0, y: 0 }]
|
|
16
20
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.test)('should give the shortest path without diagonals', () => {
|
|
23
|
+
const grid = grid_1.Grid.createByValues([
|
|
24
|
+
[true, true, true, true],
|
|
25
|
+
[true, false, false, true],
|
|
26
|
+
[true, false, false, true],
|
|
27
|
+
[true, false, false, true]
|
|
28
|
+
]);
|
|
29
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: false });
|
|
30
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
31
|
+
directPathAvailable: true,
|
|
32
|
+
path: [
|
|
33
|
+
{ x: 0, y: 0 },
|
|
34
|
+
{ x: 1, y: 0 },
|
|
35
|
+
{ x: 2, y: 0 },
|
|
36
|
+
{ x: 3, y: 0 },
|
|
37
|
+
{ x: 3, y: 1 },
|
|
38
|
+
{ x: 3, y: 2 },
|
|
39
|
+
{ x: 3, y: 3 }
|
|
40
|
+
]
|
|
37
41
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
});
|
|
43
|
+
(0, vitest_1.test)('should give the shortest path 1', () => {
|
|
44
|
+
const grid = grid_1.Grid.createByValues([
|
|
45
|
+
[true, true, true, true],
|
|
46
|
+
[true, false, false, true],
|
|
47
|
+
[true, false, false, true],
|
|
48
|
+
[true, false, false, true]
|
|
49
|
+
]);
|
|
50
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
|
|
51
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
52
|
+
directPathAvailable: true,
|
|
53
|
+
path: [
|
|
54
|
+
{ x: 0, y: 0 },
|
|
55
|
+
{ x: 1, y: 0 },
|
|
56
|
+
{ x: 2, y: 0 },
|
|
57
|
+
{ x: 3, y: 1 },
|
|
58
|
+
{ x: 3, y: 2 },
|
|
59
|
+
{ x: 3, y: 3 }
|
|
60
|
+
]
|
|
57
61
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.test)('should give the shortest path 2', () => {
|
|
64
|
+
const grid = grid_1.Grid.createByValues([
|
|
65
|
+
[true, true, true, false],
|
|
66
|
+
[true, false, false, false],
|
|
67
|
+
[true, true, false, true],
|
|
68
|
+
[true, false, true, true]
|
|
69
|
+
]);
|
|
70
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
|
|
71
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
72
|
+
directPathAvailable: true,
|
|
73
|
+
path: [
|
|
74
|
+
{ x: 0, y: 0 },
|
|
75
|
+
{ x: 0, y: 1 },
|
|
76
|
+
{ x: 1, y: 2 },
|
|
77
|
+
{ x: 2, y: 3 },
|
|
78
|
+
{ x: 3, y: 3 }
|
|
79
|
+
]
|
|
76
80
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
});
|
|
82
|
+
(0, vitest_1.test)('should give the shortest path 3', () => {
|
|
83
|
+
const grid = grid_1.Grid.createByValues([
|
|
84
|
+
[true, false, false, true, false],
|
|
85
|
+
[true, false, true, false, true],
|
|
86
|
+
[true, false, true, false, true],
|
|
87
|
+
[false, true, false, false, true]
|
|
88
|
+
]);
|
|
89
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 4, y: 3 }, { includeDiagonals: true });
|
|
90
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
91
|
+
directPathAvailable: true,
|
|
92
|
+
path: [
|
|
93
|
+
{ x: 0, y: 0 },
|
|
94
|
+
{ x: 0, y: 1 },
|
|
95
|
+
{ x: 0, y: 2 },
|
|
96
|
+
{ x: 1, y: 3 },
|
|
97
|
+
{ x: 2, y: 2 },
|
|
98
|
+
{ x: 2, y: 1 },
|
|
99
|
+
{ x: 3, y: 0 },
|
|
100
|
+
{ x: 4, y: 1 },
|
|
101
|
+
{ x: 4, y: 2 },
|
|
102
|
+
{ x: 4, y: 3 }
|
|
103
|
+
]
|
|
100
104
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
105
|
+
});
|
|
106
|
+
(0, vitest_1.test)('should give the shortest path backwards 3', () => {
|
|
107
|
+
const grid = grid_1.Grid.createByValues([
|
|
108
|
+
[true, false, false, true, false],
|
|
109
|
+
[true, false, true, false, true],
|
|
110
|
+
[true, false, true, false, true],
|
|
111
|
+
[false, true, false, false, true]
|
|
112
|
+
]);
|
|
113
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 4, y: 3 }, { x: 0, y: 0 }, { includeDiagonals: true });
|
|
114
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
115
|
+
directPathAvailable: true,
|
|
116
|
+
path: [
|
|
117
|
+
{ x: 4, y: 3 },
|
|
118
|
+
{ x: 4, y: 2 },
|
|
119
|
+
{ x: 4, y: 1 },
|
|
120
|
+
{ x: 3, y: 0 },
|
|
121
|
+
{ x: 2, y: 1 },
|
|
122
|
+
{ x: 2, y: 2 },
|
|
123
|
+
{ x: 1, y: 3 },
|
|
124
|
+
{ x: 0, y: 2 },
|
|
125
|
+
{ x: 0, y: 1 },
|
|
126
|
+
{ x: 0, y: 0 }
|
|
127
|
+
]
|
|
124
128
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.test)('should give the shortest path to closest position', () => {
|
|
131
|
+
const grid = grid_1.Grid.createByValues([
|
|
132
|
+
[true, true, true, false],
|
|
133
|
+
[true, false, false, false],
|
|
134
|
+
[true, false, false, false],
|
|
135
|
+
[true, true, false, true]
|
|
136
|
+
]);
|
|
137
|
+
const result = path_finder_1.PathFinder.findPath(grid, { x: 0, y: 0 }, { x: 3, y: 3 }, { includeDiagonals: true });
|
|
138
|
+
(0, vitest_1.expect)(result).toEqual({
|
|
139
|
+
directPathAvailable: false,
|
|
140
|
+
path: [
|
|
141
|
+
{ x: 0, y: 0 },
|
|
142
|
+
{ x: 0, y: 1 },
|
|
143
|
+
{ x: 0, y: 2 },
|
|
144
|
+
{ x: 1, y: 3 }
|
|
145
|
+
]
|
|
142
146
|
});
|
|
143
|
-
|
|
147
|
+
});
|
|
148
|
+
/*
|
|
144
149
|
test('stress test', () => {
|
|
145
150
|
let size = 800;
|
|
146
151
|
let centerPos = { x: Math.floor(size / 2), y: Math.floor(size / 2) };
|
|
@@ -161,4 +166,4 @@ const path_finder_1 = require("./path-finder");
|
|
|
161
166
|
console.info(end.getTime() - start.getTime());
|
|
162
167
|
});*/
|
|
163
168
|
});
|
|
164
|
-
//# sourceMappingURL=path-finder.spec.js.map
|
|
169
|
+
//# sourceMappingURL=path-finder.spec.js.map
|