Game Development Reference
In-Depth Information
Utility = ( OddsNoAttack() * -mTowerCost)
+ ( mOddsSmallAttack * -( mTowerCost + mSmallDamageTower ) )
+ ( mOddsLargeAttack * -( mTowerCost + mLargeDamageTower ) );
return Utility;
};
float MyGame::UtilityNoTower()
{
// Returns the utility value of not purchasing the tower.
float Utility;
Utility = ( mOddsSmallAttack * -mSmallDamageNoTower )
+ ( mOddsLargeAttack * -mBarracksCost );
return Utility;
};
bool MyGame::BuildTower()
{
// Returns the decision on whether or not to purchase the
// tower based on the relative utility values returned from
// the two functions.
if ( UtilityTower() > UtilityNoTower() ) {
return true;
} else {
return false;
}
};
Search WWH ::




Custom Search