本文整理汇总了C++中CvAIGrandStrategyXMLEntry::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CvAIGrandStrategyXMLEntry::GetType方法的具体用法?C++ CvAIGrandStrategyXMLEntry::GetType怎么用?C++ CvAIGrandStrategyXMLEntry::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvAIGrandStrategyXMLEntry
的用法示例。
在下文中一共展示了CvAIGrandStrategyXMLEntry::GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogGrandStrategies
/// Log GrandStrategy state: what are the Priorities and who is Active?
void CvGrandStrategyAI::LogGrandStrategies(const FStaticVector< int, 5, true, c_eCiv5GameplayDLL >& vModifiedGrandStrategyPriorities)
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
CvString strDesc;
CvString strLogName;
// Find the name of this civ and city
playerName = GetPlayer()->getCivilizationShortDescription();
// Open the log file
if(GC.getPlayerAndCityAILogSplit())
{
strLogName = "GrandStrategyAI_Log_" + playerName + ".csv";
}
else
{
strLogName = "GrandStrategyAI_Log.csv";
}
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);
AIGrandStrategyTypes eGrandStrategy;
// Loop through Grand Strategies
for(int iGrandStrategyLoop = 0; iGrandStrategyLoop < GC.getNumAIGrandStrategyInfos(); iGrandStrategyLoop++)
{
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategyLoop;
// GrandStrategy Info
CvAIGrandStrategyXMLEntry* pEntry = GC.getAIGrandStrategyInfo(eGrandStrategy);
const char* szAIGrandStrategyType = (pEntry != NULL)? pEntry->GetType() : "Unknown Type";
if(GetActiveGrandStrategy() == eGrandStrategy)
{
strTemp.Format("*** %s, %d, %d", szAIGrandStrategyType, GetGrandStrategyPriority(eGrandStrategy), vModifiedGrandStrategyPriorities[eGrandStrategy]);
}
else
{
strTemp.Format("%s, %d, %d", szAIGrandStrategyType, GetGrandStrategyPriority(eGrandStrategy), vModifiedGrandStrategyPriorities[eGrandStrategy]);
}
strOutBuf = strBaseString + strTemp;
pLog->Msg(strOutBuf);
}
}
}
示例2: DoGuessOtherPlayersActiveGrandStrategy
/// 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);
//.........这里部分代码省略.........
示例3: DoTurn
/// Runs every turn to determine what the player's Active Grand Strategy is and to change Priority Levels as necessary
void CvGrandStrategyAI::DoTurn()
{
DoGuessOtherPlayersActiveGrandStrategy();
int iGrandStrategiesLoop;
AIGrandStrategyTypes eGrandStrategy;
CvAIGrandStrategyXMLEntry* pGrandStrategy;
CvString strGrandStrategyName;
// Loop through all GrandStrategies to set their Priorities
for(iGrandStrategiesLoop = 0; iGrandStrategiesLoop < GetAIGrandStrategies()->GetNumAIGrandStrategies(); iGrandStrategiesLoop++)
{
eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategiesLoop;
pGrandStrategy = GetAIGrandStrategies()->GetEntry(iGrandStrategiesLoop);
strGrandStrategyName = (CvString) pGrandStrategy->GetType();
// Base Priority looks at Personality Flavors (0 - 10) and multiplies * the Flavors attached to a Grand Strategy (0-10),
// so expect a number between 0 and 100 back from this
int iPriority = GetBaseGrandStrategyPriority(eGrandStrategy);
if(strGrandStrategyName == "AIGRANDSTRATEGY_CONQUEST")
{
iPriority += GetConquestPriority();
}
else if(strGrandStrategyName == "AIGRANDSTRATEGY_CULTURE")
{
iPriority += GetCulturePriority();
}
else if(strGrandStrategyName == "AIGRANDSTRATEGY_UNITED_NATIONS")
{
iPriority += GetUnitedNationsPriority();
}
else if(strGrandStrategyName == "AIGRANDSTRATEGY_SPACESHIP")
{
iPriority += GetSpaceshipPriority();
}
// Random element
iPriority += GC.getGame().getJonRandNum(/*50*/ GC.getAI_GS_RAND_ROLL(), "Grand Strategy AI: GS rand roll.");
// Give a boost to the current strategy so that small fluctuation doesn't cause a big change
if(GetActiveGrandStrategy() == eGrandStrategy && GetActiveGrandStrategy() != NO_AIGRANDSTRATEGY)
{
iPriority += /*50*/ GC.getAI_GRAND_STRATEGY_CURRENT_STRATEGY_WEIGHT();
}
SetGrandStrategyPriority(eGrandStrategy, iPriority);
}
// Now look at what we think the other players in the game are up to - we might have an opportunity to capitalize somewhere
int iNumPlayersAliveAndMet = 0;
int iMajorLoop;
for(iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)
{
if(GET_PLAYER((PlayerTypes) iMajorLoop).isAlive())
{
if(GET_TEAM(GetPlayer()->getTeam()).isHasMet(GET_PLAYER((PlayerTypes) iMajorLoop).getTeam()))
{
iNumPlayersAliveAndMet++;
}
}
}
FStaticVector< int, 5, true, c_eCiv5GameplayDLL > viNumGrandStrategiesAdopted;
int iNumPlayers;
// Init vector
for(iGrandStrategiesLoop = 0; iGrandStrategiesLoop < GetAIGrandStrategies()->GetNumAIGrandStrategies(); iGrandStrategiesLoop++)
{
iNumPlayers = 0;
// Tally up how many players we think are pusuing each Grand Strategy
for(iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)
{
if(GetGuessOtherPlayerActiveGrandStrategy((PlayerTypes) iMajorLoop) == (AIGrandStrategyTypes) iGrandStrategiesLoop)
{
iNumPlayers++;
}
}
viNumGrandStrategiesAdopted.push_back(iNumPlayers);
}
FStaticVector< int, 5, true, c_eCiv5GameplayDLL > viGrandStrategyChangeForLogging;
int iChange;
// Now modify our preferences based on how many people are going for stuff
for(iGrandStrategiesLoop = 0; iGrandStrategiesLoop < GetAIGrandStrategies()->GetNumAIGrandStrategies(); iGrandStrategiesLoop++)
{
eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategiesLoop;
// If EVERYONE else we know is also going for this Grand Strategy, reduce our Priority by 50%
iChange = GetGrandStrategyPriority(eGrandStrategy) * /*50*/ GC.getAI_GRAND_STRATEGY_OTHER_PLAYERS_GS_MULTIPLIER();
iChange = iChange * viNumGrandStrategiesAdopted[eGrandStrategy] / iNumPlayersAliveAndMet;
iChange /= 100;
ChangeGrandStrategyPriority(eGrandStrategy, -iChange);
//.........这里部分代码省略.........
示例4: LogGuessOtherPlayerGrandStrategy
/// Log our guess as to other Players' Active Grand Strategy
void CvGrandStrategyAI::LogGuessOtherPlayerGrandStrategy(const FStaticVector< int, 5, true, c_eCiv5GameplayDLL >& vGrandStrategyPriorities, PlayerTypes ePlayer)
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
CvString otherPlayerName;
CvString strDesc;
CvString strLogName;
// Find the name of this civ and city
playerName = GetPlayer()->getCivilizationShortDescription();
// Open the log file
if(GC.getPlayerAndCityAILogSplit())
{
strLogName = "GrandStrategyAI_Guess_Log_" + playerName + ".csv";
}
else
{
strLogName = "GrandStrategyAI_Guess_Log.csv";
}
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);
AIGrandStrategyTypes eGrandStrategy;
int iPriority;
// Loop through Grand Strategies
for(int iGrandStrategyLoop = 0; iGrandStrategyLoop < GC.getNumAIGrandStrategyInfos(); iGrandStrategyLoop++)
{
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategyLoop;
iPriority = vGrandStrategyPriorities[iGrandStrategyLoop];
CvAIGrandStrategyXMLEntry* pEntry = GC.getAIGrandStrategyInfo(eGrandStrategy);
const char* szGrandStrategyType = (pEntry != NULL)? pEntry->GetType() : "Unknown Strategy";
// GrandStrategy Info
if(GetActiveGrandStrategy() == eGrandStrategy)
{
strTemp.Format("*** %s, %d", szGrandStrategyType, iPriority);
}
else
{
strTemp.Format("%s, %d", szGrandStrategyType, iPriority);
}
otherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescription();
strOutBuf = strBaseString + otherPlayerName + ", " + strTemp;
if(GetGuessOtherPlayerActiveGrandStrategy(ePlayer) == eGrandStrategy)
{
// Confidence in our guess
switch(GetGuessOtherPlayerActiveGrandStrategyConfidence(ePlayer))
{
case GUESS_CONFIDENCE_POSITIVE:
strTemp.Format("Positive");
break;
case GUESS_CONFIDENCE_LIKELY:
strTemp.Format("Likely");
break;
case GUESS_CONFIDENCE_UNSURE:
strTemp.Format("Unsure");
break;
default:
strTemp.Format("XXX");
break;
}
strOutBuf += ", " + strTemp;
}
pLog->Msg(strOutBuf);
}
// One more entry for NO GRAND STRATEGY
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
iPriority = vGrandStrategyPriorities[GC.getNumAIGrandStrategyInfos()];
// GrandStrategy Info
strTemp.Format("NO_GRAND_STRATEGY, %d", iPriority);
otherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescription();
strOutBuf = strBaseString + otherPlayerName + ", " + strTemp;
pLog->Msg(strOutBuf);
}
}