From cbf8d61fcf17edbed3d72d0530a3f83961c5256f Mon Sep 17 00:00:00 2001 From: GodCipher Date: Mon, 23 Sep 2024 21:39:16 +0200 Subject: [PATCH] feat: remove deprecated counterCheck --- .../PathfinderConfiguration.java | 11 ------ .../pathfinder/AbstractPathfinder.java | 37 +------------------ 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/pathetic-api/src/main/java/org/patheloper/api/pathing/configuration/PathfinderConfiguration.java b/pathetic-api/src/main/java/org/patheloper/api/pathing/configuration/PathfinderConfiguration.java index 2f813598..82eb7de7 100644 --- a/pathetic-api/src/main/java/org/patheloper/api/pathing/configuration/PathfinderConfiguration.java +++ b/pathetic-api/src/main/java/org/patheloper/api/pathing/configuration/PathfinderConfiguration.java @@ -73,16 +73,6 @@ public class PathfinderConfiguration { */ boolean loadingChunks; - /** - * If pathfinding fails, determines whether to run a reverse pathfinding check (from target to - * start) to verify the result. This is a computationally expensive fallback but can help identify - * some failure cases. - * - * @deprecated This feature is deprecated and may be removed in a future release. - */ - @Deprecated - boolean counterCheck; - /** * Determines whether the pathfinding algorithm should see PathFilterStages as prioritization, * instead of filtering. This means that the pathfinding algorithm will prioritize paths that pass @@ -138,7 +128,6 @@ public static PathfinderConfiguration deepCopy(PathfinderConfiguration pathfinde .allowingFailFast(pathfinderConfiguration.allowingFailFast) .allowingFallback(pathfinderConfiguration.allowingFallback) .loadingChunks(pathfinderConfiguration.loadingChunks) - .counterCheck(pathfinderConfiguration.counterCheck) .heuristicWeights(pathfinderConfiguration.heuristicWeights) .build(); } diff --git a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java index e3700a56..79829dc3 100644 --- a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java +++ b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java @@ -9,7 +9,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; -import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.annotation.Nullable; @@ -204,7 +203,7 @@ private PathfinderResult executePathing( aborted = false; // just in case - return backupPathfindingOrFailure(depth, start, target, filters, fallbackNode); + return backupPathfindingOrFailure(depth, start, target, fallbackNode); } catch (Exception e) { throw ErrorLogger.logFatalErrorWithStacktrace("Failed to find path", e); } @@ -291,22 +290,13 @@ private PathfinderResult finishPathing(PathState pathState, Node currentNode) { /** If the pathfinder has failed to find a path, it will try to still give a result. */ private PathfinderResult backupPathfindingOrFailure( - Depth depth, - PathPosition start, - PathPosition target, - List filters, - Node fallbackNode) { + Depth depth, PathPosition start, PathPosition target, Node fallbackNode) { Optional maxIterationsResult = maxIterationsReached(depth, fallbackNode); if (maxIterationsResult.isPresent()) { return maxIterationsResult.get(); } - Optional counterCheckResult = counterCheck(start, target, filters); - if (counterCheckResult.isPresent()) { - return counterCheckResult.get(); - } - Optional fallbackResult = fallback(fallbackNode); return fallbackResult.orElseGet( () -> @@ -332,29 +322,6 @@ private Optional fallback(Node fallbackNode) { return Optional.empty(); } - private Optional counterCheck( - PathPosition start, PathPosition target, List filters) { - if (!pathfinderConfiguration.isCounterCheck()) { - return Optional.empty(); - } - - AStarPathfinder aStarPathfinder = - new AStarPathfinder( - PathfinderConfiguration.deepCopy(pathfinderConfiguration).withCounterCheck(false)); - try { - PathfinderResult pathfinderResult = - aStarPathfinder.findPath(start, target, filters).toCompletableFuture().get(); - - if (pathfinderResult.getPathState() == PathState.FOUND) { - return Optional.of(pathfinderResult); - } - } catch (InterruptedException | ExecutionException e) { - throw new RuntimeException(e); - } - - return Optional.empty(); - } - private Path fetchRetracedPath(@NonNull Node node) { if (node.getParent() == null) return new PathImpl(