Game Development Reference
In-Depth Information
Notice that we have trapped this function so that the value of the Health Kit can
never be negative. No matter how late we are in arriving at the kit, it will never
actually damage us.
Our resulting decision code would then be:
GOAL_TYPE MyGame::GetBestAction2()
{
// This implementation includes the fact that
// the value of the Health Kit decays over time
// Calc our remaining health if we get the Health Kit first
int HealthFirst = mMyHealth
- Damage( mTimeToHealth, mDamageRate )
- Damage( mTimeHealthToArmor, mDamageRate )
- Damage( mTimeToArmor, mArmoredDamageRate )
+ HealthKitValue( mTimeToHealth,
mHealthKitDecayRate );
// Calc our remaining health if we get the Armor first
int ArmorFirst = mMyHealth
- Damage( mTimeToArmor, mDamageRate )
- Damage( mTimeHealthToArmor, mArmoredDamageRate )
- Damage( mTimeToHealth, mArmoredDamageRate )
+ HealthKitValue(mTimeToArmor + mTimeHealthToArmor,
mHealthKitDecayRate );
// If both methods would leave us WORSE off than we started
// then do neither.
if ( ( mMyHealth > HealthFirst ) &&
( mMyHealth > ArmorFirst ) ) {
return GOAL_NONE;
}
Search WWH ::




Custom Search