Research Article

Artificial Intelligence in Video Games: Towards a Unified Framework

Algorithm 13

Controller management in the CptMvAgent2D class.
class  CptMvAgent2D:  public  CptMvEntity2D
{
private:
 //List of registered controllers
std::list<CptMvAgent2D_Controller>  controllers;
public:
 //Registers a new controller
void  AddController(CptMvAgent2D_Controller  c)
{
controllers.push_back(c);
}
 //Notifies controllers that a bot has been removed from the game
void  BotRemoved(CptMvAgent2D  bot)
 {
std::list<CptMvAgent2D_Controller>::iterator it;
  for  (it = controllers.begin(); it != controllers.end(); ++it)
{
(it)->BotRemoved_Handler(bot);
}
}
}