Game Development Reference
In-Depth Information
from the battlefield and perhaps ran out of ammo for some of our weapons, the
total number of options available to us would decrease, and the number that we
would consider would contract with it.
Now that we have decided that we will consider the top eight choices, we have
truncated our list to:
Name
Weapon
Score
Evil Genius
R/L
7.7
Boss Man
R/L
8.5
Baddie 3
R/L
9.7
Evilmeister
R/L
9.8
Evil Genius
M/G
10.8
Baddie 3
Shotgun
11.2
Baddie 3
M/G
12.6
Baddie 2
R/L
13.1
Those all look like fairly reasonable actions for us to take. Their scores are so
similar, it almost doesn't matter which one we choose. Therefore, a simple solution
would be to pick one of them randomly.
P UTTING I TIN C ODE
We can do this very simply by changing the selection code in CAgent . The original
SelectTarget() function sorted the vector and selected the target in the 0 index—
the lowest-scored combination.
void CAgent::SelectTarget()
{
ScoreAllTargets();
std::sort( mvTargets.begin(), mvTargets.end() );
mpCurrentTarget = mvTargets[0].pDude;
mpCurrentWeapon = mvTargets[0].pWeapon;
}
Search WWH ::




Custom Search