|
|||||||||
| 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.StandardAIPlayer
public class StandardAIPlayer
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 |
StandardAIPlayer.AIStrategy
|
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private static int |
MAX_DISTANCE_TO_BRING_GIFT
|
private static int |
MAX_DISTANCE_TO_MAKE_DEMANDS
|
private static int |
MAX_NUMBER_OF_DEMANDS
|
private static int |
MAX_NUMBER_OF_GIFTS_BEING_DELIVERED
|
private java.util.HashMap<java.lang.String,java.lang.Integer> |
sessionRegister
Stores temporary information for sessions (trading with another player etc). |
private StandardAIPlayer.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, PARTIAL_ATTRIBUTE |
| Constructor Summary | |
|---|---|
StandardAIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIPlayer and reads the information from the
given Element. |
|
StandardAIPlayer(AIMain aiMain,
ServerPlayer player)
Creates a new AIPlayer. |
|
StandardAIPlayer(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. |
private void |
bringGifts()
Brings gifts to nice players with nearby colonies. |
int |
buyProposition(Unit unit,
Goods goods,
int gold)
Called when another Player proposes a trade. |
private void |
cheat()
Cheats for the AI :-) |
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 |
demandTribute()
Demands goods from players with nearby colonies. |
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. |
(package private) void |
equipSoldiersOutsideColony(Colony colony)
|
private Unit |
getBestTreasureTrain(Tile tile)
Returns the treasure train carrying the largest treasure located on the given Tile. |
private AIUnit |
getBraveForSeekAndDestroy(IndianSettlement indianSettlement)
|
(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 boolean |
isWorkForREF()
Checks if this player has work to do (provided it is an REF-player). |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
private void |
rearrangeWorkersInColonies()
Calls AIColony.rearrangeWorkers(net.sf.freecol.common.networking.Connection) 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 |
(package private) void |
reOrganizeSoldiersOfColony(Colony colony)
|
(package private) void |
secureIndianSettlement(IndianSettlement is)
Takes the necessary actions to secure an indian settlement TODO: Package for access by a test only - necessary? |
private void |
secureSettlements()
Takes the necessary actions to secure the settlements. |
FoundingFather |
selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
Selects the most useful founding father offered. |
void |
startWorking()
Tells this AIPlayer to make decisions. |
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes this object to an XML stream. |
int |
tradeProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a trade. |
| Methods inherited from class net.sf.freecol.server.ai.AIPlayer |
|---|
checkForREFDefeat, clearAIUnits, getAIColonyIterator, getAIUnitIterator, getConnection, getId, getPlayer, recruitAIUnitInEurope, sendAndWaitSafely, sendUpdatedTilesToAll, 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 static final int MAX_DISTANCE_TO_BRING_GIFT
private static final int MAX_NUMBER_OF_GIFTS_BEING_DELIVERED
private static final int MAX_DISTANCE_TO_MAKE_DEMANDS
private static final int MAX_NUMBER_OF_DEMANDS
private StandardAIPlayer.AIStrategy strategy
private java.util.HashMap<java.lang.String,java.lang.Integer> sessionRegister
| Constructor Detail |
|---|
public StandardAIPlayer(AIMain aiMain,
ServerPlayer player)
AIPlayer.
aiMain - The main AI-class.player - The player that should be associated with this
AIPlayer.
public StandardAIPlayer(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 StandardAIPlayer(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,
Goods goods,
int gold)
Player proposes a trade.
buyProposition in class AIPlayerunit - The foreign Unit 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 tradeProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes a trade.
tradeProposition 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 boolean isWorkForREF()
true if any of our units are located in the new
world or if a puppet-nation has declared independence.private void determineStances()
private void abortInvalidMissions()
private void abortInvalidAndOneTimeMissions()
private void giveNavalMissions()
private void rearrangeWorkersInColonies()
AIColony.rearrangeWorkers(net.sf.freecol.common.networking.Connection) for every colony this player
owns.
private void secureSettlements()
void equipSoldiersOutsideColony(Colony colony)
void reOrganizeSoldiersOfColony(Colony colony)
void secureIndianSettlement(IndianSettlement is)
private AIUnit getBraveForSeekAndDestroy(IndianSettlement indianSettlement)
private void giveNormalMissions()
private void bringGifts()
private void demandTribute()
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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||