cz.cuni.amis.pogamut.defcon.agent.impl
Class DefConAgentLogicController<AGENT extends DefConAgent>

Package class diagram package DefConAgentLogicController
java.lang.Object
  extended by cz.cuni.amis.pogamut.defcon.agent.impl.DefConAgentController<AGENT>
      extended by cz.cuni.amis.pogamut.defcon.agent.impl.DefConAgentLogicController<AGENT>
Type Parameters:
AGENT - Controlled agent's type.
All Implemented Interfaces:
IAgentLogic<LogicModule<AGENT>>, IDefConAgentController<AGENT>, IDefConAgentLogicController<AGENT,LogicModule<AGENT>>

public class DefConAgentLogicController<AGENT extends DefConAgent>
extends DefConAgentController<AGENT>
implements IDefConAgentLogicController<AGENT,LogicModule<AGENT>>

Implements infrastructure for a logic of the bot and simplifies distinction between different stages of the game.

Author:
Radek 'Black_Hand' Pibil

Field Summary
protected  BuildingsManager buildingsManager
           
protected  IFlagChecker flagChecker
           
protected  FleetsManager fleetsManager
           
protected  GameInfo gameInfo
           
 IWorldEventListener<GameRunningChanged> gameStartedListener
          Annotation-based event listener registrator cannot handle inheritance, so we have to use this old styled method.
protected  DefConAgentLogic<AGENT> logicModule
           
protected  DefConWorldView worldview
           
 
Fields inherited from class cz.cuni.amis.pogamut.defcon.agent.impl.DefConAgentController
agent
 
Constructor Summary
DefConAgentLogicController()
          Assigns logicMethod, which gets executed in logic().
 
Method Summary
 void addGameLogicListener(ILogicUpdateListener updateListener)
          Registers a listener from updates.
 void beforeFirstLogic()
           
 void firstGameLogic()
          Executed the first tick instead of gameLogic.
 void gameLogic()
          Executed periodically while still in game.
 void gameLogicWorker()
          Updates listeners, then calls gameLogic();
 BuildingsManager getBuildingsManager()
           
 IFlagChecker getFlagChecker()
          Returns flag checker used for map analysis.
 FleetsManager getFleetsManager()
           
 long getLogicInitializeTime()
           
 long getLogicShutdownTime()
           
 IMailBox getMailBox()
          Returns the mailbox.
 Random getRandom()
          Returns a random number generator.
 void initializeController(AGENT agent)
          Registers anonymous listeners and creates logic module.
 void logic()
          Gets executed periodically.
 void logicInitialize(LogicModule<AGENT> logicModule)
           
 void logicShutdown()
           
 void preGameLogic()
          Executed instead of gameLogic while still in lobby.
 void unregisterUpdates(ILogicUpdateListener updateListener)
          Unregisters a listener from updates.
 
Methods inherited from class cz.cuni.amis.pogamut.defcon.agent.impl.DefConAgentController
act, botStopped, getAct, getGameInfo, getLog, getWorldView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.defcon.agent.IDefConAgentController
botStopped
 

Field Detail

logicModule

protected DefConAgentLogic<AGENT extends DefConAgent> logicModule

worldview

protected DefConWorldView worldview

gameInfo

protected GameInfo gameInfo

fleetsManager

protected FleetsManager fleetsManager

buildingsManager

protected BuildingsManager buildingsManager

flagChecker

protected IFlagChecker flagChecker

gameStartedListener

public IWorldEventListener<GameRunningChanged> gameStartedListener
Annotation-based event listener registrator cannot handle inheritance, so we have to use this old styled method.

Constructor Detail

DefConAgentLogicController

public DefConAgentLogicController()
Assigns logicMethod, which gets executed in logic(). This could be either gameLogic() or preGameLogic().

Method Detail

initializeController

public void initializeController(AGENT agent)
Registers anonymous listeners and creates logic module.

Specified by:
initializeController in interface IDefConAgentController<AGENT extends DefConAgent>
Overrides:
initializeController in class DefConAgentController<AGENT extends DefConAgent>

getLogicInitializeTime

public long getLogicInitializeTime()
Specified by:
getLogicInitializeTime in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

getLogicShutdownTime

public long getLogicShutdownTime()
Specified by:
getLogicShutdownTime in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

beforeFirstLogic

public void beforeFirstLogic()
Specified by:
beforeFirstLogic in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

logic

public void logic()
Gets executed periodically. Here we call a method that is currently stored in logicMethod field.

Specified by:
logic in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

preGameLogic

public void preGameLogic()
Executed instead of gameLogic while still in lobby. This is what you could use to talk while the game is not running yet. Defcon API is not entirely clear if this is OK, so if you run into any problems with it, we would be glad to hear about them.


firstGameLogic

public void firstGameLogic()
Executed the first tick instead of gameLogic.


gameLogic

public void gameLogic()
Executed periodically while still in game. This is THE method for your AI. Override it to make your bot do something else than (possibly) a reaction to incoming events.


gameLogicWorker

public final void gameLogicWorker()
Updates listeners, then calls gameLogic();


logicInitialize

public void logicInitialize(LogicModule<AGENT> logicModule)
Specified by:
logicInitialize in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

logicShutdown

public void logicShutdown()
Specified by:
logicShutdown in interface IAgentLogic<LogicModule<AGENT extends DefConAgent>>

addGameLogicListener

public void addGameLogicListener(ILogicUpdateListener updateListener)
Registers a listener from updates.

Parameters:
updateListener -

unregisterUpdates

public void unregisterUpdates(ILogicUpdateListener updateListener)
Unregisters a listener from updates.

Parameters:
updateListener -

getRandom

public final Random getRandom()
Returns a random number generator.

Returns:

getMailBox

public final IMailBox getMailBox()
Returns the mailbox.

Returns:

getFlagChecker

public IFlagChecker getFlagChecker()
Returns flag checker used for map analysis.

Returns:

getFleetsManager

public final FleetsManager getFleetsManager()

getBuildingsManager

public final BuildingsManager getBuildingsManager()


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.