net.sf.freecol.server.ai
Class REFAIPlayer

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.server.ai.AIObject
          extended by net.sf.freecol.server.ai.AIPlayer
              extended by net.sf.freecol.server.ai.EuropeanAIPlayer
                  extended by net.sf.freecol.server.ai.REFAIPlayer

public 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 Summary
private static java.util.logging.Logger logger
           
 
Fields inherited from class net.sf.freecol.server.ai.AIPlayer
MAX_DISTANCE_TO_BRING_GIFT, MAX_DISTANCE_TO_MAKE_DEMANDS, MAX_NUMBER_OF_DEMANDS, MAX_NUMBER_OF_GIFTS_BEING_DELIVERED
 
Fields inherited from class net.sf.freecol.server.ai.AIObject
uninitialized
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
REFAIPlayer(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new REFAIPlayer and reads the information from the given Element.
REFAIPlayer(AIMain aiMain, ServerPlayer player)
          Creates a new REFAIPlayer.
REFAIPlayer(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Creates a new REFAIPlayer.
 
Method Summary
private  boolean alreadySeeking(Unit unit)
          Checks if there is already a seek and destroy mission active on for a target unit.
 int getDefendColonyMissionValue(Unit unit, Colony colony, int turns)
          Evaluate allocating a unit to the defence of a colony.
 int getUnitSeekAndDestroyMissionValue(Unit unit, Tile newTile, int turns)
          Evaluate a potential seek and destroy mission for a given unit to a given tile.
 void giveNormalMissions()
          Gives a mission to non-naval units.
 Tile initialize(boolean teleport)
          Initialize the REF.
 void startWorking()
          Tells this REFAIPlayer to make decisions.
 
Methods inherited from class net.sf.freecol.server.ai.EuropeanAIPlayer
acceptDiplomaticTrade, acceptMercenaries, acceptTax, buyProposition, chooseMilitaryTarget, getColonyDefenders, getTileImprovementPlans, getWishes, giveMilitaryMission, hasFewColonies, indianDemand, recruitAIUnitInEurope, registerSellGoods, removeTileImprovementPlan, selectFoundingFather, sellProposition, trainAIUnitInEurope
 
Methods inherited from class net.sf.freecol.server.ai.AIPlayer
abortInvalidAndOneTimeMissions, abortInvalidMissions, clearAIUnits, determineStance, determineStances, doMissions, getAIAdvantage, getAIColonies, getAIColony, getAIRandom, getAIUnit, getAIUnitIterator, getAIUnits, getConnection, getId, getPlayer, getXMLElementTagName, isTargetValidForSeekAndDestroy, readFromXMLImpl, setDebuggingConnection, setPlayer, toXMLImpl
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
dispose, getAIMain, getGame, getSpecification, isUninitialized, readFromXML
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
Constructor Detail

REFAIPlayer

public REFAIPlayer(AIMain aiMain,
                   ServerPlayer 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,
                   org.w3c.dom.Element element)
Creates a new REFAIPlayer and reads the information from the given Element.

Parameters:
aiMain - The main AI-class.
element - The XML-element containing information.

REFAIPlayer

public REFAIPlayer(AIMain aiMain,
                   javax.xml.stream.XMLStreamReader in)
            throws javax.xml.stream.XMLStreamException
Creates a new REFAIPlayer.

Parameters:
aiMain - The main AI-object.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
Method Detail

startWorking

public void startWorking()
Tells this REFAIPlayer to make decisions.

Overrides:
startWorking in class EuropeanAIPlayer

initialize

public Tile 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:
The preferred entry location, or null if no useful preference.

getDefendColonyMissionValue

public int getDefendColonyMissionValue(Unit unit,
                                       Colony colony,
                                       int turns)
Evaluate allocating a unit to the defence of a colony. Temporary helper method for giveMilitaryMission. Only public for testAssignDefendSettlementMission.

Overrides:
getDefendColonyMissionValue in class EuropeanAIPlayer
Parameters:
unit - The Unit that is to defend.
colony - The Colony to defend.
turns - The turns for the unit to reach the colony.
Returns:
A value for such a mission.

getUnitSeekAndDestroyMissionValue

public int getUnitSeekAndDestroyMissionValue(Unit unit,
                                             Tile newTile,
                                             int turns)
Evaluate a potential seek and destroy mission for a given unit to a given tile.

Overrides:
getUnitSeekAndDestroyMissionValue in class EuropeanAIPlayer
Parameters:
unit - The Unit to do the mission.
newTile - The Tile to go to.
turns - How long to travel to the tile.
Returns:
A score for the proposed mission.

alreadySeeking

private boolean alreadySeeking(Unit unit)
Checks if there is already a seek and destroy mission active on for a target unit.

Parameters:
unit - The Unit to check if there is a mission for.
Returns:
True if there is a mission for the unit.

giveNormalMissions

public void giveNormalMissions()
Gives a mission to non-naval units.

Overrides:
giveNormalMissions in class EuropeanAIPlayer