O'Reilly logo

Behavioral Mathematics for Game AI by Dave Mark

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

Comparing Options

Of course, we need to repeat ScoreTarget() for each of the enemies we face and for each of the weapons we carry. If we are facing three Dudes and have four weapons available to us, we have 12 options to score. By looping through the two lists, we can call ScoreTarget() for each of the 12 combinations.

 void CAgent::ScoreAllTargets() { sWEAPON_INFO ThisWeapon; CDude* pThisEnemy; USHORT ei, wi; // loop indexes mvTargets.empty(); // start with a fresh list of targets for ( ei = 0; ei < mpDudeCollection->GetSize(); ei++ ) { pThisEnemy = mpDudeCollection->GetPointer( DUDE_TYPE(ei) ); for ( wi = 0; wi < mvWeapons.size(); wi++ ) { ThisWeapon = mvWeapons[wi]; // Only consider loaded weapons if ( ThisWeapon.Ammo > 0 ) { ScoreTarget( ...

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