j4cevo
Class Brain

java.lang.Object
  extended byj4cevo.Brain
Direct Known Subclasses:
Brain, DefaultBrain

public abstract class Brain
extends java.lang.Object

A brain belongs to one particular player and is informed whenever any action for this player is required. Brain receives all calls from the game server.
To build your own AI this class has to be subclassed. In order to be load at runtime, the customized AI has to be compiled and reside in the same directory as j4cEvo.dll and cEvo. exe. j4cEvo uses a standard property file named j4cEvo.properties to determine which AI to use for which seat number (AFAIK this is the only information passed from cEvo).
example for sampleai.Player on seat 8:
8=sampleai/Brain
please note the slash as package separator
When running cEvo, just place j4cEvo on a seat(in cEvo 0.9.1 left top seat has number 8), other as follows
812
703
654
j4cEvo will load the mentioned class. Additionaly this class is used as a Factory for managed objects - according create methods may be overriden to create customized versions of the managed objects.


Constructor Summary
Brain()
           
 
Method Summary
protected abstract  void breakGame()
          Called just before the game ends.
protected abstract  void cityChanged(int index)
          Called when a new city was founded.
protected abstract  void contactAccepted()
          Diplomacy: Enemy has accepted contact request.
protected abstract  void contactEnded()
          Diplomacy: Enemy end negotiation (Not fully understood by me, needs further investigation. okrumnow)
protected abstract  void contactRejected()
          Diplomacy: Enemy rejected contact request (Not fully understood by me, needs further investigation. okrumnow)
protected abstract  void contactRequested(Enemy e)
          Called when another player tries to start Diplomacy with us.
protected  City createCity()
          Hook for subclasses.
protected  Enemy createEnemy()
          Hook for subclasses.
protected  EnemyCity createEnemyCity()
          Hook for subclasses.
protected  EnemyModel createEnemyModel()
          Hook for subclasses.
protected  EnemyUnit createEnemyUnit()
          Hook for subclasses.
protected  Model createModel()
          Hook for subclasses.
protected  PlayerCity createPlayerCity()
          Hook for subclasses.
protected  Unit createUnit()
          Hook for subclasses.
protected abstract  void decisionNoticed()
          Diplomacy: Enemy has noticed latest decision, continue with negotiation now.
 Player getPlayer()
          Gets the player attribute of the Brain object
protected abstract  void getReady()
          Calls just before the first turn after starting or loading a game.
protected abstract  void negotiationBroken()
          Diplomacy: Enemy has broken negotiation.
protected abstract  void offerAccepted()
          Diplomacy: Enemy accepts latest offer.
protected abstract  void receiveOffer(Offer offer)
          Diplomacy: Enemy makes an offer.
protected abstract  void treatyCanceled(Enemy e)
          Diplomacy: Enemy cancels current treaty.
protected abstract  void turn()
          Player is due to make a turn.
protected abstract  void unitMoved(java.nio.ByteBuffer b, int command)
          An enemy unit has moved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Brain

public Brain()
Method Detail

getReady

protected abstract void getReady()
Calls just before the first turn after starting or loading a game.


breakGame

protected abstract void breakGame()
Called just before the game ends.


cityChanged

protected abstract void cityChanged(int index)
Called when a new city was founded. (not necessarily the player's one ???)

Parameters:
index - Index of the city

contactAccepted

protected abstract void contactAccepted()
Diplomacy: Enemy has accepted contact request. (Not fully understood by me, needs further investigation. okrumnow)


contactEnded

protected abstract void contactEnded()
Diplomacy: Enemy end negotiation (Not fully understood by me, needs further investigation. okrumnow)


contactRejected

protected abstract void contactRejected()
Diplomacy: Enemy rejected contact request (Not fully understood by me, needs further investigation. okrumnow)


contactRequested

protected abstract void contactRequested(Enemy e)
Called when another player tries to start Diplomacy with us.

Parameters:
e - The enemy that started Diplomacy

createCity

protected City createCity()
Hook for subclasses. Override this method to provide a cutomized City

Returns:
a newly created City

createEnemy

protected Enemy createEnemy()
Hook for subclasses. Override this method to provide a cutomized Enemy

Returns:
a newly created Enemy

createEnemyCity

protected EnemyCity createEnemyCity()
Hook for subclasses. Override this method to provide a cutomized EnemyCity

Returns:
a newly created EnemyCity

createEnemyModel

protected EnemyModel createEnemyModel()
Hook for subclasses. Override this method to provide a cutomized EnemyModel

Returns:
a newly created EnemyModel

createEnemyUnit

protected EnemyUnit createEnemyUnit()
Hook for subclasses. Override this method to provide a cutomized EnemyUnit

Returns:
a newly created EnemyUnit

createModel

protected Model createModel()
Hook for subclasses. Override this method to provide a cutomized Model

Returns:
a newly created Model

createPlayerCity

protected PlayerCity createPlayerCity()
Hook for subclasses. Override this method to provide a cutomized PlayerCity

Returns:
a newly created PlayerCity

createUnit

protected Unit createUnit()
Hook for subclasses. Override this method to provide a cutomized Unit

Returns:
a newly created Unit

decisionNoticed

protected abstract void decisionNoticed()
Diplomacy: Enemy has noticed latest decision, continue with negotiation now. (Not fully understood by me, needs further investigation. okrumnow)


negotiationBroken

protected abstract void negotiationBroken()
Diplomacy: Enemy has broken negotiation. (Not fully understood by me, needs further investigation. okrumnow)


offerAccepted

protected abstract void offerAccepted()
Diplomacy: Enemy accepts latest offer. (Not fully understood by me, needs further investigation. okrumnow)


receiveOffer

protected abstract void receiveOffer(Offer offer)
Diplomacy: Enemy makes an offer. (Not fully understood by me, needs further investigation. okrumnow)

Parameters:
offer - The offer made by the enemy

treatyCanceled

protected abstract void treatyCanceled(Enemy e)
Diplomacy: Enemy cancels current treaty. (Not fully understood by me, needs further investigation. okrumnow)

Parameters:
e - The Enemy that cancelled the state treaty.

turn

protected abstract void turn()
Player is due to make a turn.


unitMoved

protected abstract void unitMoved(java.nio.ByteBuffer b,
                                  int command)
An enemy unit has moved.

Parameters:
b - Description of the Parameter
command - type of action the unit performed
See Also:
Protocol.cShowMove

getPlayer

public final Player getPlayer()
Gets the player attribute of the Brain object

Returns:
The player value


generated: 20050107