Class Map.MoveCandidate

  • Enclosing class:
    Map

    private static class Map.MoveCandidate
    extends java.lang.Object
    Internal class for evaluating a candidate move.
    • Constructor Summary

      Constructors 
      Constructor Description
      MoveCandidate​(Unit unit, PathNode current, Location dst, int movesLeft, int turns, boolean onCarrier, CostDecider decider)
      Creates a new move candidate where a cost decider will be used to work out the new moves and turns left.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.util.HashMap<java.lang.String,​PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,​java.lang.Integer> f, Map.SearchHeuristic sh)
      Add this candidate to the open map+queue.
      boolean canImprove​(PathNode best)
      Does this move candidate improve on a specified move.
      void embarkUnit​(Unit unit)
      Handles the change of unit as a result of an embark.
      int getCost()
      Get the cost.
      void improve​(java.util.HashMap<java.lang.String,​PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,​java.lang.Integer> f, Map.SearchHeuristic sh)
      Replace a given path with that of this candidate move.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • unit

        private Unit unit
      • current

        private final PathNode current
      • movesLeft

        private int movesLeft
      • turns

        private int turns
      • onCarrier

        private final boolean onCarrier
      • cost

        private int cost
    • Constructor Detail

      • MoveCandidate

        public MoveCandidate​(Unit unit,
                             PathNode current,
                             Location dst,
                             int movesLeft,
                             int turns,
                             boolean onCarrier,
                             CostDecider decider)
        Creates a new move candidate where a cost decider will be used to work out the new moves and turns left.
        Parameters:
        unit - The Unit to move.
        current - The current position on the path.
        dst - The Location to move to.
        movesLeft - The initial number of moves left.
        turns - The initial number of turns.
        onCarrier - Will the new move be on a carrier.
        decider - The CostDecider to use.
    • Method Detail

      • getCost

        public int getCost()
        Get the cost.
        Returns:
        The current move cost.
      • embarkUnit

        public void embarkUnit​(Unit unit)
        Handles the change of unit as a result of an embark.
        Parameters:
        unit - The Unit to embark.
      • canImprove

        public boolean canImprove​(PathNode best)
        Does this move candidate improve on a specified move.
        Parameters:
        best - The PathNode to compare against.
        Returns:
        True if this candidate is an improvement.
      • improve

        public void improve​(java.util.HashMap<java.lang.String,​PathNode> openMap,
                            java.util.PriorityQueue<PathNode> openMapQueue,
                            java.util.HashMap<java.lang.String,​java.lang.Integer> f,
                            Map.SearchHeuristic sh)
        Replace a given path with that of this candidate move.
        Parameters:
        openMap - The list of available nodes.
        openMapQueue - The queue of available nodes.
        f - The heuristic values for A*.
        sh - A SearchHeuristic to apply.
      • add

        public void add​(java.util.HashMap<java.lang.String,​PathNode> openMap,
                        java.util.PriorityQueue<PathNode> openMapQueue,
                        java.util.HashMap<java.lang.String,​java.lang.Integer> f,
                        Map.SearchHeuristic sh)
        Add this candidate to the open map+queue.
        Parameters:
        openMap - The list of available nodes.
        openMapQueue - The queue of available nodes.
        f - The map of f-values.
        sh - A SearchHeuristic to apply.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object