Research Article
Artificial Intelligence in Video Games: Towards a Unified Framework
Algorithm 22
The update function of the CptBot class. The function uses the Attack conceptual control to issue commands to the units in the game.
void CptBot::Update() | { | //if the bot is under AI control but not scripted | if (!GetAgent()->isPossessed()) | { | //examine all the opponents in the bots sensory memory and select one | //to be the current target | if (m_pTargetSelectionRegulator->isReady()) | { | m_pTargSys->Update(); | } | //update the sensory memory with any visual stimulus | if (m_pVisionUpdateRegulator->isReady()) | { | m_pSensoryMem->UpdateVision(); | } | //Attack | if (m_pAttackRegulator->isReady() && m_pTargSys->isTargetPresent()) | { | Attack(m_pOwner->ID(), m_pTargSys->GetTarget()->ID()); | } | } | } |
|