O'Reilly logo

Programming Game AI by Example by Mat Buckland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Goal_Composite::ProcessSubgoals
All composite goals call this method each update step to process their
subgoals. The method ensures that all completed and failed goals are
removed from the list before processing the next subgoal in line and return
-
ing its status. If the subgoal list is empty,
completed is returned.
template <class entity_type>
int Goal_Composite<entity_type>::ProcessSubgoals()
{
//remove all completed and failed goals from the front of the subgoal list
while (!m_SubGoals.empty() &&
(m_SubGoals.front()->isComplete() || m_SubGoals.front()->hasFailed()))
{
m_SubGoals.front()->Terminate();
delete m_SubGoals.front();
m_SubGoals.pop_front();
Goal-Driven Agent Behavior
| 385
Implementation
Figure 9.7. The final design. The figure shows three examples of concrete classes used
by the Raven bots.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required