Class AStarAlgorithm


  • public class AStarAlgorithm
    extends java.lang.Object
    A* path finding algorithm.
    • Constructor Detail

      • AStarAlgorithm

        public AStarAlgorithm()
    • Method Detail

      • findPath

        public static Tile[] findPath​(Locatable origin,
                                      Locatable destination,
                                      APIContext ctx)
        Finds a path from origin to destination.
        Parameters:
        origin - the start point
        destination - the end point
        ctx - APIContext
        Returns:
        the tile path or null if not reachable
      • distance

        public static double distance​(Locatable origin,
                                      Locatable destination,
                                      APIContext ctx)
        Calculates the distance between the origin and the destination.
        Parameters:
        origin - to calculate distance from
        destination - to calculate the distance to
        ctx - APIContext
        Returns:
        the calculated distance or Double.POSITIVE_INFINITY if not reachable
      • distance

        public static double distance​(Locatable origin,
                                      Locatable destination,
                                      boolean ignoreObjects,
                                      APIContext ctx)
        Calculates the distance between the origin and the destination. Does not take objects in to account
        Parameters:
        origin - to calculate distance from
        destination - to calculate the distance to
        ctx - APIContext
        Returns:
        the calculated distance or Double.POSITIVE_INFINITY if not reachable