Research Article

Artificial Intelligence in Video Games: Towards a Unified Framework

Algorithm 12

Synchronization with virtual classes. The virtual class MovingEntity uses a pure virtual getter implemented by its concrete subclass Raven_Bot for its synchronization code.
class  MovingEntity:  public  BaseGameEntity
{
 //Virtual accessor − Retrieves the conceptual projection of this entity
virtual  CptMvEntity2D  GetCptMvEntity2D()  const  = 0;
void  SetVelocity(const  Vector2D &  NewVel)
{
m_vVelocity = NewVel;
  //Velocity changed, update conceptual data
GetCptMvEntity2D()->SetVelocity(m_vVelocity);
}
}
class  Raven_Bot:  public  MovingEntity
{
protected:
 //The conceptual projection
CptMvAgent2D  cpt;
public:
 //Returns the entire conceptual projection of this bot
CptMvAgent2D  GetCptMvAgent2D()  const  {  return  cpt; }
 //Returns the conceptual projection of the MovingEntity part of this bot
CptMvEntity2D  GetCptMvEntity2D()  const  {  return  cpt; }
 //Returns the conceptual projection of the BaseGameEntity part of this bot
CptEntity2D  GetCptEntity2D()  const  {  return  cpt; }
}