/// Is ePlayer expanding recklessly?
bool CvDiplomacyAI::IsPlayerRecklessExpander(PlayerTypes ePlayer)
{
// If the player is too far away from us, we don't care
if(GetPlayer()->GetProximityToPlayer(ePlayer) < PLAYER_PROXIMITY_CLOSE)
return false;
// If the player has too few cities, don't worry about it
int iNumCities = GET_PLAYER(ePlayer).getNumCities();
if(iNumCities < 4)
return false;
double fAverageNumCities = 0;
int iNumPlayers = 0;
// Find out what the average is (minus the player we're looking at)
PlayerTypes eLoopPlayer;
CvPlayer* pPlayer;
for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
eLoopPlayer = (PlayerTypes) iPlayerLoop;
pPlayer = &GET_PLAYER(eLoopPlayer);
// Not alive
if(!pPlayer->isAlive())
continue;
// Not the guy we're looking at
if(eLoopPlayer == ePlayer)
continue;
iNumPlayers++;
fAverageNumCities += pPlayer->getNumCities();
}
// Not sure how this would happen, but we'll be safe anyways since we'll be dividing by this value
if(iNumPlayers == 0)
{
CvAssertMsg(false, "0 players to evaluate when trying to identify if someone is a reckless expander. Not sure how this would happen without the game being over yet.");
return false;
}
fAverageNumCities /= iNumPlayers;
// Must have way more cities than the average player in the game
if(iNumCities < fAverageNumCities * 1.5)
return false;
// If this guy's military is as big as ours, then it probably means he's just stronger than us
if(GetPlayerMilitaryStrengthComparedToUs(ePlayer) >= STRENGTH_AVERAGE)
return false;
return true;
}