Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Feb 21, 2024
1 parent 641b614 commit 2105ceb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public final List<T> getNeighbors(int x, int y, NeighborFilteringOption neighbor
getDown(x, y).ifPresent(result::add);

// Include "Corner" neighbors when eight directions
if(neighborFilteringOption.is(EIGHT_DIRECTIONS)) {
if (neighborFilteringOption == EIGHT_DIRECTIONS) {
getUpLeft(x, y).ifPresent(result::add);
getUpRight(x, y).ifPresent(result::add);
getDownLeft(x, y).ifPresent(result::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,4 @@
public enum NeighborFilteringOption {

FOUR_DIRECTIONS, EIGHT_DIRECTIONS;

public boolean is(NeighborFilteringOption... neighborFilteringOptions) {
for(NeighborFilteringOption neighborFilteringOption : neighborFilteringOptions) {
if(neighborFilteringOption.equals(this)) {
return true;
}
}
return false;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public List<AStarCell> findPath(AStarCell[][] grid, AStarCell start, AStarCell t
}
}

Heuristic<AStarCell> heuristic = (neighborFilteringOption.is(FOUR_DIRECTIONS)) ? defaultHeuristic : diagonalHeuristic;
Heuristic<AStarCell> heuristic = (neighborFilteringOption == FOUR_DIRECTIONS) ? defaultHeuristic : diagonalHeuristic;

// reset grid cells data
for (int y = 0; y < grid[0].length; y++) {
Expand Down

0 comments on commit 2105ceb

Please sign in to comment.