Improve comment

This commit is contained in:
Manuel Vögele
2022-01-28 22:16:22 +01:00
parent 4c006d34c9
commit 6e0571c565
+1 -1
View File
@@ -61,7 +61,7 @@ function calculate_path(from, to) {
if (previousNodes.has(neighborNode)) if (previousNodes.has(neighborNode))
continue; continue;
// TODO We currently assume a cost of one for all transitions. Change this for 5/10/5 or difficult terrain support // TODO We currently assume a cost of one for all transitions. Change this for 5/10/5 or difficult terrain support
// We charge an extra 0.0001 for diagonals // We charge an extra 0.0001 for diagonals to unnecessary diagonal steps
const isDiagonal = currentNode.node.x !== neighborNode.x && currentNode.node.y !== neighborNode.y; const isDiagonal = currentNode.node.x !== neighborNode.x && currentNode.node.y !== neighborNode.y;
const edgeCost = isDiagonal ? 1.0001 : 1; const edgeCost = isDiagonal ? 1.0001 : 1;
const neighbor = {node: neighborNode, cost: currentNode.cost + edgeCost, estimated: currentNode.cost + edgeCost + estimate_cost(neighborNode, from), previous: currentNode}; const neighbor = {node: neighborNode, cost: currentNode.cost + edgeCost, estimated: currentNode.cost + edgeCost + estimate_cost(neighborNode, from), previous: currentNode};