|
||||||||||
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 |
---|
Fields inherited from class net.sf.freecol.common.model.FreeColObject |
---|
ID_ATTRIBUTE_TAG |
Constructor Summary | |
---|---|
AIPlayer(AIMain aiMain,
java.lang.String id)
|
Method Summary | |
---|---|
abstract boolean |
acceptDiplomaticTrade(DiplomaticTrade agreement)
|
abstract boolean |
acceptIndianDemand(Unit unit,
Colony colony,
Goods goods,
int gold)
Decides whether to accept an Indian demand, or not. |
abstract boolean |
acceptMercenaryOffer()
Decides whether to accept a mercenary offer, or not. |
abstract boolean |
acceptTax(int tax)
Decides whether to accept the monarch's tax raise or not. |
abstract int |
buyProposition(Unit unit,
Goods goods,
int gold)
Called when another Player proposes a trade. |
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. |
abstract java.util.Iterator<TileImprovementPlan> |
getTileImprovementPlanIterator()
Returns an Iterator over all the
TileImprovement s needed by all of this player's colonies. |
abstract 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. |
abstract boolean |
hasFewColonies()
This is a temporary method which are used for forcing the computer players into building more colonies. |
AIUnit |
recruitAIUnitInEurope(int slot)
Helper function for server communication - Ask the server to recruit a unit in Europe on behalf of the AIPlayer. |
abstract void |
registerSellGoods(Goods goods)
Called after another Player sends a trade message |
abstract void |
removeTileImprovementPlan(TileImprovementPlan plan)
Remove a TileImprovementPlan from the list |
abstract FoundingFather |
selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
Selects the most useful founding father offered. |
void |
setDebuggingConnection(Connection debuggingConnection)
Sets the Connection to be used while communicating with
the server. |
abstract void |
startWorking()
Tells this AIPlayer to make decisions. |
abstract int |
tradeProposition(Unit unit,
Settlement settlement,
Goods goods,
int gold)
Called when another Player proposes a trade. |
AIUnit |
trainAIUnitInEurope(UnitType unitType)
Helper function for server communication - Ask the server to train a unit in Europe on behalf of the AIPlayer. |
Methods inherited from class net.sf.freecol.server.ai.AIObject |
---|
dispose, getAIMain, getGame, isUninitialized, readFromXML |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AIPlayer(AIMain aiMain, java.lang.String id)
Method Detail |
---|
public Player getPlayer()
Player
this AIPlayer
is
controlling.
Player
.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 FreeColObject
public AIUnit trainAIUnitInEurope(UnitType unitType)
public AIUnit recruitAIUnitInEurope(int slot)
public abstract void startWorking()
AIPlayer
to make decisions. The
AIPlayer
is done doing work this turn when this method
returns.
NOTE: For the moment, any implementation of this _must_ make sure
to call checkForREFDefeat() at the start of a turn,
if the player this AI works for isREF(). See TODO at that method.
public abstract java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
Iterator
over all the
TileImprovement
s needed by all of this player's colonies.
Iterator
.TileImprovement
public abstract void removeTileImprovementPlan(TileImprovementPlan plan)
TileImprovementPlan
from the list
public abstract boolean hasFewColonies()
true
if the AI should build more colonies.public abstract 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
.Wish
public abstract FoundingFather selectFoundingFather(java.util.List<FoundingFather> foundingFathers)
foundingFathers
- The founding fathers on offer.
public abstract boolean acceptTax(int tax)
tax
- The new tax rate to be considered.
true
if the tax raise should be accepted.public abstract 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 abstract boolean acceptMercenaryOffer()
true
if this AIPlayer
accepts the
offer and false
otherwise.public abstract boolean acceptDiplomaticTrade(DiplomaticTrade agreement)
public abstract void registerSellGoods(Goods goods)
Player
sends a trade
message
goods
- The goods which we are going to offerpublic abstract int buyProposition(Unit unit, Goods goods, int gold)
Player
proposes a trade.
unit
- 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 abstract 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 static java.lang.String getXMLElementTagName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |