International Journal of Computer Games Technology / 2015 / Article / Alg 20

Research Article

Artificial Intelligence in Video Games: Towards a Unified Framework

Algorithm 20

Synchronizing conceptual unit state. Some attributes are not required by the targeting AI and only serve as illustrations.
void  GravenAIModule::syncUnit(CptMvAgent2D  u, Unit unit)
{
 //Synchronize CptEntity2D attributes
u->SetID(unit->getID());
u->SetEntityType(cpttype_bot);
u->SetScale(1);
u->SetBRadius(MAX(unit->getType().height()  /  2, unit->getType().width()  /  2));
u->SetPos(Vector2D(unit->getPosition().x, unit->getPosition().y));
 //Synchronize CptMvEntity2D attributes
u->SetHeading(Vector2D(unit->getVelocityX(), unit->getVelocityY()));
u->SetVelocity(Vector2D(unit->getVelocityX(), unit->getVelocityY()));
u->SetMass(1);
u->SetMaxSpeed(unit->getType().topSpeed());
u->SetMaxTurnRate(unit->getType().turnRadius());
u->SetMaxForce(unit->getType().acceleration());
 //Synchronize CptMvAgent2D attributes
u->SetMaxHealth(unit->getType().maxHitPoints() + unit->getType().maxShields());
u->SetHealth(unit->getHitPoints() + unit->getShields());
u->SetScore(unit->getKillCount());
u->SetPossessed(false );
u->SetFieldOfView(360);
u->Face(Vector2D(unit->getVelocityX(), unit->getVelocityY()));
u->SetWorld(this ->cptWorld);
u->SetStatus(unit->exists() ? CptMvAgent2D::alive: CptMvAgent2D::dead);
u->SetPlayer(unit->getPlayer()->getID());
u->SetSightRange(unit->getType().sightRange());
u->SetPlane(unit->isFlying());
u->SetAirReach(unit->getType().airWeapon() != WeaponTypes::None);
u->SetGroundReach(unit->getType().groundWeapon() != WeaponTypes::None);
}

We are committed to sharing findings related to COVID-19 as quickly as possible. We will be providing unlimited waivers of publication charges for accepted research articles as well as case reports and case series related to COVID-19. Review articles are excluded from this waiver policy. Sign up here as a reviewer to help fast-track new submissions.