From 36c9d67729f214059a8c61ff74dcedde5d82c1ae Mon Sep 17 00:00:00 2001 From: evanpelle Date: Tue, 12 Nov 2024 18:34:39 -0800 Subject: [PATCH] pathfinding perf improvement --- src/core/PathFinding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/PathFinding.ts b/src/core/PathFinding.ts index e3a871ea0..b7bb778c9 100644 --- a/src/core/PathFinding.ts +++ b/src/core/PathFinding.ts @@ -41,7 +41,7 @@ export class AStar { for (const neighbor of this.current.neighborsWrapped()) { if (neighbor != this.dst && neighbor.isLand()) continue; // Skip non-water tiles - const tentativeGScore = this.gScore.get(this.current)! + 9 - Math.max(1, Math.min(neighbor.magnitude(), 8)); + const tentativeGScore = this.gScore.get(this.current)! + 3 - Math.max(1, Math.min(neighbor.magnitude() / 4, 2)); if (!this.gScore.has(neighbor) || tentativeGScore < this.gScore.get(neighbor)!) { this.cameFrom.set(neighbor, this.current);