|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.server.ai.AIObject
net.sf.freecol.server.ai.AIPlayer
net.sf.freecol.server.ai.ColonialAIPlayer
public class ColonialAIPlayer
Objects of this class contains AI-information for a single Player and
is used for controlling this player.
The method startWorking() gets called by the
AIInGameInputHandler when it is this player's turn.
| Nested Class Summary | |
|---|---|
private static class |
ColonialAIPlayer.AIStrategy
|
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private ManageMissionariesGoal |
mGoal
Goal to manage missionary units of this player. |
private java.util.ArrayList<AIUnit> |
myAIUnits
Used in temporary override of AIUnit iterator methods |
private ColonialAIPlayer.AIStrategy |
strategy
The strategy of this player. |
| 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, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
ColonialAIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIPlayer and reads the information from the
given Element. |
|
ColonialAIPlayer(AIMain aiMain,
ServerPlayer player)
Creates a new AIPlayer. |
|
ColonialAIPlayer(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIPlayer. |
|
| Method Summary | |
|---|---|
private void |
abortInvalidAndOneTimeMissions()
Aborts all the missions which are no longer valid. |
private void |
abortInvalidMissions()
Aborts all the missions which are no longer valid. |
boolean |
acceptDiplomaticTrade(DiplomaticTrade agreement)
|
boolean |
acceptIndianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
Decides whether to accept an Indian demand, or not. |
boolean |
acceptMercenaryOffer()
Decides whether to accept a mercenary offer, or not. |
boolean |
acceptTax(int tax)
Decides whether to accept the monarch's tax raise or not. |
int |
buyProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a trade. |
private void |
cheat()
Cheats for the AI :-) |
protected void |
clearAIUnits()
Helper method to let implementing subclasses clear aiUnits. |
private void |
createAIGoodsInColonies()
Calls AIColony.createAIGoods() for every colony this player owns. |
private void |
createTransportLists()
Maps Transportables to carrier's using a
TransportMission. |
private void |
determineStances()
Determines the stances towards each player. |
private void |
doMissions()
Makes every unit perform their mission. |
private void |
ensureCorrectMissions()
Ensures that all workers inside a colony gets a WorkInsideColonyMission. |
protected java.util.Iterator<AIUnit> |
getAIUnitIterator()
Returns an iterator over all AIUnits owned by this
player, which currently do _not_ have a goal. |
private Unit |
getBestTreasureTrain(Tile tile)
Returns the treasure train carrying the largest treasure located on the given Tile. |
(package private) int |
getDefendColonyMissionValue(Unit u,
Colony colony,
int turns)
|
java.util.Iterator<TileImprovementPlan> |
getTileImprovementPlanIterator()
Returns an Iterator over all the
TileImprovements needed by all of this player's colonies. |
(package private) int |
getUnitSeekAndDestroyMissionValue(Unit unit,
Tile newTile,
int turns)
|
java.util.Iterator<Wish> |
getWishIterator()
Returns an Iterator for all the wishes. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
(package private) void |
giveMilitaryMission(AIUnit aiUnit)
Gives a military Mission to the given unit. |
private void |
giveNavalMissions()
Gives missions to all the naval units this player owns. |
private void |
giveNormalMissions()
Gives a mission to non-naval units. |
boolean |
hasFewColonies()
This is a temporary method which are used for forcing the computer players into building more colonies. |
(package private) boolean |
isTargetValidForSeekAndDestroy(Unit attacker,
Unit defender)
TODO: Package for access by a test only - necessary? |
private void |
manageMissionaries()
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
private void |
rearrangeWorkersInColonies()
Calls AIColony.rearrangeWorkers for every colony this player
owns. |
void |
registerSellGoods(Goods goods)
Called after another Player sends a trade message |
void |
removeTileImprovementPlan(TileImprovementPlan plan)
Remove a TileImprovementPlan from the list |
FoundingFather |
selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
Selects the most useful founding father offered. |
int |
sellProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a sale. |
void |
startWorking()
Tells this AIPlayer to make decisions. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes this object to an XML stream. |
| Methods inherited from class net.sf.freecol.server.ai.AIPlayer |
|---|
determineStance, getAIColony, getAIColonyIterator, getAIUnit, getAIUnits, getConnection, getId, getPlayer, recruitAIUnitInEurope, setDebuggingConnection, setPlayer, trainAIUnitInEurope |
| Methods inherited from class net.sf.freecol.server.ai.AIObject |
|---|
dispose, getAIMain, getAIRandom, getGame, isUninitialized, readFromXML |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private ColonialAIPlayer.AIStrategy strategy
private java.util.ArrayList<AIUnit> myAIUnits
private ManageMissionariesGoal mGoal
| Constructor Detail |
|---|
public ColonialAIPlayer(AIMain aiMain,
ServerPlayer player)
AIPlayer.
aiMain - The main AI-class.player - The player that should be associated with this
AIPlayer.
public ColonialAIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
AIPlayer and reads the information from the
given Element.
aiMain - The main AI-class.element - The XML-element containing information.
public ColonialAIPlayer(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIPlayer.
aiMain - The main AI-object.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.| Method Detail |
|---|
public void startWorking()
AIPlayer to make decisions. The
AIPlayer is done doing work this turn when this method
returns.
startWorking in class AIPlayerpublic java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
Iterator over all the
TileImprovements needed by all of this player's colonies.
getTileImprovementPlanIterator in class AIPlayerIterator.TileImprovementpublic void removeTileImprovementPlan(TileImprovementPlan plan)
TileImprovementPlan from the list
removeTileImprovementPlan in class AIPlayerpublic boolean hasFewColonies()
hasFewColonies in class AIPlayertrue if the AI should build more colonies.public java.util.Iterator<Wish> getWishIterator()
Iterator for all the wishes. The items are
sorted by the value, with the item having the
highest value appearing first in the Iterator.
getWishIterator in class AIPlayerIterator.Wishpublic FoundingFather selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
selectFoundingFather in class AIPlayerfoundingFathers - The founding fathers on offer.
public boolean acceptTax(int tax)
acceptTax in class AIPlayertax - The new tax rate to be considered.
true if the tax raise should be accepted.
public boolean acceptIndianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
acceptIndianDemand in class AIPlayerunit - The unit making demands.colony - The colony where demands are being made.goods - The goods demanded.gold - The amount of gold demanded.
true if this AIPlayer accepts the
indian demand and false otherwise.public boolean acceptMercenaryOffer()
acceptMercenaryOffer in class AIPlayertrue if this AIPlayer accepts the
offer and false otherwise.public boolean acceptDiplomaticTrade(DiplomaticTrade agreement)
acceptDiplomaticTrade in class AIPlayerpublic void registerSellGoods(Goods goods)
Player sends a trade message
registerSellGoods in class AIPlayergoods - The goods which we are going to offer
public int buyProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes a trade.
buyProposition in class AIPlayerunit - The foreign Unit trying to trade.settlement - The Settlement this player owns and
which the given Unit is trying to trade.goods - The goods the given Unit is trying to sell.gold - The suggested price.
AIPlayer suggests or
NetworkConstants.NO_TRADE.
public int sellProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes a sale.
sellProposition in class AIPlayerunit - The foreign Unit trying to trade.settlement - The Settlement this player owns and
which the given Unit if trying to sell goods.goods - The goods the given Unit is trying to sell.gold - The suggested price.
AIPlayer suggests or
NetworkConstants.NO_TRADE.
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class AIPlayerout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to the
stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class AIPlayerin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if there are any problems reading from the
stream.public static java.lang.String getXMLElementTagName()
private void cheat()
private void ensureCorrectMissions()
WorkInsideColonyMission.
private void determineStances()
private void abortInvalidMissions()
private void abortInvalidAndOneTimeMissions()
private void giveNavalMissions()
private void rearrangeWorkersInColonies()
AIColony.rearrangeWorkers for every colony this player
owns.
private void giveNormalMissions()
private void createAIGoodsInColonies()
AIColony.createAIGoods() for every colony this player owns.
private void doMissions()
int getDefendColonyMissionValue(Unit u,
Colony colony,
int turns)
int getUnitSeekAndDestroyMissionValue(Unit unit,
Tile newTile,
int turns)
boolean isTargetValidForSeekAndDestroy(Unit attacker,
Unit defender)
void giveMilitaryMission(AIUnit aiUnit)
Mission to the given unit.
aiUnit - The unit.private void createTransportLists()
Transportables to carrier's using a
TransportMission.
private Unit getBestTreasureTrain(Tile tile)
Tile.
tile - a Tile value
null if no treasure
train is located on this Tile.private void manageMissionaries()
protected java.util.Iterator<AIUnit> getAIUnitIterator()
AIUnits owned by this
player, which currently do _not_ have a goal.
This is a temporary override to allow the old AI code to keep working
with some units, while exempting those already managed by new code.
getAIUnitIterator in class AIPlayerIterator.protected void clearAIUnits()
clearAIUnits in class AIPlayer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||