/// Runs every turn to try and figure out what other known Players' Grand Strategies are void CvGrandStrategyAI::DoGuessOtherPlayersActiveGrandStrategy() { CvWeightedVector<int, 5, true> vGrandStrategyPriorities; FStaticVector< int, 5, true, c_eCiv5GameplayDLL > vGrandStrategyPrioritiesForLogging; GuessConfidenceTypes eGuessConfidence = NO_GUESS_CONFIDENCE_TYPE; int iGrandStrategiesLoop = 0; AIGrandStrategyTypes eGrandStrategy = NO_AIGRANDSTRATEGY; CvAIGrandStrategyXMLEntry* pGrandStrategy = 0; CvString strGrandStrategyName; CvTeam& pTeam = GET_TEAM(GetPlayer()->getTeam()); int iMajorLoop = 0; PlayerTypes eMajor = NO_PLAYER; int iPriority = 0; // Establish world Military strength average int iWorldMilitaryAverage = GC.getGame().GetWorldMilitaryStrengthAverage(GetPlayer()->GetID(), true, true); // Establish world culture and tourism averages int iNumPlayersAlive = 0; int iWorldCultureAverage = 0; int iWorldTourismAverage = 0; for(iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++) { eMajor = (PlayerTypes) iMajorLoop; if(GET_PLAYER(eMajor).isAlive()) { iWorldCultureAverage += GET_PLAYER(eMajor).GetJONSCultureEverGenerated(); iWorldTourismAverage += GET_PLAYER(eMajor).GetCulture()->GetTourism(); iNumPlayersAlive++; } } iWorldCultureAverage /= iNumPlayersAlive; iWorldTourismAverage /= iNumPlayersAlive; // Establish world Tech progress average iNumPlayersAlive = 0; int iWorldNumTechsAverage = 0; TeamTypes eTeam; for(int iTeamLoop = 0; iTeamLoop < MAX_MAJOR_CIVS; iTeamLoop++) // Looping over all MAJOR teams { eTeam = (TeamTypes) iTeamLoop; if(GET_TEAM(eTeam).isAlive()) { iWorldNumTechsAverage += GET_TEAM(eTeam).GetTeamTechs()->GetNumTechsKnown(); iNumPlayersAlive++; } } iWorldNumTechsAverage /= iNumPlayersAlive; // Look at every Major we've met for(iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++) { eMajor = (PlayerTypes) iMajorLoop; if(GET_PLAYER(eMajor).isAlive() && iMajorLoop != GetPlayer()->GetID()) { if(pTeam.isHasMet(GET_PLAYER(eMajor).getTeam())) { for(iGrandStrategiesLoop = 0; iGrandStrategiesLoop < GetAIGrandStrategies()->GetNumAIGrandStrategies(); iGrandStrategiesLoop++) { eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategiesLoop; pGrandStrategy = GetAIGrandStrategies()->GetEntry(iGrandStrategiesLoop); strGrandStrategyName = (CvString) pGrandStrategy->GetType(); if(strGrandStrategyName == "AIGRANDSTRATEGY_CONQUEST") { iPriority = GetGuessOtherPlayerConquestPriority(eMajor, iWorldMilitaryAverage); } else if(strGrandStrategyName == "AIGRANDSTRATEGY_CULTURE") { iPriority = GetGuessOtherPlayerCulturePriority(eMajor, iWorldCultureAverage, iWorldTourismAverage); } else if(strGrandStrategyName == "AIGRANDSTRATEGY_UNITED_NATIONS") { iPriority = GetGuessOtherPlayerUnitedNationsPriority(eMajor); } else if(strGrandStrategyName == "AIGRANDSTRATEGY_SPACESHIP") { iPriority = GetGuessOtherPlayerSpaceshipPriority(eMajor, iWorldNumTechsAverage); } vGrandStrategyPriorities.push_back(iGrandStrategiesLoop, iPriority); vGrandStrategyPrioritiesForLogging.push_back(iPriority); } if(vGrandStrategyPriorities.size() > 0) { // Add "No Grand Strategy" in case we just don't have enough info to go on iPriority = /*40*/ GC.getAI_GRAND_STRATEGY_GUESS_NO_CLUE_WEIGHT(); vGrandStrategyPriorities.push_back(NO_AIGRANDSTRATEGY, iPriority); vGrandStrategyPrioritiesForLogging.push_back(iPriority); vGrandStrategyPriorities.SortItems(); eGrandStrategy = (AIGrandStrategyTypes) vGrandStrategyPriorities.GetElement(0); iPriority = vGrandStrategyPriorities.GetWeight(0); eGuessConfidence = NO_GUESS_CONFIDENCE_TYPE; // How confident are we in our Guess? if(eGrandStrategy != NO_AIGRANDSTRATEGY) { if(iPriority >= /*120*/ GC.getAI_GRAND_STRATEGY_GUESS_POSITIVE_THRESHOLD()) { eGuessConfidence = GUESS_CONFIDENCE_POSITIVE; } else if(iPriority >= /*70*/ GC.getAI_GRAND_STRATEGY_GUESS_LIKELY_THRESHOLD()) { eGuessConfidence = GUESS_CONFIDENCE_LIKELY; } else { eGuessConfidence = GUESS_CONFIDENCE_UNSURE; } } SetGuessOtherPlayerActiveGrandStrategy(eMajor, eGrandStrategy, eGuessConfidence); LogGuessOtherPlayerGrandStrategy(vGrandStrategyPrioritiesForLogging, eMajor); } vGrandStrategyPriorities.clear(); vGrandStrategyPrioritiesForLogging.clear(); } } } }