Class Unit.ClosestSettlementGoalDecider

  • All Implemented Interfaces:
    GoalDecider
    Enclosing class:
    Unit

    private static class Unit.ClosestSettlementGoalDecider
    extends java.lang.Object
    implements GoalDecider
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private PathNode best
      Best path so far.
      private int bestValue
      Best value so far.
      private boolean coastal
      Require a connected port.
      private Tile exclude
      A tile to exclude.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClosestSettlementGoalDecider​(Tile exclude, boolean coastal)
      Build a new goal decider to find the closest path to a settlement owned by the player controlling the searching unit.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean check​(Unit u, PathNode path)
      Checks whether the given PathNode is a goal/sub-goal.
      PathNode getGoal()
      Gets the PathNode containing the goal.
      boolean hasSubGoals()
      Determines whether this GoalDecider has any sub goals.
      • Methods inherited from class java.lang.Object

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

      • exclude

        private Tile exclude
        A tile to exclude.
      • coastal

        private boolean coastal
        Require a connected port.
      • bestValue

        private int bestValue
        Best value so far.
      • best

        private PathNode best
        Best path so far.
    • Constructor Detail

      • ClosestSettlementGoalDecider

        public ClosestSettlementGoalDecider​(Tile exclude,
                                            boolean coastal)
        Build a new goal decider to find the closest path to a settlement owned by the player controlling the searching unit.
        Parameters:
        exclude - An optional tile to exclude.
        coastal - If true, a connected port is required.
    • Method Detail

      • getGoal

        public PathNode getGoal()
        Gets the PathNode containing the goal.
        Specified by:
        getGoal in interface GoalDecider
        Returns:
        The PathNode where the Tile returned by pathNode.getTile() is the goal.
      • hasSubGoals

        public boolean hasSubGoals()
        Determines whether this GoalDecider has any sub goals.
        Specified by:
        hasSubGoals in interface GoalDecider
        Returns:
        true if there are any sub goals and false otherwise.
      • check

        public boolean check​(Unit u,
                             PathNode path)
        Checks whether the given PathNode is a goal/sub-goal.
        Specified by:
        check in interface GoalDecider
        Parameters:
        u - The Unit which we are trying to find a path for.
        path - The PathNode where the Tile returned by pathNode.getTile() is the tile to be checked.
        Returns:
        true if the PathNode was either a goal or a sub goal and false otherwise. The goal should be returned by GoalDecider.getGoal() right after a call to this method, if this method returns true and GoalDecider.hasSubGoals() returns false.