Skip to content

Commit

Permalink
Merge branch 'master' into feat/new-shop-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Jameskmonger committed Dec 22, 2024
2 parents dd642ae + e9a8083 commit 4eeaac4
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions modules/@creature-chess/battle/src/pathfinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export function sortPaths(
{ x: -forwardY, y: 0 }, // Left
];

// Function to calculate the priority index of a step
const getPriority = (step: TileCoordinates) => {
const dx = step.x - startPos.x;
const dy = step.y - startPos.y;
Expand Down Expand Up @@ -144,8 +143,6 @@ export class Pathfinder {

const path = astar.search(this.graph, startGraphItem, endGraphItem);

console.log(start, end, path);

if (path.length === 0) {
return null;
}
Expand All @@ -158,21 +155,11 @@ export class Pathfinder {
}

private setWeights(board: BoardState) {
let x = 0;
let y = 0;
for (const [position, pieceId] of Object.entries(board.piecePositions)) {
[x, y] = position.split(",").map((p) => parseInt(p, 10));

if (pieceId) {
this.graph.grid[x][y].weight = 0;
}
}
}

private resetWeights() {
for (let x = 0; x < this.size.width; x++) {
for (let y = 0; y < this.size.height; y++) {
this.graph.grid[x][y].weight = 1;
this.graph.grid[x][y].weight = board.piecePositions[`${x},${y}`]
? 0
: 1;
}
}
}
Expand Down

0 comments on commit 4eeaac4

Please sign in to comment.