microboard-temp 0.5.98 → 0.5.100
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/cjs/browser.js +9 -9
- package/dist/cjs/index.js +9 -9
- package/dist/cjs/node.js +9 -9
- package/dist/esm/browser.js +9 -9
- package/dist/esm/index.js +9 -9
- package/dist/esm/node.js +9 -9
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36682,7 +36682,7 @@ function getDirection(from, to) {
|
|
|
36682
36682
|
return null;
|
|
36683
36683
|
}
|
|
36684
36684
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
36685
|
-
const TURN_PENALTY =
|
|
36685
|
+
const TURN_PENALTY = 5000;
|
|
36686
36686
|
const dirMap = {
|
|
36687
36687
|
top: "vertical",
|
|
36688
36688
|
bottom: "vertical",
|
|
@@ -36703,7 +36703,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
36703
36703
|
return 0;
|
|
36704
36704
|
}
|
|
36705
36705
|
function heuristic(start, end) {
|
|
36706
|
-
return Math.abs(start.
|
|
36706
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
36707
36707
|
}
|
|
36708
36708
|
function getNeighbors(node2, grid, obstacles) {
|
|
36709
36709
|
const neighbors = [];
|
|
@@ -36809,8 +36809,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36809
36809
|
const startNode = {
|
|
36810
36810
|
point: start,
|
|
36811
36811
|
costSoFar: 0,
|
|
36812
|
-
heuristic: heuristic({ point: start
|
|
36813
|
-
toFinish: heuristic({ point: start
|
|
36812
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
36813
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
36814
36814
|
xGrid: startRowIndex,
|
|
36815
36815
|
yGrid: startPointIndex
|
|
36816
36816
|
};
|
|
@@ -36821,8 +36821,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36821
36821
|
const current = openSet.shift();
|
|
36822
36822
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
36823
36823
|
if (current.point.barelyEqual(end)) {
|
|
36824
|
-
|
|
36825
|
-
return path2;
|
|
36824
|
+
return reconstructPath(current);
|
|
36826
36825
|
}
|
|
36827
36826
|
closedSet.add(currentKey);
|
|
36828
36827
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -36832,17 +36831,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36832
36831
|
continue;
|
|
36833
36832
|
}
|
|
36834
36833
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
36834
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
36835
36835
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
36836
|
-
const tentativeCost = current.costSoFar +
|
|
36836
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
36837
36837
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
36838
36838
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
36839
36839
|
if (existingNodeInOpenSet) {
|
|
36840
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
36840
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
36841
36841
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
36842
36842
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
36843
36843
|
existingNodeInOpenSet.parent = current;
|
|
36844
36844
|
} else {
|
|
36845
|
-
neighbor.costSoFar = tentativeCost
|
|
36845
|
+
neighbor.costSoFar = tentativeCost;
|
|
36846
36846
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
36847
36847
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
36848
36848
|
openSet.push(neighbor);
|
package/dist/cjs/index.js
CHANGED
|
@@ -36682,7 +36682,7 @@ function getDirection(from, to) {
|
|
|
36682
36682
|
return null;
|
|
36683
36683
|
}
|
|
36684
36684
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
36685
|
-
const TURN_PENALTY =
|
|
36685
|
+
const TURN_PENALTY = 5000;
|
|
36686
36686
|
const dirMap = {
|
|
36687
36687
|
top: "vertical",
|
|
36688
36688
|
bottom: "vertical",
|
|
@@ -36703,7 +36703,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
36703
36703
|
return 0;
|
|
36704
36704
|
}
|
|
36705
36705
|
function heuristic(start, end) {
|
|
36706
|
-
return Math.abs(start.
|
|
36706
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
36707
36707
|
}
|
|
36708
36708
|
function getNeighbors(node2, grid, obstacles) {
|
|
36709
36709
|
const neighbors = [];
|
|
@@ -36809,8 +36809,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36809
36809
|
const startNode = {
|
|
36810
36810
|
point: start,
|
|
36811
36811
|
costSoFar: 0,
|
|
36812
|
-
heuristic: heuristic({ point: start
|
|
36813
|
-
toFinish: heuristic({ point: start
|
|
36812
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
36813
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
36814
36814
|
xGrid: startRowIndex,
|
|
36815
36815
|
yGrid: startPointIndex
|
|
36816
36816
|
};
|
|
@@ -36821,8 +36821,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36821
36821
|
const current = openSet.shift();
|
|
36822
36822
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
36823
36823
|
if (current.point.barelyEqual(end)) {
|
|
36824
|
-
|
|
36825
|
-
return path2;
|
|
36824
|
+
return reconstructPath(current);
|
|
36826
36825
|
}
|
|
36827
36826
|
closedSet.add(currentKey);
|
|
36828
36827
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -36832,17 +36831,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36832
36831
|
continue;
|
|
36833
36832
|
}
|
|
36834
36833
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
36834
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
36835
36835
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
36836
|
-
const tentativeCost = current.costSoFar +
|
|
36836
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
36837
36837
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
36838
36838
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
36839
36839
|
if (existingNodeInOpenSet) {
|
|
36840
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
36840
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
36841
36841
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
36842
36842
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
36843
36843
|
existingNodeInOpenSet.parent = current;
|
|
36844
36844
|
} else {
|
|
36845
|
-
neighbor.costSoFar = tentativeCost
|
|
36845
|
+
neighbor.costSoFar = tentativeCost;
|
|
36846
36846
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
36847
36847
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
36848
36848
|
openSet.push(neighbor);
|
package/dist/cjs/node.js
CHANGED
|
@@ -39155,7 +39155,7 @@ function getDirection(from, to) {
|
|
|
39155
39155
|
return null;
|
|
39156
39156
|
}
|
|
39157
39157
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
39158
|
-
const TURN_PENALTY =
|
|
39158
|
+
const TURN_PENALTY = 5000;
|
|
39159
39159
|
const dirMap = {
|
|
39160
39160
|
top: "vertical",
|
|
39161
39161
|
bottom: "vertical",
|
|
@@ -39176,7 +39176,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
39176
39176
|
return 0;
|
|
39177
39177
|
}
|
|
39178
39178
|
function heuristic(start, end) {
|
|
39179
|
-
return Math.abs(start.
|
|
39179
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
39180
39180
|
}
|
|
39181
39181
|
function getNeighbors(node2, grid, obstacles) {
|
|
39182
39182
|
const neighbors = [];
|
|
@@ -39282,8 +39282,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39282
39282
|
const startNode = {
|
|
39283
39283
|
point: start,
|
|
39284
39284
|
costSoFar: 0,
|
|
39285
|
-
heuristic: heuristic({ point: start
|
|
39286
|
-
toFinish: heuristic({ point: start
|
|
39285
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
39286
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
39287
39287
|
xGrid: startRowIndex,
|
|
39288
39288
|
yGrid: startPointIndex
|
|
39289
39289
|
};
|
|
@@ -39294,8 +39294,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39294
39294
|
const current = openSet.shift();
|
|
39295
39295
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
39296
39296
|
if (current.point.barelyEqual(end)) {
|
|
39297
|
-
|
|
39298
|
-
return path2;
|
|
39297
|
+
return reconstructPath(current);
|
|
39299
39298
|
}
|
|
39300
39299
|
closedSet.add(currentKey);
|
|
39301
39300
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -39305,17 +39304,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39305
39304
|
continue;
|
|
39306
39305
|
}
|
|
39307
39306
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
39307
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
39308
39308
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
39309
|
-
const tentativeCost = current.costSoFar +
|
|
39309
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
39310
39310
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
39311
39311
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
39312
39312
|
if (existingNodeInOpenSet) {
|
|
39313
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
39313
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
39314
39314
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
39315
39315
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
39316
39316
|
existingNodeInOpenSet.parent = current;
|
|
39317
39317
|
} else {
|
|
39318
|
-
neighbor.costSoFar = tentativeCost
|
|
39318
|
+
neighbor.costSoFar = tentativeCost;
|
|
39319
39319
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
39320
39320
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
39321
39321
|
openSet.push(neighbor);
|
package/dist/esm/browser.js
CHANGED
|
@@ -36527,7 +36527,7 @@ function getDirection(from, to) {
|
|
|
36527
36527
|
return null;
|
|
36528
36528
|
}
|
|
36529
36529
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
36530
|
-
const TURN_PENALTY =
|
|
36530
|
+
const TURN_PENALTY = 5000;
|
|
36531
36531
|
const dirMap = {
|
|
36532
36532
|
top: "vertical",
|
|
36533
36533
|
bottom: "vertical",
|
|
@@ -36548,7 +36548,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
36548
36548
|
return 0;
|
|
36549
36549
|
}
|
|
36550
36550
|
function heuristic(start, end) {
|
|
36551
|
-
return Math.abs(start.
|
|
36551
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
36552
36552
|
}
|
|
36553
36553
|
function getNeighbors(node2, grid, obstacles) {
|
|
36554
36554
|
const neighbors = [];
|
|
@@ -36654,8 +36654,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36654
36654
|
const startNode = {
|
|
36655
36655
|
point: start,
|
|
36656
36656
|
costSoFar: 0,
|
|
36657
|
-
heuristic: heuristic({ point: start
|
|
36658
|
-
toFinish: heuristic({ point: start
|
|
36657
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
36658
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
36659
36659
|
xGrid: startRowIndex,
|
|
36660
36660
|
yGrid: startPointIndex
|
|
36661
36661
|
};
|
|
@@ -36666,8 +36666,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36666
36666
|
const current = openSet.shift();
|
|
36667
36667
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
36668
36668
|
if (current.point.barelyEqual(end)) {
|
|
36669
|
-
|
|
36670
|
-
return path2;
|
|
36669
|
+
return reconstructPath(current);
|
|
36671
36670
|
}
|
|
36672
36671
|
closedSet.add(currentKey);
|
|
36673
36672
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -36677,17 +36676,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36677
36676
|
continue;
|
|
36678
36677
|
}
|
|
36679
36678
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
36679
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
36680
36680
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
36681
|
-
const tentativeCost = current.costSoFar +
|
|
36681
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
36682
36682
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
36683
36683
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
36684
36684
|
if (existingNodeInOpenSet) {
|
|
36685
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
36685
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
36686
36686
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
36687
36687
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
36688
36688
|
existingNodeInOpenSet.parent = current;
|
|
36689
36689
|
} else {
|
|
36690
|
-
neighbor.costSoFar = tentativeCost
|
|
36690
|
+
neighbor.costSoFar = tentativeCost;
|
|
36691
36691
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
36692
36692
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
36693
36693
|
openSet.push(neighbor);
|
package/dist/esm/index.js
CHANGED
|
@@ -36520,7 +36520,7 @@ function getDirection(from, to) {
|
|
|
36520
36520
|
return null;
|
|
36521
36521
|
}
|
|
36522
36522
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
36523
|
-
const TURN_PENALTY =
|
|
36523
|
+
const TURN_PENALTY = 5000;
|
|
36524
36524
|
const dirMap = {
|
|
36525
36525
|
top: "vertical",
|
|
36526
36526
|
bottom: "vertical",
|
|
@@ -36541,7 +36541,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
36541
36541
|
return 0;
|
|
36542
36542
|
}
|
|
36543
36543
|
function heuristic(start, end) {
|
|
36544
|
-
return Math.abs(start.
|
|
36544
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
36545
36545
|
}
|
|
36546
36546
|
function getNeighbors(node2, grid, obstacles) {
|
|
36547
36547
|
const neighbors = [];
|
|
@@ -36647,8 +36647,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36647
36647
|
const startNode = {
|
|
36648
36648
|
point: start,
|
|
36649
36649
|
costSoFar: 0,
|
|
36650
|
-
heuristic: heuristic({ point: start
|
|
36651
|
-
toFinish: heuristic({ point: start
|
|
36650
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
36651
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
36652
36652
|
xGrid: startRowIndex,
|
|
36653
36653
|
yGrid: startPointIndex
|
|
36654
36654
|
};
|
|
@@ -36659,8 +36659,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36659
36659
|
const current = openSet.shift();
|
|
36660
36660
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
36661
36661
|
if (current.point.barelyEqual(end)) {
|
|
36662
|
-
|
|
36663
|
-
return path2;
|
|
36662
|
+
return reconstructPath(current);
|
|
36664
36663
|
}
|
|
36665
36664
|
closedSet.add(currentKey);
|
|
36666
36665
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -36670,17 +36669,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
36670
36669
|
continue;
|
|
36671
36670
|
}
|
|
36672
36671
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
36672
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
36673
36673
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
36674
|
-
const tentativeCost = current.costSoFar +
|
|
36674
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
36675
36675
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
36676
36676
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
36677
36677
|
if (existingNodeInOpenSet) {
|
|
36678
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
36678
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
36679
36679
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
36680
36680
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
36681
36681
|
existingNodeInOpenSet.parent = current;
|
|
36682
36682
|
} else {
|
|
36683
|
-
neighbor.costSoFar = tentativeCost
|
|
36683
|
+
neighbor.costSoFar = tentativeCost;
|
|
36684
36684
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
36685
36685
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
36686
36686
|
openSet.push(neighbor);
|
package/dist/esm/node.js
CHANGED
|
@@ -38988,7 +38988,7 @@ function getDirection(from, to) {
|
|
|
38988
38988
|
return null;
|
|
38989
38989
|
}
|
|
38990
38990
|
function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
38991
|
-
const TURN_PENALTY =
|
|
38991
|
+
const TURN_PENALTY = 5000;
|
|
38992
38992
|
const dirMap = {
|
|
38993
38993
|
top: "vertical",
|
|
38994
38994
|
bottom: "vertical",
|
|
@@ -39009,7 +39009,7 @@ function isChangingDirection(current, neighbor, newStart, newEnd) {
|
|
|
39009
39009
|
return 0;
|
|
39010
39010
|
}
|
|
39011
39011
|
function heuristic(start, end) {
|
|
39012
|
-
return Math.abs(start.
|
|
39012
|
+
return Math.abs(start.point.x - end.point.x) + Math.abs(start.point.y - end.point.y);
|
|
39013
39013
|
}
|
|
39014
39014
|
function getNeighbors(node2, grid, obstacles) {
|
|
39015
39015
|
const neighbors = [];
|
|
@@ -39115,8 +39115,8 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39115
39115
|
const startNode = {
|
|
39116
39116
|
point: start,
|
|
39117
39117
|
costSoFar: 0,
|
|
39118
|
-
heuristic: heuristic({ point: start
|
|
39119
|
-
toFinish: heuristic({ point: start
|
|
39118
|
+
heuristic: heuristic({ point: start }, endNode),
|
|
39119
|
+
toFinish: heuristic({ point: start }, endNode),
|
|
39120
39120
|
xGrid: startRowIndex,
|
|
39121
39121
|
yGrid: startPointIndex
|
|
39122
39122
|
};
|
|
@@ -39127,8 +39127,7 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39127
39127
|
const current = openSet.shift();
|
|
39128
39128
|
const currentKey = `${current.point.x},${current.point.y}`;
|
|
39129
39129
|
if (current.point.barelyEqual(end)) {
|
|
39130
|
-
|
|
39131
|
-
return path2;
|
|
39130
|
+
return reconstructPath(current);
|
|
39132
39131
|
}
|
|
39133
39132
|
closedSet.add(currentKey);
|
|
39134
39133
|
const neighbors = getNeighbors(current, grid, obstacles);
|
|
@@ -39138,17 +39137,18 @@ function findPath(start, end, grid, obstacles, existingPath, newStart, newEnd) {
|
|
|
39138
39137
|
continue;
|
|
39139
39138
|
}
|
|
39140
39139
|
const extraCost = isChangingDirection(current, neighbor, newStart, newEnd);
|
|
39140
|
+
const movementCost = Math.abs(current.point.x - neighbor.point.x) + Math.abs(current.point.y - neighbor.point.y);
|
|
39141
39141
|
const pathOverlapCost = existingPath.has(neighborKey) ? 1000 : 0;
|
|
39142
|
-
const tentativeCost = current.costSoFar +
|
|
39142
|
+
const tentativeCost = current.costSoFar + movementCost + pathOverlapCost + extraCost;
|
|
39143
39143
|
let existingNodeInOpenSet = openSet.find((node2) => node2.point.barelyEqual(neighbor.point));
|
|
39144
39144
|
if (!existingNodeInOpenSet || tentativeCost < existingNodeInOpenSet.costSoFar) {
|
|
39145
39145
|
if (existingNodeInOpenSet) {
|
|
39146
|
-
existingNodeInOpenSet.costSoFar = tentativeCost
|
|
39146
|
+
existingNodeInOpenSet.costSoFar = tentativeCost;
|
|
39147
39147
|
existingNodeInOpenSet.heuristic = heuristic(neighbor, endNode);
|
|
39148
39148
|
existingNodeInOpenSet.toFinish = existingNodeInOpenSet.costSoFar + existingNodeInOpenSet.heuristic;
|
|
39149
39149
|
existingNodeInOpenSet.parent = current;
|
|
39150
39150
|
} else {
|
|
39151
|
-
neighbor.costSoFar = tentativeCost
|
|
39151
|
+
neighbor.costSoFar = tentativeCost;
|
|
39152
39152
|
neighbor.heuristic = heuristic(neighbor, endNode);
|
|
39153
39153
|
neighbor.toFinish = neighbor.costSoFar + neighbor.heuristic;
|
|
39154
39154
|
openSet.push(neighbor);
|