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 HeuristicWeights
Represents the default set of heuristic weights used for pathfinding calculations.static final HeuristicWeights
Deprecated.static final HeuristicWeights
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic HeuristicWeights
create
(double manhattanWeight, double octileWeight, double perpendicularWeight, double heightWeight) Creates a newHeuristicWeights
instance with the specified weights.boolean
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
Deprecated.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
Deprecated.Provides a set of weights strongly prioritizing the shortest direct path, even if diagonally. -
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_WEIGHTS
instance 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 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.- 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.
-
equals
-
hashCode
public int hashCode() -
toString
-