net.sf.freecol.server.ai
Class NewAIPlayer

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.server.ai.AIObject
          extended by net.sf.freecol.server.ai.NewAIPlayer
Direct Known Subclasses:
EuropeanAIPlayer, IndianAIPlayer

Deprecated. Currently unused, outdated copy of AIPlayer. Eventual specialization of AI should extend AIPlayer, see ColonialAIPlayer. The method startWorking() gets called by the AIInGameInputHandler when it is this player's turn.

public abstract class NewAIPlayer
extends AIObject

Objects of this class contains AI-information for a single Player and is used for controlling this player.


Field Summary
private  java.util.ArrayList<AIUnit> aiUnits
          Deprecated. Temporary variable.
private  Connection debuggingConnection
          Deprecated. Temporary variable.
protected static EquipmentType horses
          Deprecated.  
private static java.util.logging.Logger logger
          Deprecated.  
protected static EquipmentType muskets
          Deprecated.  
private  ServerPlayer player
          Deprecated. The FreeColGameObject this AIObject contains AI-information for.
protected  java.util.HashMap<java.lang.String,java.lang.Integer> sessionRegister
          Deprecated.  
protected static EquipmentType toolsType
          Deprecated.  
 
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, PARTIAL_ATTRIBUTE
 
Constructor Summary
NewAIPlayer()
          Deprecated.  
NewAIPlayer(AIMain aiMain, org.w3c.dom.Element element)
          Deprecated. Creates a new AIPlayer and reads the information from the given Element.
NewAIPlayer(AIMain aiMain, ServerPlayer player)
          Deprecated. Creates a new AIPlayer.
NewAIPlayer(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Deprecated. Creates a new AIPlayer.
 
Method Summary
protected  void abortInvalidAndOneTimeMissions()
          Deprecated. Aborts all the missions which are no longer valid.
protected  void abortInvalidMissions()
          Deprecated. Aborts all the missions which are no longer valid.
 int buyProposition(Unit unit, Goods goods, int gold)
          Deprecated. Called when another Player proposes a trade.
protected  void clearAIUnits()
          Deprecated.  
protected  void determineStances()
          Deprecated. Determines the stances towards each player.
protected  void doMissions()
          Deprecated. Makes every unit perform their mission.
 java.util.Iterator<AIUnit> getAIUnitIterator()
          Deprecated. Returns an iterator over all the AIUnits owned by this player.
 Unit getBestTreasureTrain(Tile tile)
          Deprecated. Returns the treasure train carrying the largest treasure located on the given Tile.
 Connection getConnection()
          Deprecated. Gets the connection to the server.
 java.lang.String getId()
          Deprecated. Returns the ID for this AIPlayer.
 Player getPlayer()
          Deprecated. Returns the Player this AIPlayer is controlling.
(package private)  int getUnitSeekAndDestroyMissionValue(Unit unit, Tile newTile, int turns)
          Deprecated.  
static java.lang.String getXMLElementTagName()
          Deprecated. Returns the tag name of the root element representing this object.
(package private)  boolean isTargetValidForSeekAndDestroy(Unit attacker, Unit defender)
          Deprecated.  
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Deprecated. Reads information for this object from an XML stream.
 void registerSellGoods(Goods goods)
          Deprecated. Called after another Player sends a trade message
protected  void sendAndWaitSafely(org.w3c.dom.Element element)
          Deprecated. Send an element and ignore IO exceptions.
protected  void sendUpdatedTilesToAll(java.util.ArrayList<Tile> tiles)
          Deprecated. Send some tiles to update to all players which can see them
 void setDebuggingConnection(Connection debuggingConnection)
          Deprecated. Sets the Connection to be used while communicating with the server.
abstract  void startWorking()
          Deprecated. Tells this AIPlayer to make decisions.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Deprecated. 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 net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readChildren, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, setId, toArrayElement, toArrayElement, toListElement, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
Deprecated. 

muskets

protected static EquipmentType muskets
Deprecated. 

horses

protected static EquipmentType horses
Deprecated. 

toolsType

protected static EquipmentType toolsType
Deprecated. 

sessionRegister

protected java.util.HashMap<java.lang.String,java.lang.Integer> sessionRegister
Deprecated. 

player

private ServerPlayer player
Deprecated. 
The FreeColGameObject this AIObject contains AI-information for.


aiUnits

private java.util.ArrayList<AIUnit> aiUnits
Deprecated. 
Temporary variable.


debuggingConnection

private Connection debuggingConnection
Deprecated. 
Temporary variable.

Constructor Detail

NewAIPlayer

public NewAIPlayer()
Deprecated. 

NewAIPlayer

public NewAIPlayer(AIMain aiMain,
                   ServerPlayer player)
Deprecated. 
Creates a new AIPlayer.

Parameters:
aiMain - The main AI-class.
player - The player that should be associated with this AIPlayer.

NewAIPlayer

public NewAIPlayer(AIMain aiMain,
                   org.w3c.dom.Element element)
Deprecated. 
Creates a new AIPlayer and reads the information from the given Element.

Parameters:
aiMain - The main AI-class.
element - The XML-element containing information.

NewAIPlayer

public NewAIPlayer(AIMain aiMain,
                   javax.xml.stream.XMLStreamReader in)
            throws javax.xml.stream.XMLStreamException
Deprecated. 
Creates a new AIPlayer.

Parameters:
aiMain - The main AI-object.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
Method Detail

startWorking

public abstract void startWorking()
Deprecated. 
Tells this AIPlayer to make decisions. The AIPlayer is done doing work this turn when this method returns.


determineStances

protected void determineStances()
Deprecated. 
Determines the stances towards each player. That is: should we declare war?


abortInvalidMissions

protected void abortInvalidMissions()
Deprecated. 
Aborts all the missions which are no longer valid.


abortInvalidAndOneTimeMissions

protected void abortInvalidAndOneTimeMissions()
Deprecated. 
Aborts all the missions which are no longer valid.


sendAndWaitSafely

protected void sendAndWaitSafely(org.w3c.dom.Element element)
Deprecated. 
Send an element and ignore IO exceptions. This was used all over the place, no better use a single method.

Parameters:
element - The element.

sendUpdatedTilesToAll

protected void sendUpdatedTilesToAll(java.util.ArrayList<Tile> tiles)
Deprecated. 
Send some tiles to update to all players which can see them

Parameters:
tiles - The tiles to update.

doMissions

protected void doMissions()
Deprecated. 
Makes every unit perform their mission.


getBestTreasureTrain

public Unit getBestTreasureTrain(Tile tile)
Deprecated. 
Returns the treasure train carrying the largest treasure located on the given Tile.

Parameters:
tile - a Tile value
Returns:
The best treasure train or null if no treasure train is located on this Tile.

getUnitSeekAndDestroyMissionValue

int getUnitSeekAndDestroyMissionValue(Unit unit,
                                      Tile newTile,
                                      int turns)
Deprecated. 

isTargetValidForSeekAndDestroy

boolean isTargetValidForSeekAndDestroy(Unit attacker,
                                       Unit defender)
Deprecated. 

getAIUnitIterator

public java.util.Iterator<AIUnit> getAIUnitIterator()
Deprecated. 
Returns an iterator over all the AIUnits owned by this player.

Returns:
The Iterator.

getPlayer

public Player getPlayer()
Deprecated. 
Returns the Player this AIPlayer is controlling.

Returns:
The Player.

getConnection

public Connection getConnection()
Deprecated. 
Gets the connection to the server.

Returns:
The connection that can be used when communication with the server.

setDebuggingConnection

public void setDebuggingConnection(Connection debuggingConnection)
Deprecated. 
Sets the Connection to be used while communicating with the server. This method is only used for debugging.

Parameters:
debuggingConnection - The connection to be used for debugging.

getId

public java.lang.String getId()
Deprecated. 
Returns the ID for this AIPlayer. This is the same as the ID for the Player this AIPlayer controls.

Overrides:
getId in class FreeColObject
Returns:
The ID.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Deprecated. 
Writes this object to an XML stream.

Specified by:
toXMLImpl in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Deprecated. 
Reads information for this object from an XML stream.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems reading from the stream.

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Deprecated. 
Returns the tag name of the root element representing this object.

Returns:
the tag name.

registerSellGoods

public void registerSellGoods(Goods goods)
Deprecated. 
Called after another Player sends a trade message

Parameters:
goods - The goods which we are going to offer

buyProposition

public int buyProposition(Unit unit,
                          Goods goods,
                          int gold)
Deprecated. 
Called when another Player proposes a trade.

Parameters:
unit - The foreign Unit trying to trade.
goods - The goods the given Unit is trying to sell.
gold - The suggested price.
Returns:
The price this AIPlayer suggests or NetworkConstants.NO_TRADE.

clearAIUnits

protected void clearAIUnits()
Deprecated.