/// Initialize void CvTacticalAnalysisMap::Init(int iNumPlots) { // Time building of these maps AI_PERF("AI-perf-tact.csv", "CvTacticalAnalysisMap::Init()" ); if(m_pPlots) { SAFE_DELETE_ARRAY(m_pPlots); } m_pPlots = FNEW(CvTacticalAnalysisCell[iNumPlots], c_eCiv5GameplayDLL, 0); m_iNumPlots = iNumPlots; m_iDominancePercentage = GC.getAI_TACTICAL_MAP_DOMINANCE_PERCENTAGE(); }
/// Initialize void CvTacticalAnalysisMap::Init(PlayerTypes ePlayer) { // Time building of these maps AI_PERF("AI-perf-tact.csv", "CvTacticalAnalysisMap::Init()" ); m_ePlayer = ePlayer; m_pCells.clear(); m_pCells.resize( GC.getMap().numPlots() ); m_DominanceZones.clear(); m_iDominancePercentage = GC.getAI_TACTICAL_MAP_DOMINANCE_PERCENTAGE(); m_iTurnBuilt = -1; m_iTacticalRange = 6; m_iUnitStrengthMultiplier = 5; }
void CvPlayerAI::AI_chooseResearch() { AI_PERF("AI-perf.csv", "AI_chooseResearch"); TechTypes eBestTech = NO_TECH; int iI; clearResearchQueue(); if(GetPlayerTechs()->GetCurrentResearch() == NO_TECH) { for(iI = 0; iI < MAX_PLAYERS; iI++) { if(GET_PLAYER((PlayerTypes)iI).isAlive()) { if((iI != GetID()) && (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam())) { if(GET_PLAYER((PlayerTypes)iI).GetPlayerTechs()->GetCurrentResearch() != NO_TECH) { if(GetPlayerTechs()->CanResearch(GET_PLAYER((PlayerTypes)iI).GetPlayerTechs()->GetCurrentResearch())) { pushResearch(GET_PLAYER((PlayerTypes)iI).GetPlayerTechs()->GetCurrentResearch()); } } } } } } if(GetPlayerTechs()->GetCurrentResearch() == NO_TECH) { //todo: script override if(eBestTech == NO_TECH) { eBestTech = GetPlayerTechs()->GetTechAI()->ChooseNextTech(); } if(eBestTech != NO_TECH) { pushResearch(eBestTech); } } }
void CvPlayerAI::AI_considerAnnex() { AI_PERF("AI-perf.csv", "AI_ considerAnnex"); // if the empire is unhappy, don't consider annexing if (IsEmpireUnhappy()) { return; } // if we're going for a culture victory, don't consider annexing if (GetDiplomacyAI()->IsGoingForCultureVictory()) { return; } // for Venice if (GetPlayerTraits()->IsNoAnnexing()) { return; } // if their capital city is puppeted, annex it CvCity* pCity = getCapitalCity(); if (pCity && pCity->IsPuppet()) { // we should only annex one city a turn, and sense this is one, we're done! pCity->DoAnnex(); return; } std::vector<CityAndProduction> aCityAndProductions; int iLoop = 0; pCity = NULL; // Find first coastal city in same area as settler for(pCity = firstCity(&iLoop); pCity != NULL; pCity = nextCity(&iLoop)) { CityAndProduction kEval; kEval.pCity = pCity; kEval.iProduction = pCity->getYieldRateTimes100(YIELD_PRODUCTION, false); aCityAndProductions.push_back(kEval); } std::stable_sort(aCityAndProductions.begin(), aCityAndProductions.end(), CityAndProductionEval()); CvCity* pTargetCity = NULL; float fCutoffValue = GC.getNORMAL_ANNEX(); BuildingClassTypes eCourthouseType = NO_BUILDINGCLASS; // find courthouse for(int eBuildingType = 0; eBuildingType < GC.getNumBuildingInfos(); eBuildingType++) { const BuildingTypes eBuilding = static_cast<BuildingTypes>(eBuildingType); CvBuildingEntry* buildingInfo = GC.getBuildingInfo(eBuilding); if(buildingInfo) { if (buildingInfo->IsNoOccupiedUnhappiness()) { eCourthouseType = (BuildingClassTypes)buildingInfo->GetBuildingClassType(); break; } } } bool bCourthouseImprovement = false; if (eCourthouseType != NO_BUILDINGCLASS) { if (GetPlayerPolicies()->GetBuildingClassProductionModifier(eCourthouseType) > 0) { bCourthouseImprovement = true; } } if (bCourthouseImprovement) { fCutoffValue = GC.getAGGRESIVE_ANNEX(); } uint uiCutOff = (uint)(aCityAndProductions.size() * fCutoffValue); for (uint ui = 0; ui < uiCutOff; ui++) { if (aCityAndProductions[ui].pCity->IsPuppet()) { pTargetCity = aCityAndProductions[ui].pCity; break; } } if (pTargetCity) { if (!pTargetCity->IsResistance()) { pTargetCity->DoAnnex(); } } }