Package net.sf.freecol.server.ai
Class REFAIPlayer
- java.lang.Object
-
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
REFAIPlayer.REFNavyGoalDecider
Goal decider class for the REF Navyprivate static class
REFAIPlayer.TargetTuple
Container class for REF target colony information.
-
Field Summary
Fields Modifier and Type Field Description private boolean
landed
Has the army been landed?private static java.util.logging.Logger
logger
private static int
seekAndDestroyRange
private java.util.Map<Location,java.lang.Integer>
targetMap
Map of target to count.private static int
UNIT_USAD_THRESHOLD
Limit on the number of REF units chasing a single hostile unit.-
Fields inherited from class net.sf.freecol.server.ai.EuropeanAIPlayer
pioneerComparator, scoutComparator
-
Fields inherited from class net.sf.freecol.server.ai.AIObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description REFAIPlayer(AIMain aiMain, FreeColXMLReader xr)
Creates a newREFAIPlayer
.REFAIPlayer(AIMain aiMain, Player player)
Creates a newREFAIPlayer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
adjustMission(AIUnit aiUnit, PathNode path, java.lang.Class type, int value)
Adjusts the score of this proposed mission for this player type.protected Stance
determineStance(Player other)
Standard stance change determination.private java.util.List<REFAIPlayer.TargetTuple>
findColonyTargets(AIUnit aiu, boolean port, AIUnit aiCarrier)
Find suitable colony targets.private java.util.List<REFAIPlayer.TargetTuple>
findColonyTargets(AIUnit aiu, AIUnit aiCarrier)
Find suitable colony targets.void
giveNormalMissions(LogBuilder lb)
Ensures all units have a mission.boolean
initialize(boolean teleport)
Initialize the REF.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.void
startWorking()
Tells thisAIPlayer
to make decisions.-
Methods inherited from class net.sf.freecol.server.ai.EuropeanAIPlayer
acceptDiplomaticTrade, acceptMercenaries, acceptTax, allocateTransportables, buildTipMap, cheatGold, claimTransportable, completeWish, doMissions, getBadlyDefended, getBestGoodsWish, getBestPlan, getBestPlanTile, getGoodsWishesAt, getMissionaryMission, getNationSummary, getNavalStrengthRatio, getNeededWagons, getPioneeringMission, getPrivateerMission, getScoutingMission, getStrengthRatio, getTransportMission, getUrgentTransportables, getWishes, getWorkerWishesAt, getWorkInsideColonyMission, handleTrade, indianDemand, pioneersNeeded, removeAIObject, removeTileImprovementPlan, scoutsNeeded, selectFoundingFather, updateTransport
-
Methods inherited from class net.sf.freecol.server.ai.MissionAIPlayer
addAIUnit, clearAIUnits, getAIUnits, getDefendCurrentSettlementMission, getDefendSettlementMission, getIdleAtSettlementMission, getSeekAndDestroyMission, getSeekAndDestroyMission, getSettlementDefenders, getWanderHostileMission, isTargetValidForSeekAndDestroy, logMissions
-
Methods inherited from class net.sf.freecol.server.ai.AIPlayer
askServer, checkIntegrity, chooseFoundingFatherHandler, diplomacyHandler, firstContactHandler, fountainOfYouthHandler, getAIAdvantage, getAIColonies, getAIColony, getAIRandom, getAIUnit, getConnection, getPlayer, getXMLTagName, indianDemandHandler, invoke, lootCargoHandler, monarchActionHandler, nationSummaryHandler, nativeTradeHandler, newLandNameHandler, newRegionNameHandler, readAttributes, reconnectHandler, setAIHandler, setCurrentPlayerHandler, setInitialized, writeAttributes
-
Methods inherited from class net.sf.freecol.server.ai.AIObject
addAIObjectWithId, checkIntegrity, copyIn, dispose, getAIMain, getGame, getSpecification, isDisposed, setGame, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toString, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
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
-
seekAndDestroyRange
private static final int seekAndDestroyRange
- 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 newREFAIPlayer
.- Parameters:
aiMain
- The main AI-class.player
- The player that should be associated with thisREFAIPlayer
.
-
REFAIPlayer
public REFAIPlayer(AIMain aiMain, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newREFAIPlayer
.- 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
- TheAIUnit
to search with.port
- If true, insist on the colonies being ports.aiCarrier
- TheAIUnit
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
- TheAIUnit
to search with.aiCarrier
- TheAIUnit
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 ofAIUnit
s with a transport mission.privateers
- The list ofAIUnit
s with a privateer mission.lb
- ALogBuilder
to log to.- Returns:
- A list of new
AIUnit
s with transport missions.
-
determineStance
protected Stance determineStance(Player other)
Standard stance change determination.- Overrides:
determineStance
in classEuropeanAIPlayer
- Parameters:
other
- ThePlayer
wrt consider stance.- Returns:
- The new
Stance
.
-
giveNormalMissions
public void giveNormalMissions(LogBuilder lb)
Ensures all units have a mission.- Overrides:
giveNormalMissions
in classEuropeanAIPlayer
- Parameters:
lb
- ALogBuilder
to log to.
-
startWorking
public void startWorking()
Tells thisAIPlayer
to make decisions. TheAIPlayer
is done doing work this turn when this method returns.- Overrides:
startWorking
in classEuropeanAIPlayer
-
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 classEuropeanAIPlayer
- Parameters:
aiUnit
- TheAIUnit
to perform the mission.path
- APathNode
to the target of this mission.type
- The mission type.value
- The proposed value.- Returns:
- A score representing the desirability of this mission.
-
-