|
|||||||||
| 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.AIColony
public class AIColony
Objects of this class contains AI-information for a single Colony.
| Nested Class Summary | |
|---|---|
private static class |
AIColony.ExperienceUpgrade
|
| Field Summary | |
|---|---|
private java.util.ArrayList<AIGoods> |
aiGoods
|
private Colony |
colony
The FreeColGameObject this AIObject contains AI-information for. |
private ColonyPlan |
colonyPlan
|
private static java.util.logging.Logger |
logger
|
private boolean |
rearrangeWorkers
Records whether the workers in this Colony need to be rearranged. |
private java.util.ArrayList<TileImprovementPlan> |
tileImprovementPlans
|
private java.util.ArrayList<Wish> |
wishes
|
| 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 | |
|---|---|
AIColony(AIMain aiMain,
Colony colony)
Creates a new AIColony. |
|
AIColony(AIMain aiMain,
org.w3c.dom.Element element)
Creates a new AIColony. |
|
AIColony(AIMain aiMain,
java.lang.String id)
Creates a new AIColony. |
|
AIColony(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
Creates a new AIColony. |
|
| Method Summary | |
|---|---|
void |
addGoodsWish(GoodsWish gw)
Add a GoodsWish to the wish list. |
static Unit |
bestUnitForWorkLocation(java.util.Collection<Unit> units,
WorkLocation workLocation,
GoodsType goodsType)
|
boolean |
canBuildEquipment(EquipmentType equipmentType)
Returns true if this AIColony can build the given
type of equipment. |
(package private) void |
checkConditionsForHorseBreed()
Verifies if the Colony has conditions for breeding horses,
and un-mounts a mounted Unit if available, to have horses to breed. |
private void |
checkForUnarmedExpertSoldier()
Checks if the colony has an unarmed expert soldier inside If there are conditions to arm it, put it outside for later equip |
private void |
checkForUnequippedExpertPioneer()
|
private boolean |
colonyCouldProduce(GoodsType goodsType)
|
void |
createAIGoods()
Creates a list of the goods which should be shipped out of this colony. |
private void |
createGoodsWishes()
|
void |
createTileImprovementPlans()
Creates a list of the Tile-improvements which will
increase the production by this Colony. |
private void |
createWishes()
Creates the wishes for the Colony. |
private void |
createWorkerWishes()
|
private void |
decideBuildable(Connection connection)
Decides what to build in the Colony. |
void |
dispose()
Disposes this AIColony. |
java.util.Iterator<AIGoods> |
getAIGoodsIterator()
Returns an Iterator of the goods to be shipped from this
colony. |
protected AIPlayer |
getAIOwner()
|
protected AIUnit |
getAIUnit(Unit unit)
|
int |
getAvailableGoods(GoodsType goodsType)
Returns the available amount of the GoodsType given. |
static UnitType |
getBestDefender(Colony colony)
Returns the best defender for the given colony. |
private ColonyTile |
getBestVacantTile(Unit unit,
GoodsType goodsType)
Find a colony's best tile to put a unit to produce a type of goods. |
Colony |
getColony()
Gets the Colony this AIColony controls. |
ColonyPlan |
getColonyPlan()
|
protected Connection |
getConnection()
|
private static AIColony.ExperienceUpgrade |
getExperienceUpgrade(Unit unit,
UnitType expert)
|
private int |
getHammersRequired(BuildableType buildableType)
|
private UnitType |
getNextExpert(boolean onlyFood)
|
java.util.Iterator<TileImprovementPlan> |
getTileImprovementPlanIterator()
Returns an Iterator over all the
TileImprovementPlans needed by this colony. |
private int |
getToolsRequired(BuildableType buildableType)
|
java.util.Iterator<Wish> |
getWishIterator()
Gets an Iterator for every Wish the
Colony has. |
java.util.List<WorkerWish> |
getWorkerWishes()
|
static java.lang.String |
getXMLElementTagName()
Returns the tag name of the root element representing this object. |
boolean |
isBadlyDefended()
|
private void |
placeExpertsInWorkPlaces(java.util.List<Unit> units,
java.util.List<WorkLocationPlan> workLocationPlans)
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Reads information for this object from an XML stream. |
boolean |
rearrangeWorkers(Connection connection)
Rearranges the workers within this colony. |
void |
removeAIGoods(AIGoods ag)
Removes the given AIGoods from this colony's list. |
boolean |
removeTileImprovementPlan(TileImprovementPlan plan)
Removes a TileImprovementPlan from the list |
void |
removeWish(Wish w)
|
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Writes this object to an XML stream. |
private boolean |
tryUseTile(Tile tile)
Try to use a tile. |
| Methods inherited from class net.sf.freecol.server.ai.AIObject |
|---|
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 Colony colony
private ColonyPlan colonyPlan
private java.util.ArrayList<AIGoods> aiGoods
private java.util.ArrayList<Wish> wishes
private java.util.ArrayList<TileImprovementPlan> tileImprovementPlans
private boolean rearrangeWorkers
| Constructor Detail |
|---|
public AIColony(AIMain aiMain,
Colony colony)
AIColony.
aiMain - The main AI-object.colony - The colony to make an AIObject for.
public AIColony(AIMain aiMain,
org.w3c.dom.Element element)
AIColony.
aiMain - The main AI-object.element - An Element containing an XML-representation
of this object.
public AIColony(AIMain aiMain,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
AIColony.
aiMain - The main AI-object.in - The input stream containing the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
public AIColony(AIMain aiMain,
java.lang.String id)
AIColony.
aiMain - The main AI-object.id - | Method Detail |
|---|
protected AIUnit getAIUnit(Unit unit)
protected AIPlayer getAIOwner()
protected Connection getConnection()
public Colony getColony()
Colony this AIColony controls.
Colony.public void dispose()
AIColony.
dispose in class AIObjectpublic java.util.Iterator<AIGoods> getAIGoodsIterator()
Iterator of the goods to be shipped from this
colony. The item with the highest
transport priority gets
returned first by this Iterator.
Iterator.public java.util.Iterator<Wish> getWishIterator()
Iterator for every Wish the
Colony has.
Iterator. The items with the
highest value appears first in the
IteratorWishpublic java.util.List<WorkerWish> getWorkerWishes()
public void createTileImprovementPlans()
Tile-improvements which will
increase the production by this Colony.
TileImprovementPlanpublic java.util.Iterator<TileImprovementPlan> getTileImprovementPlanIterator()
Iterator over all the
TileImprovementPlans needed by this colony.
Iterator.TileImprovementPlanpublic boolean removeTileImprovementPlan(TileImprovementPlan plan)
TileImprovementPlan from the list
private void createWishes()
Colony.
private void createWorkerWishes()
public static UnitType getBestDefender(Colony colony)
colony - a Colony value
UnitType valueprivate void createGoodsWishes()
private boolean colonyCouldProduce(GoodsType goodsType)
private UnitType getNextExpert(boolean onlyFood)
private int getToolsRequired(BuildableType buildableType)
private int getHammersRequired(BuildableType buildableType)
public boolean isBadlyDefended()
public void removeWish(Wish w)
public void addGoodsWish(GoodsWish gw)
GoodsWish to the wish list.
gw - The GoodsWish to be added.public void removeAIGoods(AIGoods ag)
AIGoods from this colony's list. The
AIGoods-object is not disposed as part of this operation.
Use that method instead to remove the object completely (this method
would then be called indirectly).
ag - The AIGoods to be removed.AIGoods.dispose()public void createAIGoods()
getAIGoodsIterator() returns the
Iterator for.
public int getAvailableGoods(GoodsType goodsType)
public boolean canBuildEquipment(EquipmentType equipmentType)
true if this AIColony can build the given
type of equipment. Unlike the method of the Colony, this takes
goods "reserved" for building or breeding purposes into account.
equipmentType - an EquipmentType value
boolean valueSettlement.canBuildEquipment(EquipmentType equipmentType)private boolean tryUseTile(Tile tile)
tile - The Tile to use.
private ColonyTile getBestVacantTile(Unit unit,
GoodsType goodsType)
unit - The Unit to work the tile.goodsType - The type of goods to produce.
public boolean rearrangeWorkers(Connection connection)
ColonyPlan, although minor adjustments can be done to increase
production.
connection - The Connection to be used when
communicating with the server.private void checkForUnequippedExpertPioneer()
public static Unit bestUnitForWorkLocation(java.util.Collection<Unit> units,
WorkLocation workLocation,
GoodsType goodsType)
private static AIColony.ExperienceUpgrade getExperienceUpgrade(Unit unit,
UnitType expert)
private void checkForUnarmedExpertSoldier()
void checkConditionsForHorseBreed()
Colony has conditions for breeding horses,
and un-mounts a mounted Unit if available, to have horses to breed.
private void placeExpertsInWorkPlaces(java.util.List<Unit> units,
java.util.List<WorkLocationPlan> workLocationPlans)
private void decideBuildable(Connection connection)
Colony.
connection - The connection to use when communicating with the
server.public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange in interface java.beans.PropertyChangeListenerpublic ColonyPlan getColonyPlan()
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 | ||||||||