|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.server.ai.AIObject
net.sf.freecol.server.ai.AIPlayer
public 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 | |
|---|---|
static java.lang.String |
COPYRIGHT
|
static java.lang.String |
LICENSE
|
static java.lang.String |
REVISION
|
static int |
STRATEGY_CONQUEST
|
static int |
STRATEGY_COOPERATION
|
static int |
STRATEGY_IMMIGRATION
|
static int |
STRATEGY_NONE
|
static int |
STRATEGY_TRADE
|
| Fields inherited from class net.sf.freecol.server.ai.AIObject |
|---|
id, uninitialized |
| Constructor Summary | |
|---|---|
AIPlayer(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIPlayer and reads the information from the
given Element. |
|
AIPlayer(AIMain aiMain,
ServerPlayer player)
Creates a new AIPlayer. |
|
AIPlayer(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIPlayer. |
|
| Method Summary | |
|---|---|
boolean |
acceptIndianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
Decides whether to accept an Indian demand, or not. |
boolean |
acceptTax(int tax)
Decides whether to accept the monarch's tax raise or not. |
java.util.Iterator<AIColony> |
getAIColonyIterator()
Returns an iterator over all the AIColonys owned by this
player. |
java.util.Iterator<AIUnit> |
getAIUnitIterator()
Returns an iterator over all the AIUnits owned by this
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. |
int |
getStrategy()
Returns the strategy of this AIPlayer. |
java.util.Iterator<TileImprovement> |
getTileImprovementIterator()
Returns an Iterator over all the
TileImprovements needed by all of this player's colonies. |
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. |
boolean |
hasFewColonies()
This is a temporary method which are used for forcing the computer players into building more colonies. |
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
int |
selectFoundingFather(int[] foundingFathers)
Selects the most useful founding father offered. |
void |
setDebuggingConnection(Connection debuggingConnection)
Sets the Connection to be used while communicating with
the server. |
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.AIObject |
|---|
dispose, getAIMain, getGame, getRandom, isUninitialized, readFromXML, readFromXMLElement, toXML, toXMLElement |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String COPYRIGHT
public static final java.lang.String LICENSE
public static final java.lang.String REVISION
public static final int STRATEGY_NONE
public static final int STRATEGY_TRADE
public static final int STRATEGY_IMMIGRATION
public static final int STRATEGY_COOPERATION
public static final int STRATEGY_CONQUEST
| Constructor Detail |
|---|
public AIPlayer(AIMain aiMain,
ServerPlayer player)
AIPlayer.
aiMain - The main AI-class.player - The player that should be associated with this
AIPlayer.
public AIPlayer(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 AIPlayer(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.
public java.util.Iterator<TileImprovement> getTileImprovementIterator()
Iterator over all the
TileImprovements needed by all of this player's colonies.
Iterator.TileImprovementpublic boolean hasFewColonies()
true 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.
Iterator.Wishpublic int selectFoundingFather(int[] foundingFathers)
foundingFathers - The founding fathers on offer.
public int tradeProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Player proposes a trade.
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.public boolean acceptTax(int tax)
tax - 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)
unit - 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 java.util.Iterator<AIUnit> getAIUnitIterator()
AIUnits owned by this
player.
Iterator.public java.util.Iterator<AIColony> getAIColonyIterator()
AIColonys owned by this
player.
Iterator.public Player getPlayer()
Player this AIPlayer is
controlling.
Player.public int getStrategy()
AIPlayer.
AIPlayer.public 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.public java.lang.String getID()
AIPlayer. This is the same as the
ID for the Player this AIPlayer controls.
getID in class AIObject
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class AIObjectout - 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 AIObjectin - 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 | ||||||||