Try with branch caching again

This commit is contained in:
2024-12-18 23:21:58 +00:00
parent f79cf1a347
commit 2dc097383c
2 changed files with 67 additions and 43 deletions

View File

@@ -106,8 +106,6 @@ for (let y = 1; y < height - 1; y++) {
let fastest: number|null = null;
const scoreCache: { [key: string]: [number, Coord, Dir] } = {};
const branchCache: { [key: string]: number } = {};
const scores: Array<[number, Array<string>]> = [];
@@ -125,9 +123,6 @@ function getScoresAfterPosition(pos: Coord, dir: Dir, currentScore = 0, path: Ar
} else {
branchCache[cacheKey] = currentScore;
}
if (lastBranch) {
scoreCache[`${lastBranch[1].x},${lastBranch[1].y}`] = [currentScore - lastBranch[0], pos, dir];
}
lastBranch = [currentScore, pos];
}
[dir, nextDir(dir), prevDir(dir)].forEach((newDir, i) => {