|
|||||||||
| 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
public abstract class AIPlayer
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 java.util.List<AIUnit> |
aiUnits
Temporary variable, used to hold all AIUnit objects belonging to this AI. |
private Connection |
debuggingConnection
Temporary variable, used for debugging purposes only. |
private static java.util.logging.Logger |
logger
|
static int |
MAX_DISTANCE_TO_BRING_GIFT
|
static int |
MAX_DISTANCE_TO_MAKE_DEMANDS
|
static int |
MAX_NUMBER_OF_DEMANDS
|
static int |
MAX_NUMBER_OF_GIFTS_BEING_DELIVERED
|
private ServerPlayer |
player
The FreeColGameObject this AIObject contains AI-information for. |
| 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 | |
|---|---|
AIPlayer(AIMain aiMain,
java.lang.String id)
|
|
| Method Summary | |
|---|---|
protected void |
abortInvalidAndOneTimeMissions()
Aborts all the missions which are no longer valid. |
protected void |
abortInvalidMissions()
Aborts all the missions which are no longer valid. |
abstract boolean |
acceptDiplomaticTrade(DiplomaticTrade agreement)
Returns an Iterator for all the wishes. |
abstract int |
buyProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes to buy. |
protected void |
clearAIUnits()
Clears the cache of AI units. |
private void |
createAIUnits()
Build the cache of AI units. |
protected Player.Stance |
determineStance(Player other)
Standard stance change determination. |
protected void |
determineStances()
Determines the stances towards each player. |
protected void |
doMissions()
Makes every unit perform their mission. |
protected AIColony |
getAIColony(Colony colony)
Gets the AI colony corresponding to a given colony, if any. |
protected java.util.Iterator<AIColony> |
getAIColonyIterator()
Returns an iterator over all the AIColonys owned by this
player. |
protected AIUnit |
getAIUnit(Unit unit)
Gets the AI unit corresponding to a given unit, if any. |
protected java.util.Iterator<AIUnit> |
getAIUnitIterator()
Returns an iterator over all the AIUnits owned by this
player. |
protected java.util.List<AIUnit> |
getAIUnits()
Gets a list of AIUnits for the player. |
Connection |
getConnection()
Gets the connection to the server. |
java.lang.String |
getId()
Returns the ID for this AIPlayer. |
Player |
getPlayer()
Returns the Player this AIPlayer is
controlling. |
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
boolean |
isTargetValidForSeekAndDestroy(Unit attacker,
Tile tile)
Find out if a tile contains a suitable target for seek-and-destroy. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
abstract void |
registerSellGoods(Goods goods)
Called after another Player sends a trade message |
abstract int |
sellProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a sale. |
void |
setDebuggingConnection(Connection debuggingConnection)
Sets the Connection to be used while communicating with
the server. |
protected void |
setPlayer(ServerPlayer p)
Sets the ServerPlayer this AIPlayer is controlling. |
abstract 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.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
public static final int MAX_DISTANCE_TO_BRING_GIFT
public static final int MAX_NUMBER_OF_GIFTS_BEING_DELIVERED
public static final int MAX_DISTANCE_TO_MAKE_DEMANDS
public static final int MAX_NUMBER_OF_DEMANDS
private ServerPlayer player
private Connection debuggingConnection
private java.util.List<AIUnit> aiUnits
| Constructor Detail |
|---|
public AIPlayer(AIMain aiMain,
java.lang.String id)
| Method Detail |
|---|
public Player getPlayer()
Player this AIPlayer is
controlling.
Player.protected void setPlayer(ServerPlayer p)
public java.lang.String getId()
AIPlayer. This is the same as the
ID for the Player this AIPlayer controls.
getId in class FreeColObjectpublic Connection getConnection()
public void setDebuggingConnection(Connection debuggingConnection)
Connection to be used while communicating with
the server.
This method is only used for debugging.
debuggingConnection - The connection to be used for debugging.protected void clearAIUnits()
private void createAIUnits()
protected java.util.List<AIUnit> getAIUnits()
protected java.util.Iterator<AIUnit> getAIUnitIterator()
AIUnits owned by this
player.
Iterator.protected java.util.Iterator<AIColony> getAIColonyIterator()
AIColonys owned by this
player.
Iterator.protected AIColony getAIColony(Colony colony)
colony - The Colony to look up.
protected AIUnit getAIUnit(Unit unit)
unit - The Unit to look up.
protected Player.Stance determineStance(Player other)
other - The Player wrt consider stance.
public abstract void startWorking()
AIPlayer to make decisions. The
AIPlayer is done doing work this turn when this method
returns.
public abstract boolean acceptDiplomaticTrade(DiplomaticTrade agreement)
Iterator for all the wishes. The items are
sorted by the value, with the item having the
highest value appearing first in the Iterator.
Iterator.Wishpublic abstract void registerSellGoods(Goods goods)
Player sends a trade message
goods - The goods which we are going to offer
public abstract int buyProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes to buy.
unit - 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 abstract int sellProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes a sale.
unit - 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 determineStances()
protected void abortInvalidMissions()
protected void abortInvalidAndOneTimeMissions()
protected void doMissions()
public boolean isTargetValidForSeekAndDestroy(Unit attacker,
Tile tile)
attacker - The attacking Unit.tile - The Tile to attack into.
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class FreeColObjectout - 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 FreeColObjectin - 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()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||