Skip to content

Commit

Permalink
Removed experimental and unfinished stuff, deprecated #newPathfinder …
Browse files Browse the repository at this point in the history
…method with a type
  • Loading branch information
Metaphoriker committed Sep 19, 2023
1 parent 55551b9 commit 39da5eb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,31 @@
import org.patheloper.api.pathing.strategy.PathfinderStrategy;

/**
* A set of rules that are used while pathfinding.
* <p>
* strategy - The class of the strategy to use while pathfinding.
* <p>
* maxIterations - The maximum amount of iterations to do while pathfinding.
* <p>
* maxLength - The maximum length of the path.
* This should not be set too high since it can cause a lagspike within the pathfinder which causes it to take longer.
* <p>
* async - Whether to run the pathfinding async or not.
* <p>
* allowDiagonal - Whether to allow diagonal movement or not.
* <p>
* alternateTarget - Whether to allow the pathfinder to end at a different block than the target if the target is unreachable.
* NOTE: In most cases fallback is the better option since this can be in the worst case a very expensive radical operation
* in addition to the regular pathfinding with only the goal to find an alternate target
* no matter where or in what relation to anything.
* <p>
* failFast - Whether to fail fast or not, if the target is unreachable by the beginning.
* <p>
* fallback - If pathfinding fails, it will fallback to the already found path.
* <p>
* loadChunks - Whether to load / generate chunks
* <p>
* counterCheck - Whether to run the counter check the path if it's not found to validate the result
* NOTE: counterCheck is a fallback mechanism which researches the entire path from end to beginning again
* Configuration options for pathfinding.
*
* This class defines a set of rules that guide the behavior of the pathfinding process.
*
* - `strategy`: The class of the strategy to use for pathfinding. Defaults to {@link DirectPathfinderStrategy}.
*
* - `maxIterations`: The maximum number of iterations allowed during pathfinding. Set this to prevent infinite loops.
*
* - `maxLength`: The maximum length of the path. Avoid setting this too high as it can cause performance issues.
*
* - `async`: Whether to run pathfinding asynchronously or not.
*
* - `allowingDiagonal`: Whether to allow diagonal movement when pathfinding.
*
* - `allowingAlternateTarget`: Whether to allow the pathfinder to end at a different block than the target if the target is unreachable.
* Note: In most cases, using `fallback` is a better option as this operation can be very expensive in the worst case scenario.
*
* - `allowingFailFast`: Whether to fail fast if the target is unreachable from the start.
*
* - `allowingFallback`: If pathfinding fails, whether to fall back to the previously found path.
*
* - `loadingChunks`: Whether to load or generate chunks during pathfinding.
*
* - `counterCheck`: Whether to run a counter check on the path if it's not found to validate the result.
* Note: `counterCheck` is a fallback mechanism that reevaluates the entire path from end to beginning.
*/
@With
@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import org.patheloper.api.pathing.Pathfinder;
import org.patheloper.api.pathing.rules.PathingRuleSet;
import org.patheloper.model.pathing.pathfinder.AStarPathfinder;
import org.patheloper.model.pathing.pathfinder.BidirectionalAStarPathfinder;
import org.patheloper.util.ErrorLogger;

import java.util.Objects;

/**
* PatheticMapper is a utility class that maps the Pathetic API to the Pathetic Implementation.
*/
Expand Down Expand Up @@ -56,32 +57,22 @@ public void initialize(JavaPlugin javaPlugin) {
* @param pathfinderType - The {@link PathfinderType}
* @return The {@link Pathfinder} object
* @throws IllegalStateException If the lib is not initialized yet
* @experimental See {@link BidirectionalAStarPathfinder} for more information.
*/
@Experimental
@Deprecated
public @NonNull Pathfinder newPathfinder(PathingRuleSet pathingRuleSet, PathfinderType pathfinderType) {
if (Pathetic.isInitialized()) {
switch (pathfinderType) {
case ASTAR:
return new AStarPathfinder(pathingRuleSet);
case BIDIRECTIONAL_ASTAR:
return new BidirectionalAStarPathfinder(pathingRuleSet);
default:
throw ErrorLogger.logFatalError("Unknown pathfinder type: " + pathfinderType);
if (Objects.requireNonNull(pathfinderType) == PathfinderType.ASTAR) {
return new AStarPathfinder(pathingRuleSet);
}
throw ErrorLogger.logFatalError("Unknown pathfinder type: " + pathfinderType);
}
throw ErrorLogger.logFatalError("Pathetic is not initialized");
}


@Deprecated
public enum PathfinderType {

ASTAR,

/**
* @experimental See {@link BidirectionalAStarPathfinder} for more information.
*/
@Experimental
BIDIRECTIONAL_ASTAR
ASTAR;
}

}
1 change: 0 additions & 1 deletion pathetic-model/src/main/java/org/patheloper/Pathetic.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.patheloper.bukkit.listeners.ChunkInvalidateListener;
import org.patheloper.util.ErrorLogger;
import org.patheloper.util.NodeUtil;

@UtilityClass
public class Pathetic {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.patheloper.model.pathing.pathfinder;

import org.checkerframework.checker.units.qual.N;
import org.patheloper.api.pathing.result.PathState;
import org.patheloper.api.pathing.result.PathfinderResult;
import org.patheloper.api.pathing.rules.PathingRuleSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.patheloper.api.pathing.result.PathfinderResult;
import org.patheloper.api.pathing.rules.PathingRuleSet;
import org.patheloper.api.pathing.strategy.PathfinderStrategy;
import org.patheloper.api.pathing.strategy.strategies.DirectPathfinderStrategy;
import org.patheloper.api.snapshot.SnapshotManager;
import org.patheloper.api.wrapper.PathBlock;
import org.patheloper.api.wrapper.PathPosition;
Expand Down

This file was deleted.

0 comments on commit 39da5eb

Please sign in to comment.