本文整理汇总了C++中CvPolicyEntry类的典型用法代码示例。如果您正苦于以下问题:C++ CvPolicyEntry类的具体用法?C++ CvPolicyEntry怎么用?C++ CvPolicyEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CvPolicyEntry类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogPolicyChoice
/// Log chosen policy
void CvPolicyAI::LogPolicyChoice(PolicyTypes ePolicy)
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
CvString strDesc;
// Find the name of this civ and city
playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy);
const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown";
strTemp.Format("CHOSEN, %s", szPolicyType);
strOutBuf = strBaseString + strTemp;
pLog->Msg(strOutBuf);
}
}
示例2: WeighBranch
/// Priority for opening up this branch
int CvPolicyAI::WeighBranch(PolicyBranchTypes eBranch)
{
int iWeight = 0;
CvPolicyBranchEntry* pkPolicyBranchInfo = GC.getPolicyBranchInfo(eBranch);
if(pkPolicyBranchInfo)
{
for(int iPolicyLoop = 0; iPolicyLoop < m_pCurrentPolicies->GetPolicies()->GetNumPolicies(); iPolicyLoop++)
{
const PolicyTypes ePolicyLoop = static_cast<PolicyTypes>(iPolicyLoop);
CvPolicyEntry* pkLoopPolicyInfo = GC.getPolicyInfo(ePolicyLoop);
if(pkLoopPolicyInfo)
{
// Policy we don't have?
if(!m_pCurrentPolicies->HasPolicy(ePolicyLoop))
{
// From this branch we are considering opening?
if(pkLoopPolicyInfo->GetPolicyBranchType() == eBranch)
{
// With no prereqs?
if(pkLoopPolicyInfo->GetPrereqAndPolicies(0) == NO_POLICY)
{
iWeight += m_PolicyAIWeights.GetWeight(iPolicyLoop);
}
}
}
}
}
// Add weight of free policy from branch
iWeight += m_PolicyAIWeights.GetWeight(pkPolicyBranchInfo->GetFreePolicy());
}
return iWeight;
}
示例3: AddFlavorWeights
/// 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]);
}
}
示例4: GetBranchBuildingHappiness
/// What's the total Happiness benefit we could get from all policies/tenets in the branch based on our current buildings?
int CvPolicyAI::GetBranchBuildingHappiness(CvPlayer* pPlayer, PolicyBranchTypes eBranch)
{
// Policy Building Mods
int iSpecialPolicyBuildingHappiness = 0;
int iBuildingClassLoop;
BuildingClassTypes eBuildingClass;
for(int iPolicyLoop = 0; iPolicyLoop < GC.getNumPolicyInfos(); iPolicyLoop++)
{
PolicyTypes ePolicy = (PolicyTypes)iPolicyLoop;
CvPolicyEntry* pkPolicyInfo = GC.getPolicyInfo(ePolicy);
if(pkPolicyInfo)
{
if (pkPolicyInfo->GetPolicyBranchType() == eBranch)
{
for(iBuildingClassLoop = 0; iBuildingClassLoop < GC.getNumBuildingClassInfos(); iBuildingClassLoop++)
{
eBuildingClass = (BuildingClassTypes) iBuildingClassLoop;
CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);
if (!pkBuildingClassInfo)
{
continue;
}
if (pkPolicyInfo->GetBuildingClassHappiness(eBuildingClass) != 0)
{
BuildingTypes eBuilding = (BuildingTypes)pPlayer->getCivilizationInfo().getCivilizationBuildings(eBuildingClass);
if (eBuilding != NO_BUILDING)
{
CvCity *pCity;
int iLoop;
for (pCity = pPlayer->firstCity(&iLoop); pCity != NULL; pCity = pPlayer->nextCity(&iLoop))
{
if (pCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0)
{
iSpecialPolicyBuildingHappiness += pkPolicyInfo->GetBuildingClassHappiness(eBuildingClass);
}
}
}
}
}
}
}
}
return iSpecialPolicyBuildingHappiness;
}
示例5: GetNumHappinessPolicies
/// How many policies in this branch help happiness?
int CvPolicyAI::GetNumHappinessPolicies(CvPlayer* pPlayer, PolicyBranchTypes eBranch)
{
int iRtnValue = 0;
int iBuildingClassLoop;
BuildingClassTypes eBuildingClass;
for(int iPolicyLoop = 0; iPolicyLoop < GC.getNumPolicyInfos(); iPolicyLoop++)
{
PolicyTypes ePolicy = (PolicyTypes)iPolicyLoop;
CvPolicyEntry* pkPolicyInfo = GC.getPolicyInfo(ePolicy);
if(pkPolicyInfo)
{
if (pkPolicyInfo->GetPolicyBranchType() == eBranch)
{
for(iBuildingClassLoop = 0; iBuildingClassLoop < GC.getNumBuildingClassInfos(); iBuildingClassLoop++)
{
eBuildingClass = (BuildingClassTypes) iBuildingClassLoop;
CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);
if (!pkBuildingClassInfo)
{
continue;
}
BuildingTypes eBuilding = (BuildingTypes)pPlayer->getCivilizationInfo().getCivilizationBuildings(eBuildingClass);
if (eBuilding != NO_BUILDING)
{
// Don't count a building that can only be built in conquered cities
CvBuildingEntry *pkEntry = GC.getBuildingInfo(eBuilding);
if (!pkEntry || pkEntry->IsNoOccupiedUnhappiness())
{
continue;
}
if (pkPolicyInfo->GetBuildingClassHappiness(eBuildingClass) != 0)
{
iRtnValue++;
break;
}
}
}
}
}
}
return iRtnValue;
}
示例6: LogPossiblePolicies
/// Log all possible policy choices
void CvPolicyAI::LogPossiblePolicies()
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
CvString strDesc;
// Find the name of this civ and city
playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
int iNumBranches = GC.getNumPolicyBranchInfos();
// Dump out the weight of each possible policy
for(int iI = 0; iI < m_AdoptablePolicies.size(); iI++)
{
int iWeight = m_AdoptablePolicies.GetWeight(iI);
if(m_AdoptablePolicies.GetElement(iI) < iNumBranches)
{
strTemp.Format("Branch %d, %d", m_AdoptablePolicies.GetElement(iI), iWeight);
}
else
{
PolicyTypes ePolicy = (PolicyTypes)(m_AdoptablePolicies.GetElement(iI) - iNumBranches);
CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy);
const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown";
strTemp.Format("%s, %d", szPolicyType, iWeight);
}
strOutBuf = strBaseString + strTemp;
pLog->Msg(strOutBuf);
}
}
}
示例7: MakeDelegate
//.........这里部分代码省略.........
int iBranchWeight = 0;
// Does this branch actually help us, based on game options?
if(IsBranchEffectiveInGame(ePolicyBranch))
{
iBranchWeight += WeighBranch(ePolicyBranch);
iBranchWeight *= (100 - m_iPolicyWeightPercentDropNewBranch);
iBranchWeight /= 100;
#if defined (JRMOD_C23)
//Following condition no longer makes sense since Cultural victory has changed but i let it since it can help the AI to focus on a tree.
#endif
if(eCurrentGrandStrategy == eCultureGrandStrategy)
{
iBranchWeight /= 3;
}
}
m_AdoptablePolicies.push_back(iBranchLoop, iBranchWeight);
}
}
}
}
m_AdoptablePolicies.SortItems();
LogPossiblePolicies();
// If there were any Level 3 tenets found, consider going for the one that matches our victory strategy
if (aLevel3Tenets.size() > 0)
{
vector<int>::const_iterator it;
for (it = aLevel3Tenets.begin(); it != aLevel3Tenets.end(); it++)
{
CvPolicyEntry *pEntry;
pEntry = m_pCurrentPolicies->GetPolicies()->GetPolicyEntry(*it);
if (pEntry)
{
AIGrandStrategyTypes eGrandStrategy = pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy();
if (eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_OFFENSE")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_SPACESHIP"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_SPACESHIP")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_UNITED_NATIONS"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_DIPLOMACY")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_CULTURE")) > 0)
{
示例8: MakeDelegate
//.........这里部分代码省略.........
// Does this branch actually help us, based on game options?
if(IsBranchEffectiveInGame(ePolicyBranch))
{
iBranchWeight += WeighBranch(ePolicyBranch);
iBranchWeight *= (100 - m_iPolicyWeightPercentDropNewBranch);
iBranchWeight /= 100;
#if defined(MOD_BALANCE_CORE)
//Leftover from Vanilla victory
#else
if(eCurrentGrandStrategy == eCultureGrandStrategy)
{
iBranchWeight /= 3;
}
#endif
}
m_AdoptablePolicies.push_back(iBranchLoop, iBranchWeight);
}
}
}
}
m_AdoptablePolicies.SortItems();
LogPossiblePolicies();
#if defined(MOD_BALANCE_CORE)
#else
// If there were any Level 3 tenets found, consider going for the one that matches our victory strategy
if (aLevel3Tenets.size() > 0)
{
vector<int>::const_iterator it;
for (it = aLevel3Tenets.begin(); it != aLevel3Tenets.end(); it++)
{
CvPolicyEntry *pEntry;
pEntry = m_pCurrentPolicies->GetPolicies()->GetPolicyEntry(*it);
if (pEntry)
{
AIGrandStrategyTypes eGrandStrategy = pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy();
if (eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_OFFENSE")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_SPACESHIP"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_SPACESHIP")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_UNITED_NATIONS"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_DIPLOMACY")) > 0)
{
LogPolicyChoice((PolicyTypes)*it);
return (*it) + GC.getNumPolicyBranchInfos();
}
}
else if(eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE"))
{
if (pEntry->GetFlavorValue((FlavorTypes)GC.getInfoTypeForString("FLAVOR_CULTURE")) > 0)
{