Class HeuristicWeights
java.lang.Object
de.bsommerfeld.pathetic.api.pathing.heuristic.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 HeuristicWeightsRepresents the default set of heuristic weights used for pathfinding calculations. -
Method Summary
Modifier and TypeMethodDescriptionstatic HeuristicWeightscreate(double manhattanWeight, double octileWeight, double perpendicularWeight, double heightWeight) Creates a newHeuristicWeightsinstance with the specified weights.booleandoubleReturns the weight applied to the height difference (elevation change) component of the heuristic.doubleReturns the weight applied to the Manhattan distance component of the heuristic.doubleReturns the weight applied to the Octile distance component of the heuristic.doubleReturns the weight applied to the perpendicular distance component of the heuristic.inthashCode()toString()
-
Field Details
-
DEFAULT_WEIGHTS
Represents the default set of heuristic weights used for pathfinding calculations. This instance is initialized with equal weights for all heuristic components:manhattanWeight,octileWeight,perpendicularWeight, andheightWeight, each set to 1.0.The
DEFAULT_WEIGHTSinstance prioritizes a balanced consideration of direct, axis-aligned movement, diagonal movement, path smoothness, and elevation changes.
-
-
Method Details
-
create
public static HeuristicWeights create(double manhattanWeight, double octileWeight, double perpendicularWeight, double heightWeight) Creates a newHeuristicWeightsinstance 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.- Returns:
- A new
HeuristicWeightsinstance 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.
-
equals
-
hashCode
public int hashCode() -
toString
-