/// Establish weights for one flavor; can be called multiple times to layer strategies void CvPolicyAI::AddFlavorWeights(FlavorTypes eFlavor, int iWeight, int iPropagationPercent) { int iPolicy; CvPolicyEntry* entry; int* paiTempWeights; CvPolicyXMLEntries* pkPolicyEntries = m_pCurrentPolicies->GetPolicies(); // Create a temporary array of weights paiTempWeights = (int*)_alloca(sizeof(int*) * pkPolicyEntries->GetNumPolicies()); // Loop through all our policies for(iPolicy = 0; iPolicy < pkPolicyEntries->GetNumPolicies(); iPolicy++) { entry = pkPolicyEntries->GetPolicyEntry(iPolicy); // Set its weight by looking at policy's weight for this flavor and using iWeight multiplier passed in if(entry) paiTempWeights[iPolicy] = entry->GetFlavorValue(eFlavor) * iWeight; else paiTempWeights[iPolicy] = 0; } // Propagate these values left in the tree so prereqs get bought if(iPropagationPercent > 0) { WeightPrereqs(paiTempWeights, iPropagationPercent); } // Add these weights over previous ones for(iPolicy = 0; iPolicy < m_pCurrentPolicies->GetPolicies()->GetNumPolicies(); iPolicy++) { m_PolicyAIWeights.IncreaseWeight(iPolicy, paiTempWeights[iPolicy]); } }
/// Establish weights for one flavor; can be called multiple times to layer strategies void CvTechAI::AddFlavorWeights(FlavorTypes eFlavor, int iWeight, int iPropagationPercent) { int* paiTempWeights; // Create a temporary array of weights paiTempWeights = (int*)_alloca(sizeof(int) * m_pCurrentTechs->GetTechs()->GetNumTechs()); // Loop through all our techs for(int iTech = 0; iTech < m_pCurrentTechs->GetTechs()->GetNumTechs(); iTech++) { const TechTypes eTech = static_cast<TechTypes>(iTech); CvTechEntry* entry = m_pCurrentTechs->GetTechs()->GetEntry(iTech); if(entry) { // Set its weight by looking at tech's weight for this flavor and using iWeight multiplier passed in paiTempWeights[iTech] = entry->GetFlavorValue(eFlavor) * iWeight; // Multiply the weight by any special player-specific weighting (i.e. to prioritize civ unique bonuses) paiTempWeights[iTech] *= m_pCurrentTechs->GetPlayer()->GetPlayerTechs()->GetCivTechPriority(eTech); // Multiply the weight by any locale-specific weighting (i.e. to prioritize unlocking resources) paiTempWeights[iTech] *= m_pCurrentTechs->GetPlayer()->GetPlayerTechs()->GetLocaleTechPriority(eTech); } } // Propagate these values left in the tree so prereqs get bought WeightPrereqs(paiTempWeights, iPropagationPercent); // Add these weights over previous ones for(int iTech = 0; iTech < m_pCurrentTechs->GetTechs()->GetNumTechs(); iTech++) { CvTechEntry* entry = m_pCurrentTechs->GetTechs()->GetEntry(iTech); if(entry) { m_TechAIWeights.IncreaseWeight(iTech, paiTempWeights[iTech]); } } }