Artificial Intelligence in Video Games: Towards a Unified Framework
Algorithm 19
Conceptual view code in the onFrame callback function. The RegisterDMController creates a CptBot, which uses the Graven targeting AI to attack enemies, and adds it to the list of controllers of the CptMvAgent2D.
voidGravenAIModule::onFrame()
{
⋯
//For each unit visible to the player
Unitset units = Broodwar->getAllUnits();
for(Unitset::iterator u = units.begin(); u != units.end(); ++u)
{
//Ignore neutral units which include mineral fields and critters