Class SBFMovePathFinder


public class SBFMovePathFinder extends AbstractPathFinder<BoardLocation,SBFMovePath,SBFMovePath>
  • Constructor Details

    • SBFMovePathFinder

      public SBFMovePathFinder(SBFGame game, DestinationMap<BoardLocation,SBFMovePath> edgeDestinationMap, EdgeRelaxer<SBFMovePath,SBFMovePath> edgeRelaxer, AdjacencyMap<SBFMovePath> edgeAdjacencyMap, Comparator<SBFMovePath> edgeComparator)
      Parameters:
      edgeDestinationMap - functional interface for retrieving destination node of an edge.
      edgeRelaxer - functional interface for calculating relaxed cost.
      edgeAdjacencyMap - functional interface for retrieving neighbouring edges.
      edgeComparator - implementation of path comparator. Each path is defined by its last edge. (path:= edge concatenated with the best path to the source of the edge)
  • Method Details

    • moveEnvelopeFinder

      public static SBFMovePathFinder moveEnvelopeFinder(int maxMP, SBFGame game)
      Produces new instance of shortest path searcher. It will find all the shortest paths between starting points that are reachable with at most maxMp move points.
      Parameters:
      maxMP - maximum MP that entity can use
      game - The SBFGame
    • aStarFinder

      public static SBFMovePathFinder aStarFinder(BoardLocation destination, SBFGame game)
      Produces a new instance of shortest path between starting points and a destination finder. Algorithm will halt after reaching destination.

      Current implementation uses AStar algorithm.

      Parameters:
      game - The current Game
    • getAllComputedPaths

      public Map<BoardLocation,SBFMovePath> getAllComputedPaths()
      Returns a map of all computed shortest paths. If multiple paths to a single hex, each with different final facing, are present, then the minimal one is chosen for each hex.
      Returns:
      a map of all computed shortest paths.
    • getAllComputedCosts

      protected Map<BoardLocation,SBFMovePath> getAllComputedCosts(Comparator<SBFMovePath> comp)
      Returns a map of all computed shortest paths
    • getCost

      @Nullable protected SBFMovePath getCost(BoardLocation coords, Comparator<SBFMovePath> comp)
      Returns computed cost to reach the hex at c coordinates. If multiple path are present with different final facings, the one minimal one is chosen. If none paths are present then null is returned.
      Parameters:
      comp - comparator used if multiple paths are present
      Returns:
      shortest path to the hex at c coordinates or null
    • getComputedPath

      public SBFMovePath getComputedPath(BoardLocation coordinates)
      Returns the shortest move path to a hex at given coordinates or null if none is present. If multiple path are present with different final facings, the minimal one is chosen.
      Parameters:
      coordinates - - the coordinates of the hex
      Returns:
      the shortest move path to hex at given coordinates or null