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.
classMovingEntity:publicBaseGameEntity
{
⋯
//Virtual accessor − Retrieves the conceptual projection of this entity
virtualCptMvEntity2DGetCptMvEntity2D()const= 0;
⋯
voidSetVelocity(constVector2D &NewVel)
{
m_vVelocity = NewVel;
//Velocity changed, update conceptual data
GetCptMvEntity2D()->SetVelocity(m_vVelocity);
}
⋯
}
classRaven_Bot:publicMovingEntity
{
protected:
//The conceptual projection
CptMvAgent2Dcpt;
⋯
public:
//Returns the entire conceptual projection of this bot
CptMvAgent2DGetCptMvAgent2D()const { returncpt; }
//Returns the conceptual projection of the MovingEntity part of this bot