Class REFAIPlayer

  • All Implemented Interfaces:
    java.lang.Comparable<FreeColObject>, ObjectWithId

    public final class REFAIPlayer
    extends EuropeanAIPlayer
    Objects of this class contains AI-information for a single REF player. For now, mostly just the EuropeanAIPlayer, with a few tweaks.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • UNIT_USAD_THRESHOLD

        private static final int UNIT_USAD_THRESHOLD
        Limit on the number of REF units chasing a single hostile unit.
        See Also:
        Constant Field Values
      • targetMap

        private final java.util.Map<Location,​java.lang.Integer> targetMap
        Map of target to count.
      • landed

        private boolean landed
        Has the army been landed?
    • Constructor Detail

      • REFAIPlayer

        public REFAIPlayer​(AIMain aiMain,
                           Player player)
        Creates a new REFAIPlayer.
        Parameters:
        aiMain - The main AI-class.
        player - The player that should be associated with this REFAIPlayer.
      • REFAIPlayer

        public REFAIPlayer​(AIMain aiMain,
                           FreeColXMLReader xr)
                    throws javax.xml.stream.XMLStreamException
        Creates a new REFAIPlayer.
        Parameters:
        aiMain - The main AI-object.
        xr - The input stream containing the XML.
        Throws:
        javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
    • Method Detail

      • findColonyTargets

        private java.util.List<REFAIPlayer.TargetTuple> findColonyTargets​(AIUnit aiu,
                                                                          boolean port,
                                                                          AIUnit aiCarrier)
        Find suitable colony targets.
        Parameters:
        aiu - The AIUnit to search with.
        port - If true, insist on the colonies being ports.
        aiCarrier - The AIUnit to use as a carrier.
        Returns:
        A list of TargetTuple target choices.
      • findColonyTargets

        private java.util.List<REFAIPlayer.TargetTuple> findColonyTargets​(AIUnit aiu,
                                                                          AIUnit aiCarrier)
        Find suitable colony targets.
        Parameters:
        aiu - The AIUnit to search with.
        aiCarrier - The AIUnit to use as a carrier.
        Returns:
        A list of TargetTuple target choices.
      • initialize

        public boolean initialize​(boolean teleport)
        Initialize the REF. - Find the initial target - Give valid missions to all the units Note that we can not rely on normal AI processing as the "teleporting" Col1-style REF needs to be placed on the map before its first turn starts, so the server should ask this AI where it should arrive on the map. Note also that to find a target we can not just call getMilitaryMission and aim for it as the getMilitaryMission scoring includes distance from starting point, which is what we are trying to determine. So, just choose the best coastal colony. FIXME: Mission assignment is done here because ATM the European AI is prone to send ships full of troops off to attack the rebel navy. If this is fixed check if the normal mission assignment works and drop it from here.
        Parameters:
        teleport - "Teleporting" in is allowed.
        Returns:
        True if the initialization succeeds.
      • requireTransports

        private java.util.List<AIUnit> requireTransports​(int nt,
                                                         java.util.List<AIUnit> transports,
                                                         java.util.List<AIUnit> privateers,
                                                         LogBuilder lb)
        Require more transport missions, recruiting from the privateering missions.
        Parameters:
        nt - The number of transport missions required.
        transports - The list of AIUnits with a transport mission.
        privateers - The list of AIUnits with a privateer mission.
        lb - A LogBuilder to log to.
        Returns:
        A list of new AIUnits with transport missions.
      • determineStance

        protected Stance determineStance​(Player other)
        Standard stance change determination.
        Overrides:
        determineStance in class EuropeanAIPlayer
        Parameters:
        other - The Player wrt consider stance.
        Returns:
        The new Stance.
      • startWorking

        public void startWorking()
        Tells this AIPlayer to make decisions. The AIPlayer is done doing work this turn when this method returns.
        Overrides:
        startWorking in class EuropeanAIPlayer
      • adjustMission

        public int adjustMission​(AIUnit aiUnit,
                                 PathNode path,
                                 java.lang.Class type,
                                 int value)
        Adjusts the score of this proposed mission for this player type. Subclasses should override and refine this.
        Overrides:
        adjustMission in class EuropeanAIPlayer
        Parameters:
        aiUnit - The AIUnit to perform the mission.
        path - A PathNode to the target of this mission.
        type - The mission type.
        value - The proposed value.
        Returns:
        A score representing the desirability of this mission.