Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion preview/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var findPath = (startPoint, endPoint, grid, config) => {
const orthogonalCostMultiplier = config.orthogonalCostMultiplier ?? 1;
const maxJumpCost = config.maxJumpCost ?? 5;
const maxIterations = config.maxIterations ?? 99999;
const fearOfJump = config.fearOfJump ?? 0.24;
const index = (point) => {
return point.y * grid.height + point.x;
};
Expand All @@ -100,7 +101,7 @@ var findPath = (startPoint, endPoint, grid, config) => {
const srcHeight = grid.getHeightAt(src) ?? NOT_REACHED_COST;
const dstHeight = grid.getHeightAt(dst) ?? NOT_REACHED_COST;
if (Math.abs(srcHeight - dstHeight) > MAX_JUMP_HEIGHT) return null;
return 1 + Math.abs(srcHeight - dstHeight);
return 1;
};
const addOrthogonalJumps = (prevNode, src, srcCost, dirX, dirY) => {
let jumpDistance = 1;
Expand Down
8 changes: 4 additions & 4 deletions preview/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { Grid, transpose } from "./bundle.js";
const getPathFinding = (start, end) => {
const original = [
[
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
[
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
[
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
[
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
[
Expand Down
2 changes: 1 addition & 1 deletion src/grid/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const findPath = (
// Max jump
if (Math.abs(srcHeight - dstHeight) > MAX_JUMP_HEIGHT) return null;

return 1 + Math.abs(srcHeight - dstHeight);
return 1;
};

// Orthogonal jumps from JumpPoint
Expand Down