Class HeuristicWeights
java.lang.Object
de.metaphoriker.pathetic.api.pathing.configuration.HeuristicWeights
Represents a set of weights used to calculate a heuristic for the A* pathfinding algorithm. These
weights influence the prioritization of different path characteristics during the search.
This class defines weights for the following distance metrics:
- Manhattan Distance: Prioritizes direct movement along axes.
- Octile Distance: Allows for diagonal movement for finer-grained pathing.
- Perpendicular Distance: Penalizes deviation from the straight line to the target, aiding in smoother paths.
- Height Difference: Factors in elevation changes when calculating path costs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HeuristicWeights
Provides a set of weights strongly prioritizing the shortest direct path, even if diagonally.static final HeuristicWeights
Provides a set of default heuristic weights that may be suitable for natural pathfinding. -
Method Summary
Modifier and TypeMethodDescriptionstatic HeuristicWeights
create
(double manhattanWeight, double octileWeight, double perpendicularWeight, double heightWeight, double directionalPenaltyWeight) Creates a newHeuristicWeights
instance with the specified weights.boolean
double
Returns the weight applied to the directional penalty component of the heuristic.double
Returns the weight applied to the height difference (elevation change) component of the heuristic.double
Returns the weight applied to the Manhattan distance component of the heuristic.double
Returns the weight applied to the Octile distance component of the heuristic.double
Returns the weight applied to the perpendicular distance component of the heuristic.int
hashCode()
toString()
-
Field Details
-
NATURAL_PATH_WEIGHTS
Provides a set of default heuristic weights that may be suitable for natural pathfinding. These values can be adjusted for specific scenarios. -
DIRECT_PATH_WEIGHTS
Provides a set of weights strongly prioritizing the shortest direct path, even if diagonally.
-
-
Method Details
-
create
public static HeuristicWeights create(double manhattanWeight, double octileWeight, double perpendicularWeight, double heightWeight, double directionalPenaltyWeight) Creates a newHeuristicWeights
instance with the specified weights.- Parameters:
manhattanWeight
- The weight applied to the Manhattan distance component. A higher weight favours paths with a greater emphasis on direct, axis-aligned movement.octileWeight
- The weight applied to the Octile distance component. A higher weight allows diagonal movement, enabling more flexible paths in 3D environments.perpendicularWeight
- The weight applied to the perpendicular distance component. Increased weight discourages deviations from the straight line between the start and target, resulting in smoother paths.heightWeight
- The weight applied to the height difference (elevation change) component. A higher weight gives more consideration to vertical distance, important for terrains with varying verticality.directionalPenaltyWeight
- This weighting penalizes heights that are too high and deviate from the starting point.- Returns:
- A new
HeuristicWeights
instance with the given weights.
-
getManhattanWeight
public double getManhattanWeight()Returns the weight applied to the Manhattan distance component of the heuristic.- Returns:
- The Manhattan distance weight.
-
getOctileWeight
public double getOctileWeight()Returns the weight applied to the Octile distance component of the heuristic.- Returns:
- The Octile distance weight.
-
getPerpendicularWeight
public double getPerpendicularWeight()Returns the weight applied to the perpendicular distance component of the heuristic.- Returns:
- The perpendicular distance weight.
-
getHeightWeight
public double getHeightWeight()Returns the weight applied to the height difference (elevation change) component of the heuristic.- Returns:
- The height difference weight.
-
getDirectionalPenaltyWeight
public double getDirectionalPenaltyWeight()Returns the weight applied to the directional penalty component of the heuristic. This weight penalizes paths that deviate significantly in direction or height from the starting point.- Returns:
- The directional penalty weight.
-
equals
-
hashCode
public int hashCode() -
toString
-