Research Article

Artificial Intelligence in Video Games: Towards a Unified Framework

Algorithm 8

Modifications in the conceptual copy of a Raven class. No game behavior is defined in CDS, which hosts nothing more than a projection of the game state.
class  Raven_Weapon
{
 //this discharges a projectile from the weapon at the given target position (provided
 the weapon is ready to be discharged… every weapon has its own rate of fire)
virtual void  ShootAt(Vector2D pos) = 0;
void  IncrementRounds(int  num)
 {
  m_iNumRoundsLeft  +=  num;
  Clamp(m_iNumRoundsLeft, 0, m_iMaxRoundsCarried);
  //Synchronize rounds in CDS
  GetCptWeapon()->SetNumRoundsLeft(m_iNumRoundsLeft);
 }
};
class  CptWeapon
{
 ⋯
 //Removed
 //virtual void ShootAt(Vector2D pos) = 0;
void  SetNumRoundsLeft(int  n)
 {
  m_iNumRoundsLeft = n;
 }
 ⋯
};