Skip to content

Commit

Permalink
chore: several reworks and refacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Metaphoriker committed Sep 25, 2024
1 parent fa0807e commit 65201ee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@AllArgsConstructor
public class PathingFinishedEvent implements PathingEvent {

/** The {@link PathfinderResult} of the pathfinding process. */
@NonNull private final PathfinderResult pathfinderResult;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@
import org.patheloper.api.pathing.filter.PathFilterStage;
import org.patheloper.api.wrapper.PathPosition;

/** An event called when a Pathfinder starts pathing. */
/**
* An event triggered when a pathfinder begins the pathfinding process.
*/
@Getter
@RequiredArgsConstructor
public class PathingStartFindEvent implements PathingEvent {

/** The starting {@link PathPosition} of the pathfinding process. */
@NonNull private final PathPosition start;

/** The target {@link PathPosition} of the pathfinding process. */
@NonNull private final PathPosition target;

/** A list of {@link PathFilter} objects to be applied during the pathfinding process. */
@NonNull private final List<PathFilter> filters;

/**
* A list of {@link PathFilterStage} objects representing different stages of the filtering
* process.
*/
@NonNull private final List<PathFilterStage> filterStages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void evaluateNewNodes(
examinedPositions, currentNode, filters, filterStages, allowingDiagonal);

for (Node newNode : newNodes) {
double nodeCost = newNode.getHeuristic().get();
double nodeCost = newNode.getHeuristicCache().get();
if (pathfinderConfiguration.isPrioritizing()) {
double priorityAdjustment = calculatePriorityAdjustment(newNode, filterStages);
nodeCost -= priorityAdjustment;
Expand All @@ -92,7 +92,7 @@ private double calculatePriorityAdjustment(Node node, List<PathFilterStage> filt
snapshotManager));

if (filterResult) {
return node.getHeuristic().get() * (PRIORITY_BOOST_IN_PERCENTAGE / 100.0);
return node.getHeuristicCache().get() * (PRIORITY_BOOST_IN_PERCENTAGE / 100.0);
}
}
return 0.0;
Expand Down Expand Up @@ -197,7 +197,8 @@ private Node createNeighbourNode(Node currentNode, PathVector offset) {
currentNode.getStart(),
currentNode.getTarget(),
pathfinderConfiguration.getHeuristicWeights(),
currentNode.getDepth() + 1);
currentNode.getDepth() + 1,
pathfinderConfiguration);
newNode.setParent(currentNode);
return newNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ private Node createStartNode(PathPosition start, PathPosition target) {
start.floor(),
target.floor(),
pathfinderConfiguration.getHeuristicWeights(),
0);
0,
pathfinderConfiguration);
}

private boolean hasReachedLengthLimit(Node currentNode) {
Expand Down

0 comments on commit 65201ee

Please sign in to comment.