Skip to content

Commit

Permalink
feat: improved heuristic on accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
Metaphoriker committed Oct 1, 2024
1 parent 4c376c5 commit 838dec2
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ private double heuristic() {
double perpendicularWeight = heuristicWeights.getPerpendicularWeight();
double heightWeight = heuristicWeights.getHeightWeight();

// Ensure the combined heuristic is consistent
return Math.max(
manhattanDistance * manhattanWeight,
octileDistance * octileWeight
+ perpendicularDistance * perpendicularWeight
+ heightDifference * heightWeight);
double directionalPenalty = Math.abs(this.position.getBlockY() - start.getBlockY());

return (manhattanDistance * manhattanWeight)
+ (octileDistance * octileWeight)
+ (perpendicularDistance * perpendicularWeight)
+ (heightDifference * heightWeight)
+ (directionalPenalty * 0.5);
}

private double calculatePerpendicularDistance() {
Expand Down

0 comments on commit 838dec2

Please sign in to comment.