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

Research Article

Artificial Intelligence in Video Games: Towards a Unified Framework

Algorithm 21

Implementation of the Attack conceptual control in BW. Because the targeting AI only selects targets the unit can attack, the test to see whether the unit is flying could be discarded.
void  Attack(int  agent_id, int  target_id)
{
Unit u = Broodwar->getUnit(agent_id);
Unit v = Broodwar->getUnit(target_id);
 // Don't attack under explicit move orders
if  (u->getOrder().getID() == Orders::Move)
  return;
 // Already attacking that target
if  (u->getLastCommand().getTarget() != NULL && u->
getLastCommand().getTarget()->getID() == target_id)
  return;
if  (v->getType().isFlyer())
{
  if  (u->getType().airWeapon() != WeaponTypes::None)
u->attack(v);
  return;
}
else
{
  if  (u->getType().groundWeapon() != WeaponTypes::None &&   u->exists())
u->attack(v);
  return;
}
}

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.