From 281cbbeb897cf148b2a4c9e8d23f79070338109d Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sat, 15 Mar 2025 13:41:56 -0700 Subject: [PATCH] Remove path cache (#257) --- src/core/pathfinding/PathFinding.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/core/pathfinding/PathFinding.ts b/src/core/pathfinding/PathFinding.ts index 25ad86c29..0e1a82ff8 100644 --- a/src/core/pathfinding/PathFinding.ts +++ b/src/core/pathfinding/PathFinding.ts @@ -12,8 +12,6 @@ export class PathFinder { private aStar: AStar; private computeFinished = true; - private pathCache: Map = new Map(); - private constructor( private game: Game, private newAStar: (curr: TileRef, dst: TileRef) => AStar, @@ -57,15 +55,6 @@ export class PathFinder { return { type: PathFindResultType.Completed, tile: curr }; } - // make key the same between port a -> b and b -> a - const key = curr < dst ? curr * 1_000_000 + dst : dst * 1_000_000 + curr; - - // get the cached path - if (this.pathCache.has(key)) { - this.path = this.pathCache.get(key)!; - return { type: PathFindResultType.NextTile, tile: this.path.shift() }; - } - if (this.computeFinished) { if (this.shouldRecompute(curr, dst)) { this.curr = curr; @@ -86,8 +75,6 @@ export class PathFinder { // Remove the start tile this.path.shift(); - // save the path in the cache - this.pathCache.set(key, [...this.path]); return this.nextTile(curr, dst); case PathFindResultType.Pending: return { type: PathFindResultType.Pending };