当前位置: 首页>>代码示例>>C++>>正文


C++ CvPolicyEntry::GetFlavorValue方法代码示例

本文整理汇总了C++中CvPolicyEntry::GetFlavorValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CvPolicyEntry::GetFlavorValue方法的具体用法?C++ CvPolicyEntry::GetFlavorValue怎么用?C++ CvPolicyEntry::GetFlavorValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CvPolicyEntry的用法示例。


在下文中一共展示了CvPolicyEntry::GetFlavorValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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]);
    }
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:35,代码来源:CvPolicyAI.cpp

示例2: ChooseNextPolicy


//.........这里部分代码省略.........
                    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)
                    {
                        LogPolicyChoice((PolicyTypes)*it);
                        return (*it) + GC.getNumPolicyBranchInfos();
                    }
                }
            }
        }
    }

    CvAssertMsg(m_AdoptablePolicies.GetTotalWeight() >= 0, "Total weights of considered policies should not be negative! Please send Anton your save file and version.");

    // If total weight is above 0, choose one above a threshold
    if(m_AdoptablePolicies.GetTotalWeight() > 0)
    {
        int iNumChoices = GC.getGame().getHandicapInfo().GetPolicyNumOptions();
        iRtnValue = m_AdoptablePolicies.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing policy from Top Choices");
    }
    // Total weight may be 0 if the only branches and policies left are ones that are ineffective in our game, but we gotta pick something
    else if(m_AdoptablePolicies.GetTotalWeight() == 0 && m_AdoptablePolicies.size() > 0)
    {
        iRtnValue = m_AdoptablePolicies.ChooseAtRandom(&fcn, "Choosing policy at random (no good choices)");
    }

    // Log our choice
    if(iRtnValue != (int)NO_POLICY)
    {
        if(iRtnValue >= GC.getNumPolicyBranchInfos())
        {
            LogPolicyChoice((PolicyTypes)(iRtnValue - GC.getNumPolicyBranchInfos()));
        }
        else
        {
            LogBranchChoice((PolicyBranchTypes)iRtnValue);
        }
    }

    return iRtnValue;
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:101,代码来源:CvPolicyAI.cpp

示例3: ChooseNextPolicy


//.........这里部分代码省略.........

						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)
					{
						LogPolicyChoice((PolicyTypes)*it);
						return (*it) + GC.getNumPolicyBranchInfos();
					}
				}

			}
		}
	}
#endif
	CvAssertMsg(m_AdoptablePolicies.GetTotalWeight() >= 0, "Total weights of considered policies should not be negative! Please send Anton your save file and version.");

	// If total weight is above 0, choose one above a threshold
	if(m_AdoptablePolicies.GetTotalWeight() > 0)
	{
		int iNumChoices = GC.getGame().getHandicapInfo().GetPolicyNumOptions();
		iRtnValue = m_AdoptablePolicies.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing policy from Top Choices");
	}
	// Total weight may be 0 if the only branches and policies left are ones that are ineffective in our game, but we gotta pick something
	else if(m_AdoptablePolicies.GetTotalWeight() == 0 && m_AdoptablePolicies.size() > 0)
	{
		iRtnValue = m_AdoptablePolicies.ChooseAtRandom(&fcn, "Choosing policy at random (no good choices)");
	}

	// Log our choice
	if(iRtnValue != (int)NO_POLICY)
	{
		if(iRtnValue >= GC.getNumPolicyBranchInfos())
		{
			LogPolicyChoice((PolicyTypes)(iRtnValue - GC.getNumPolicyBranchInfos()));
		}
		else
		{
			LogBranchChoice((PolicyBranchTypes)iRtnValue);
		}
	}

	return iRtnValue;
}
开发者ID:potatoheads,项目名称:Community-Patch-DLL,代码行数:101,代码来源:CvPolicyAI.cpp


注:本文中的CvPolicyEntry::GetFlavorValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。