|
|||||||||
| 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.EuropeanAIPlayer
public class EuropeanAIPlayer
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.
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private java.util.HashMap<java.lang.String,java.lang.Integer> |
sessionRegister
Stores temporary information for sessions (trading with another player etc). |
| 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 | |
|---|---|
EuropeanAIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIPlayer and reads the information from the
given Element. |
|
EuropeanAIPlayer(AIMain aiMain,
ServerPlayer player)
Creates a new AIPlayer. |
|
EuropeanAIPlayer(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIPlayer. |
|
| Method Summary | |
|---|---|
boolean |
acceptDiplomaticTrade(DiplomaticTrade agreement)
|
boolean |
acceptMercenaries()
Decides to accept an offer of mercenaries 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,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes to buy. |
private void |
cheat()
Cheats for the AI. |
Ownable |
chooseMilitaryTarget(AIUnit aiUnit)
Chooses the best target for an AI unit to attack. |
private void |
createAIGoodsInColonies()
Calls AIColony.createAIGoods() for every colony this player owns. |
private void |
createTransportLists()
Assign transportable units and goods to available carriers transport lists. |
private void |
demandTribute()
Demands goods from players with nearby colonies. |
private void |
ensureColonyMissions()
Ensures that all workers inside a colony gets a WorkInsideColonyMission. |
private Unit |
getBestTreasureTrain(Tile tile)
Finds the treasure train carrying the largest treasure located on the given Tile. |
protected int |
getColonyDefenders(Colony colony)
Counts the number of defenders in a colony. |
int |
getDefendColonyMissionValue(Unit unit,
Colony colony,
int turns)
Evaluate allocating a unit to the defence of a colony. |
private java.util.List<AIUnit> |
getPlayerPioneers()
Takes the necessary actions to secure a european colony |
private int |
getScaledTurns(java.util.Map<Location,java.lang.Integer> distances,
Location destination)
|
java.util.List<TileImprovementPlan> |
getTileImprovementPlans()
Gets a list of all the player's tile improvement plans required by the colonies. |
private int |
getTurns(Transportable t,
TransportMission tm)
|
int |
getUnitSeekAndDestroyMissionValue(Unit unit,
Tile newTile,
int turns)
Evaluate a potential seek and destroy mission for a given unit to a given tile. |
java.util.List<Wish> |
getWishes()
Gets the wishes for all this player's colonies, sorted by the value. |
private void |
giveColonistMission(AIUnit aiUnit,
boolean fewColonies,
java.util.Map<UnitType,java.util.ArrayList<Wish>> workerWishes)
|
void |
giveMilitaryMission(AIUnit aiUnit)
Gives a military mission to the given unit. |
protected 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. |
boolean |
indianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
Decides whether to accept an Indian demand, or not. |
private void |
rearrangeWorkersInColonies()
Calls AIColony.rearrangeWorkers() for every colony this player
owns. |
AIUnit |
recruitAIUnitInEurope(int index)
Asks the server to recruit a unit in Europe on behalf of the AIPlayer. |
void |
registerSellGoods(Goods goods)
Called after another Player sends a trade message |
void |
removeTileImprovementPlan(TileImprovementPlan plan)
Remove a TileImprovementPlan from the relevant colony. |
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. |
AIUnit |
trainAIUnitInEurope(UnitType unitType)
Helper function for server communication - Ask the server to train a unit in Europe on behalf of the AIGetPlayer(). |
| 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 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 java.util.HashMap<java.lang.String,java.lang.Integer> sessionRegister
| Constructor Detail |
|---|
public EuropeanAIPlayer(AIMain aiMain,
ServerPlayer player)
AIPlayer.
aiMain - The main AI-class.player - The player that should be associated with this
AIPlayer.
public EuropeanAIPlayer(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 EuropeanAIPlayer(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.List<TileImprovementPlan> getTileImprovementPlans()
TileImprovementpublic void removeTileImprovementPlan(TileImprovementPlan plan)
TileImprovementPlan from the relevant colony.
public AIUnit recruitAIUnitInEurope(int index)
index - The index of the unit to recruit in the recruitables list,
(if not a valid index, recruit a random unit).
public AIUnit trainAIUnitInEurope(UnitType unitType)
public boolean hasFewColonies()
true if the AI should build more colonies.public java.util.List<Wish> getWishes()
value.
public 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 indianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
indianDemand 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.
public boolean acceptMercenaries()
acceptMercenaries in class AIPlayerpublic 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 to buy.
buyProposition in class AIPlayerunit - The foreign Unit trying to trade.settlement - The Settlement this player owns and
which the given Unit is trading.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.private void cheat()
private void ensureColonyMissions()
WorkInsideColonyMission.
private void rearrangeWorkersInColonies()
AIColony.rearrangeWorkers() for every colony this player
owns.
private java.util.List<AIUnit> getPlayerPioneers()
protected void giveNormalMissions()
private void giveColonistMission(AIUnit aiUnit,
boolean fewColonies,
java.util.Map<UnitType,java.util.ArrayList<Wish>> workerWishes)
private int getScaledTurns(java.util.Map<Location,java.lang.Integer> distances,
Location destination)
private void bringGifts()
private void demandTribute()
private void createAIGoodsInColonies()
AIColony.createAIGoods() for every colony this player owns.
protected int getColonyDefenders(Colony colony)
colony - The Colony to examine.
public int getDefendColonyMissionValue(Unit unit,
Colony colony,
int turns)
unit - The Unit that is to defend.colony - The Colony to defend.turns - The turns for the unit to reach the colony.
public int getUnitSeekAndDestroyMissionValue(Unit unit,
Tile newTile,
int turns)
unit - The Unit to do the mission.newTile - The Tile to go to.turns - How long to travel to the tile.
public Ownable chooseMilitaryTarget(AIUnit aiUnit)
aiUnit - The AIUnit that will attack.
public void giveMilitaryMission(AIUnit aiUnit)
aiUnit - The AIUnit to give a mission to.
private int getTurns(Transportable t,
TransportMission tm)
private void createTransportLists()
private Unit getBestTreasureTrain(Tile tile)
Tile.
tile - The Tile to check.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||