Aggressive AI

Sure and I'll just get an API key for DeepBlue and then we'll be set!

You guys can be ridiculous sometimes.

G

Alpha Go seem more interesting that deep Deep Blue, if you'd ask me. If we'd have had an AI like that, a human would never be victorious again.

EDIT: "Even though DeepMind is looking towards more “serious” issues to tackle with its artificial intelligence, Go is not the last game its AI will try to master. StarCraft 2 seems to be the next in line."

Why not Civilization!?
 
Last edited:
Wow, it's easy to forget that smart scripted behaviour comes at the cost of very complex coding.

I kind of wonder if improvements to the AI to take into account previous wars could be accomplished using a modmod, and if it did, what level of complexity causes game performance issues.

From what I've seen problems tend to arise mostly with memory overflow, but overly complex code routines (e.g. that calculate the same plot 7 times, I think I saw something about that) can slow things down too. Hmm.

Although, debugging that would probably be a nightmare.
 
iWeight = (int)GetWarProjection(eTarget) + 1;
War projections sounds like its examine the possibilty of winning a war. Is there a calculation in the background which sets the value to 0 or 1?
If so, then I would insert the modifier in the calculation that results in the output of a 1 or a 0.
 
War projections sounds like its examine the possibilty of winning a war. Is there a calculation in the background which sets the value to 0 or 1?
If so, then I would insert the modifier in the calculation that results in the output of a 1 or a 0.
It return a value updated frequently, which is either:

VERY_GOOD (which mostly mean warscore 100)
GOOD (100 > WS >= 25)
UNKNOW (25 > WS > 0)
STALEMATE (0 >= WS > -25)
DEFEAT (-25 >= WS > -100)
DESTRUCTION (WS = -100)

Then, there is a ton of conditions that put the value back to STALEMATE in certain cases (for exemple, if the warscore is high but the AI no longer have any unit nearby)

So this call seems useless if you are not already at war with the player, since you don't have warscore
(@Gazebo, is it normal that GetWarProjection is used when chosing to declare war? There is not yet any warscore, so it feels kind of strange)

@BiteInTheMark, I think the civ strength are not directly used in the war declaration. They are taken in account in the Approach mecanics (if you are stronger, the AI will probably not be in the approach "want to be at war with you"), but that's a whole bug part of code, and I don't really have the time to dig in to find all the place where it is modified.

(see this gigantic file for more infos: https://raw.githubusercontent.com/L...er/CvGameCoreDLL_Expansion2/CvDiplomacyAI.cpp)
 
My intention wasnt to get that modifier working right now. :)
But simply a suggestion how we could add one more smart aspect to the AI to deal with some irregular behavior.
 
No. That's far more complex. The code is there:

Code:
/// Handles declarations of War for this AI
void CvDiplomacyAI::DoMakeWarOnPlayer(PlayerTypes eTargetPlayer)
{
   CvAIOperation* pOperation;
    bool bWantToAttack = false;
    bool bDeclareWar = false;

    if(!IsPlayerValid(eTargetPlayer))
        return;

    if(GetWarGoal(eTargetPlayer) == WAR_GOAL_DEMAND)
        return;

    if(IsAtWar(eTargetPlayer))
        return;

    // Don't make demands of them too often (deal speed best idea)
    if(GetNumTurnsSinceStatementSent(eTargetPlayer, DIPLO_STATEMENT_DEMAND) <= GC.getGame().getGameSpeedInfo().GetDealDuration())
        return;

    bool bAtWarWithAtLeastOneMajor = MilitaryAIHelpers::IsTestStrategy_AtWar(m_pPlayer, false);
    // Minor Civ
    if(GET_PLAYER(eTargetPlayer).isMinorCiv())
    {
        bWantToAttack = !bAtWarWithAtLeastOneMajor && (GetMinorCivApproach(eTargetPlayer) == MINOR_CIV_APPROACH_CONQUEST);
        pOperation = GetPlayer()->GetMilitaryAI()->GetSneakAttackOperation(eTargetPlayer);
    }
    // Major Civ
    else
    {
        MajorCivApproachTypes eApproach = GetMajorCivApproach(eTargetPlayer, /*bHideTrueFeelings*/ false);
        bWantToAttack = (eApproach == MAJOR_CIV_APPROACH_WAR || (eApproach <= MAJOR_CIV_APPROACH_HOSTILE && IsGoingForWorldConquest()));
        bWantToAttack = bWantToAttack && !bAtWarWithAtLeastOneMajor; // let's not get into another war right now
        if(MOD_DIPLOMACY_CIV4_FEATURES && bWantToAttack)
        {
            if(IsPlayerMoveTroopsRequestAccepted(eTargetPlayer))
            {
                bWantToAttack = false;    // don't declare war on a player we promised not to attack, unless we're wily!
            }
        }
        pOperation = GetPlayer()->GetMilitaryAI()->GetSneakAttackOperation(eTargetPlayer);
    }

    // Not yet readying an attack
    if(pOperation == NULL && !IsMusteringForAttack(eTargetPlayer))    // If we're "mustering" it means we had a Sneak Attack Operation that finished
    {
        if(!GET_TEAM(GetTeam()).isAtWar(GET_PLAYER(eTargetPlayer).getTeam()))
        {
            if(GET_TEAM(GetTeam()).canDeclareWar(GET_PLAYER(eTargetPlayer).getTeam(), GetPlayer()->GetID()))
            {
                // Want to declare war on someone
                if(bWantToAttack)
                {
                    SetWarGoal(eTargetPlayer, WAR_GOAL_PREPARE);

                    // Attack on minor
                    if(GET_PLAYER(eTargetPlayer).isMinorCiv())
                        GetPlayer()->GetMilitaryAI()->RequestCityStateAttack(eTargetPlayer);
                    // Attack on major
                    else
                    {
                        GetPlayer()->GetMilitaryAI()->RequestSneakAttack(eTargetPlayer);
                        SetWantsSneakAttack(eTargetPlayer, true);
                    }
                }
                else
                {
                    SetWarGoal(eTargetPlayer, NO_WAR_GOAL_TYPE);
                    SetWantsSneakAttack(eTargetPlayer, false);
                }
            }
        }
    }
    // We already have an attack on the way
    else
    {
        // Our Approach with this player calls for war
        if(bWantToAttack)
        {
            if(!IsAtWar(eTargetPlayer))
            {
                if(GET_TEAM(GetTeam()).canDeclareWar(GET_PLAYER(eTargetPlayer).getTeam(), GetPlayer()->GetID()))
                {
                    // If we're at least 85% of the way to our objective, let loose the dogs of war!
                    if(IsMusteringForAttack(eTargetPlayer) || (pOperation != NULL && pOperation->GetOperationState() == AI_OPERATION_STATE_SUCCESSFUL_FINISH))    // If we're "mustering" it means we have a Sneak Attack Operation that's in position to attack
                    {
                        bDeclareWar = true;
                        SetMusteringForAttack(eTargetPlayer, false);
                        SetWantsSneakAttack(eTargetPlayer, false);
                    }
                }
            }
        }

        // We were planning an attack, but changed our minds so abort
        else
        {
            if(pOperation != NULL)
            {
                SetWantsSneakAttack(eTargetPlayer, false);
                pOperation->SetToAbort(AI_ABORT_DIPLO_OPINION_CHANGE);
                SetWarGoal(eTargetPlayer, NO_WAR_GOAL_TYPE);
                SetMusteringForAttack(eTargetPlayer, false);
            }
        }

        // If our Sneak Attack is read then actually initiate the DoW
        if(bDeclareWar)
        {
            DeclareWar(eTargetPlayer);
            SetWantsSneakAttack(eTargetPlayer, false);
        }
    }
}

/// Handles declarations of War for this AI
void CvDiplomacyAI::MakeWar()
{
    CvWeightedVector<int> playerList;
    int iWeight;

    if((int)m_eTargetPlayer >= (int)DIPLO_FIRST_PLAYER)
    {
        DoMakeWarOnPlayer((PlayerTypes)m_eTargetPlayer);
    }
    else
    {
        for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)
        {
            PlayerTypes eTarget = (PlayerTypes)iPlayerLoop;
            if(GC.getGame().isReallyNetworkMultiPlayer() && MOD_ACTIVE_DIPLOMACY)
            {
                if (IsPlayerValid(eTarget))
                {
                    iWeight = (int)GetWarProjection(eTarget) + 1;

                    // Square the distance enum to make it crucial
                    iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget));
                    iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget));

                    if(iPlayerLoop < MAX_MAJOR_CIVS)
                    {
                        if(GetMajorCivOpinion(eTarget) == MAJOR_CIV_OPINION_UNFORGIVABLE)
                        {
                            iWeight *= 2;
                        }

                        iWeight *= 10;  // Make sure majors are looked at before city states
                    }

                    playerList.push_back(iPlayerLoop, iWeight);
                }
            }
            else
            {
                if(IsValidUIDiplomacyTarget(eTarget) && IsPlayerValid(eTarget))
                {
                    iWeight = (int)GetWarProjection(eTarget) + 1;

                    // Square the distance enum to make it crucial
                    iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget));
                    iWeight *= (1 + (int)GetPlayer()->GetProximityToPlayer(eTarget));

                    if(iPlayerLoop < MAX_MAJOR_CIVS)
                    {
                        if(GetMajorCivOpinion(eTarget) == MAJOR_CIV_OPINION_UNFORGIVABLE)
                        {
                            iWeight *= 2;
                        }

                        iWeight *= 10;  // Make sure majors are looked at before city states
                    }

                    playerList.push_back(iPlayerLoop, iWeight);
                }
            }
        }

        playerList.SortItems();

        for(int iI = 0; iI < playerList.size(); iI++)
        {
            DoMakeWarOnPlayer((PlayerTypes)playerList.GetElement(iI));
        }
    }

    // Increment counters for co-op wars we have agreed to - this may trigger war
    for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)
    {
        PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;

        if(IsPlayerValid(eLoopPlayer))
        {
            if(!GET_PLAYER(eLoopPlayer).isMinorCiv())
            {
                for(int iThirdPlayerLoop = 0; iThirdPlayerLoop < MAX_MAJOR_CIVS; iThirdPlayerLoop++)
                {
                    PlayerTypes eThirdPlayer = (PlayerTypes) iThirdPlayerLoop;
                    if (IsPlayerValid(eThirdPlayer))
                    {
                        if(GetCoopWarCounter(eLoopPlayer, eThirdPlayer) >= 0)
                        {
                            ChangeCoopWarCounter(eLoopPlayer, eThirdPlayer, 1);

                            // AI players will always declare war at 10 turns, so we simplify things here - humans are handled by DoCoopWarTimeStatement()
                            if(!GET_PLAYER(eLoopPlayer).isHuman())
                            {
                                if(GetCoopWarAcceptedState(eLoopPlayer, eThirdPlayer) == COOP_WAR_STATE_SOON &&
                                    GetCoopWarCounter(eLoopPlayer, eThirdPlayer) == /*10*/ GC.getCOOP_WAR_SOON_COUNTER())
                                {
                                    // Us
                                    SetCoopWarAcceptedState(eLoopPlayer, eThirdPlayer, COOP_WAR_STATE_ACCEPTED);
                                    SetCoopWarCounter(eLoopPlayer, eThirdPlayer, 0);
                                    DeclareWar(eThirdPlayer);
                                    GetPlayer()->GetMilitaryAI()->RequestBasicAttack(eThirdPlayer, 2);

                                    int iLockedTurns = /*15*/ GC.getCOOP_WAR_LOCKED_LENGTH();
                                    GET_TEAM(GetPlayer()->getTeam()).ChangeNumTurnsLockedIntoWar(GET_PLAYER(eThirdPlayer).getTeam(), iLockedTurns);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Keep in mind that these are two separate functions - the real lynchpin is here:

Code:
bWantToAttack = (eApproach == MAJOR_CIV_APPROACH_WAR || (eApproach <= MAJOR_CIV_APPROACH_HOSTILE && IsGoingForWorldConquest()));
bWantToAttack = bWantToAttack && !bAtWarWithAtLeastOneMajor; // let's not get into another war right now

This is the crux of it - if the AI isn't MAJOR_CIV_APPROACH_WAR (or going for world conquest and hostile), it won't seek out aggressive wars. It may still be bribed, but it won't start a war on its own. So, the real meat of the decision-making for war is here: CvDiplomacyAI::GetBestApproachTowardsMajorCiv

This is a massive function, one I rewrote entirely (as the Firaxis one was steaming garbage full of hardcoded values).

Regarding this:
Code:
iWeight = (int)GetWarProjection(eTarget) + 1;

War Projections have two states - at war and not at war. If at war, it looks at war score; if not, it looks at strength averages. All this does, though, is sort players by value for 'making war' - they'll skip a player if the bWantToAttack above is false.

G
 
Okay, it looks like the code for CvDiplomacyAI::GetBestApproachTowardsMajorCiv is here. This is gonna take some time to understand, but if anyone's interested, I think this is the complete function.

EDIT: Translated into a more human-readable format in the post below. Updated to 7-15 version with bugfixes.

Code:
/// What is the best approach to take towards a player?  Can also pass in iHighestWeight by reference if you just want to know what the player feels most strongly about without actually caring about WHAT it is
MajorCivApproachTypes CvDiplomacyAI::GetBestApproachTowardsMajorCiv(PlayerTypes ePlayer, int& iHighestWeight, bool bLookAtOtherPlayers, bool bLog, WarFaceTypes& eWarFace)
{
   CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");
    CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");

    TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam();

    PlayerTypes eMyPlayer = GetPlayer()->GetID();

    MajorCivApproachTypes eApproach;
    // This vector is what we'll stuff the values into first, and pass it into our logging function (which can't take a CvWeightedVector, which we need to sort...)
    FStaticVector< int, 128, true, c_eCiv5GameplayDLL > viApproachWeights;

    int iApproachLoop;

    viApproachWeights.clear();

    for (iApproachLoop = 0; iApproachLoop < NUM_MAJOR_CIV_APPROACHES; iApproachLoop++)
    {
        viApproachWeights.push_back(0);
    }
#if defined(MOD_BALANCE_CORE)
    ////////////////////////////////////
    // CURRENT APPROACH BIASES
    ////////////////////////////////////

    // Bias for our current Approach.  This should prevent it from jumping around from turn-to-turn as much
    // We use the scratch pad here since the normal array has been cleared so that we have knowledge of who we've already assigned an Approach for this turn; this should be the only place the scratch pad is used
    MajorCivApproachTypes eOldApproach = (MajorCivApproachTypes)m_paeApproachScratchPad[ePlayer];
    if (eOldApproach == NO_MAJOR_CIV_APPROACH)
        eOldApproach = MAJOR_CIV_APPROACH_NEUTRAL;

    FStaticVector< int, 128, true, c_eCiv5GameplayDLL > viApproachWeightsPersonality;
    for (iApproachLoop = 0; iApproachLoop < NUM_MAJOR_CIV_APPROACHES; iApproachLoop++)
    {
        viApproachWeightsPersonality.push_back(GetPersonalityMajorCivApproachBias((MajorCivApproachTypes)iApproachLoop));
    }

    ////////////////////////////////////
    // NEUTRAL DEFAULT WEIGHT
    ////////////////////////////////////

    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];

    // If we're planning a war then give it a bias so that we don't get away from it too easily
    if (eOldApproach == MAJOR_CIV_APPROACH_WAR && GetWarGoal(ePlayer) == WAR_GOAL_PREPARE)
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;

    //Same for demand
    if (eOldApproach == MAJOR_CIV_APPROACH_HOSTILE && GetWarGoal(ePlayer) == WAR_GOAL_DEMAND)
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;

    // Wanted war last turn bias
    WarStateTypes eWarState = GetWarState(ePlayer);

    // Conquest bias: must be a stalemate or better to apply (or not at war yet)
    if (eWarState == NO_WAR_STATE_TYPE || eWarState > WAR_STATE_DEFENSIVE)
    {
        if (IsGoingForWorldConquest())
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
    }

#if defined(MOD_DIPLOMACY_CITYSTATES) || defined(MOD_BALANCE_CORE)
    //If we were given a quest to go to war with this player, that should influence our decision. Plus, it probably means he's a total jerk.
    for (int iMinorLoop = MAX_MAJOR_CIVS; iMinorLoop < MAX_CIV_PLAYERS; iMinorLoop++)
    {
        PlayerTypes eMinor = (PlayerTypes)iMinorLoop;
        if (eMinor != NO_PLAYER)
        {
            CvPlayer* pMinor = &GET_PLAYER(eMinor);
            if (pMinor)
            {
                CvMinorCivAI* pMinorCivAI = pMinor->GetMinorCivAI();
                TeamTypes eConquerorTeam = GET_TEAM(pMinor->getTeam()).GetKilledByTeam();

                if (pMinorCivAI && pMinorCivAI->IsActiveQuestForPlayer(eMyPlayer, MINOR_CIV_QUEST_WAR))
                {
                    if (pMinorCivAI->GetQuestData1(eMyPlayer, MINOR_CIV_QUEST_WAR) == ePlayer)
                    {
                        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 4;
                        break;
                    }
                }
                if (pMinorCivAI && pMinorCivAI->IsActiveQuestForPlayer(eMyPlayer, MINOR_CIV_QUEST_LIBERATION))
                {
                    if (pMinorCivAI->GetQuestData1(eMyPlayer, MINOR_CIV_QUEST_LIBERATION) == eMinor)
                    {
                        if (eConquerorTeam == eTeam)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 4;
                            break;
                        }
                    }
                }
                if (pMinorCivAI && pMinorCivAI->IsActiveQuestForPlayer(eMyPlayer, MINOR_CIV_QUEST_UNIT_GET_CITY))
                {
                    int iX = pMinorCivAI->GetQuestData1(eMyPlayer, MINOR_CIV_QUEST_UNIT_GET_CITY);
                    int iY = pMinorCivAI->GetQuestData2(eMyPlayer, MINOR_CIV_QUEST_UNIT_GET_CITY);

                    CvPlot* pPlot = GC.getMap().plot(iX, iY);
                    if (pPlot != NULL && pPlot->isCity())
                    {
                        if (pPlot->getOwner() == ePlayer)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 4;
                            break;
                        }
                    }
                }
            }
        }
    }
#endif

    ////////////////////////////////////
    // DECLARATION OF FRIENDSHIP
    ////////////////////////////////////

    if (IsDoFAccepted(ePlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 10;
    }

    ////////////////////////////////////
    // DENOUNCE
    ////////////////////////////////////

    // We denounced them
    if (IsDenouncedPlayer(ePlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = 0;
    }

    // We were friends and they betrayed us!
    if (IsFriendDenouncedUs(ePlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = 0;
    }

    // They denounced us
    if (GET_PLAYER(ePlayer).GetDiplomacyAI()->IsDenouncedPlayer(eMyPlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = 0;
    }

    //Coop War Denied?
    if (GetNumTimesCoopWarDenied(ePlayer) > 0)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= (GetNumTimesCoopWarDenied(ePlayer) * 2);
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += (GetNumTimesCoopWarDenied(ePlayer) * 2);
    }

    ////////////////////////////////////
    // MILITARY THREAT
    ////////////////////////////////////

    switch (GetMilitaryThreat(ePlayer))
    {
    case THREAT_CRITICAL:
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 8;
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 4;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case THREAT_SEVERE:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 4;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case THREAT_MAJOR:
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        break;
    case THREAT_MINOR:
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE];
        break;
    case THREAT_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    }

    switch (GetWarmongerThreat(ePlayer))
    {
    case THREAT_CRITICAL:
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 15;
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 7;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 8;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case THREAT_SEVERE:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 4;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case THREAT_MAJOR:
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 4;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case THREAT_MINOR:
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        break;
    case THREAT_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 3;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 3;
        break;
    }

    switch (GetVictoryBlockLevel(ePlayer))
    {
    case DISPUTE_LEVEL_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case BLOCK_LEVEL_WEAK:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case BLOCK_LEVEL_STRONG:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        break;
    case BLOCK_LEVEL_FIERCE:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 15;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        break;
    }

    // Weight for victory issues
    switch (GetWonderDisputeLevel(ePlayer))
    {
    case DISPUTE_LEVEL_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_WEAK:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_STRONG:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_FIERCE:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        break;
    }

    // Weight for victory issues
    switch (GetVictoryDisputeLevel(ePlayer))
    {
    case DISPUTE_LEVEL_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_WEAK:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_STRONG:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        break;
    case DISPUTE_LEVEL_FIERCE:
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 15;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 12;
        break;
    }

    switch (GetLandDisputeLevel(ePlayer))
    {
    case DISPUTE_LEVEL_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE];
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        break;
    case DISPUTE_LEVEL_WEAK:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] / 2;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] / 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] / 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] / 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] / 2;
        break;
    case DISPUTE_LEVEL_STRONG:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] ;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        break;
    case DISPUTE_LEVEL_FIERCE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        break;
    }

    if (GET_PLAYER(ePlayer).GetDiplomacyAI()->IsCloseToDominationVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
    }
    if (IsCloseToDominationVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 10;
    }
    int iNumCaps = GetPlayer()->GetNumCapitalCities();
    if (iNumCaps > 1)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * (2 * iNumCaps);
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * (2 * iNumCaps);
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * (2 * iNumCaps);
    }

    if (GET_PLAYER(ePlayer).GetDiplomacyAI()->IsCloseToSSVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 20;
    }
    if(IsCloseToSSVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
    }

    if(GET_PLAYER(ePlayer).GetDiplomacyAI()->IsCloseToDiploVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 10;
    }
    if(IsCloseToDiploVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
    }

    if(GET_PLAYER(ePlayer).GetDiplomacyAI()->IsCloseToCultureVictory())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 20;
    }

    //Special check for culture
    if(IsCloseToCultureVictory())
    {
        if(ePlayer == GetPlayer()->GetCulture()->GetCivLowestInfluence(false))
        {
            if(GetPlayerMilitaryStrengthComparedToUs(ePlayer) < STRENGTH_AVERAGE)
            {
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
            }
            else
            {
                viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 10;
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
            }
        }
        else
        {
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        }
    }

    VictoryTypes eSpaceshipVictory = (VictoryTypes) GC.getInfoTypeForString("VICTORY_SPACE_RACE", true);
    VictoryTypes eCulturalVictory = (VictoryTypes) GC.getInfoTypeForString("VICTORY_CULTURAL", true);
    VictoryTypes eDiplomaticVictory = (VictoryTypes) GC.getInfoTypeForString("VICTORY_DIPLOMATIC", true);
    VictoryTypes eDominationVictory = (VictoryTypes) GC.getInfoTypeForString("VICTORY_DOMINATION", true);

    //// Only war? ONLY WAR
    if(!GC.getGame().isVictoryValid(eSpaceshipVictory) && !GC.getGame().isVictoryValid(eCulturalVictory) && !GC.getGame().isVictoryValid(eDiplomaticVictory))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 20;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 20;
    }

    //// NO WAR?
    if(!GC.getGame().isVictoryValid(eDominationVictory))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
    }

    if(GetPlayer()->IsCramped())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
    }

    if(m_pPlayer->GetCulture()->GetWarWeariness() > 0 && m_pPlayer->IsEmpireVeryUnhappy())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * m_pPlayer->GetCulture()->GetWarWeariness() * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * m_pPlayer->GetCulture()->GetWarWeariness() * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * m_pPlayer->GetCulture()->GetWarWeariness() * 5;
    }

    ////////////////////////////////////
    // NUKES
    ////////////////////////////////////

    int iTheirNukes = GET_PLAYER(ePlayer).getNumNukeUnits();
    int iOurNukes = m_pPlayer->getNumNukeUnits();
    int iHowLikelyAreTheyToNukeUs = GET_PLAYER(ePlayer).isHuman() ? 100 : 0; // assume humans will use 'em if they've got 'em
    if (iHowLikelyAreTheyToNukeUs == 0)
    {
        if (IsNukedBy(ePlayer) || GET_PLAYER(ePlayer).GetDiplomacyAI()->IsNukedBy(eMyPlayer)) // nukes have been used already
        {
            iHowLikelyAreTheyToNukeUs = 100;
        }
        //else if (GET_PLAYER(ePlayer).GetDiplomacyAI()->GetWarProjection(eMyPlayer) == WAR_PROJECTION_DESTRUCTION) // they are surely going to lose a war with
        //{
        //    iHowLikelyAreTheyToNukeUs = 100;
        //}
        else
        {
            int iFlavorNuke = GET_PLAYER(ePlayer).GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes)GC.getInfoTypeForString("FLAVOR_USE_NUKE")) + 1;
            iHowLikelyAreTheyToNukeUs = iFlavorNuke * iFlavorNuke; // use nukes has to pass 2 rolls
        }
    }
    // do we have nukes and they don't
    if(iTheirNukes == 0 && iOurNukes > 0)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
    }
    // do they have nukes and we don't
    else if (iTheirNukes > 0 && iOurNukes == 0 && iHowLikelyAreTheyToNukeUs > 50)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 25;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
    }
    // do we both have nukes
    else if (iTheirNukes > 0 && iOurNukes > 0 && iHowLikelyAreTheyToNukeUs > 25)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
    }

    int iPlayerLoop;
    PlayerTypes eLoopPlayer;

    ////////////////////////////////////
    // AT WAR RIGHT NOW
    ////////////////////////////////////

    for (iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
    {
        eLoopPlayer = (PlayerTypes) iPlayerLoop;

        // Don't look at the guy we're already thinking about or anyone on his team
        if(ePlayer != eLoopPlayer && GET_PLAYER(ePlayer).getTeam() != GET_PLAYER(eLoopPlayer).getTeam())
        {
            if(IsPlayerValid(eLoopPlayer))
            {
                if(GET_TEAM(GetTeam()).isAtWar(GET_PLAYER(eLoopPlayer).getTeam()))
                {
                    if(GetWarState(eLoopPlayer) == WAR_STATE_CALM || GetWarState(eLoopPlayer) == WAR_STATE_STALEMATE)
                    {
                        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
                        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] / 2);
                    }
                    else if(GetWarState(eLoopPlayer) == WAR_STATE_DEFENSIVE || GetWarState(eLoopPlayer) == WAR_STATE_NEARLY_DEFEATED)
                    {
                        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
                        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
                        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 4;
                    }
                    else if(GetWarState(eLoopPlayer) == WAR_STATE_OFFENSIVE || GetWarState(eLoopPlayer) == WAR_STATE_NEARLY_WON)
                    {
                        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
                        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] / 2);
                    }
                }
            }
        }
    }

    ////////////////////////////////////
    // APPROACHES TOWARDS OTHER PLAYERS
    ////////////////////////////////////

    // Look at Approaches we've already adopted for players we feel more strongly about
    if(bLookAtOtherPlayers)
    {
        for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
        {
            eLoopPlayer = (PlayerTypes) iPlayerLoop;

            // Don't look at the guy we're already thinking about
            if(eLoopPlayer != ePlayer)
            {
                if(IsPlayerValid(eLoopPlayer) && !GET_PLAYER(eLoopPlayer).isMinorCiv())
                {
                    // Planning war with this player? (Can't ONLY use the War Approach because this could have been cleared before, but we have to also check it because it could have just been set for someone else earlier this turn)
                    if(GetWarGoal(eLoopPlayer) == WAR_GOAL_PREPARE || GetWarGoal(eLoopPlayer) == WAR_GOAL_DEMAND || GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_WAR || GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_HOSTILE)
                    {
                        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
                        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;

                        //Is this a neighbor? We want our neighbors on our good side if we're going to war with others
                        if(GET_PLAYER(ePlayer).GetProximityToPlayer(GetPlayer()->GetID()) >= PLAYER_PROXIMITY_CLOSE)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 3;
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
                        }
                        //Is the target also a neighbor? Doubly important to have him on our good side!
                        if(GET_PLAYER(eLoopPlayer).GetProximityToPlayer(GetPlayer()->GetID()) >= PLAYER_PROXIMITY_CLOSE)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 3;
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
                        }
                    }

                    // Approaches already assigned to other higher-priority Majors
                    switch(GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ false))
                    {
                        case MAJOR_CIV_APPROACH_HOSTILE:
                            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
                            break;
                        case MAJOR_CIV_APPROACH_AFRAID:
                            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
                            break;
                        case MAJOR_CIV_APPROACH_DECEPTIVE:
                            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
                            break;
                        case MAJOR_CIV_APPROACH_GUARDED:
                            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
                            break;
                    }
                    //Has a defensive pact with him? Let's reduce our war interest.
                    if (GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).IsHasDefensivePact(GET_PLAYER(ePlayer).getTeam()))
                    {
                        if (GetPlayerMilitaryStrengthComparedToUs(eLoopPlayer) >= STRENGTH_AVERAGE)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                        }    
                    }

                    //Is this guy at war with the other player?
                    if (GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()))
                    {
                        //is this loop player our biggest competitor? We should like this guy!
                        if (GetBiggestCompetitor() == eLoopPlayer)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
                        }

                        //is this loop player our most valuable DOF or DP? We hate this other guy!
                        if (GetMostValuableDoF(false) == eLoopPlayer)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                        }
                        else if (GetMostValuableDefensivePact(false) == eLoopPlayer)
                        {
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                        }
                    }
                }
            }
        }
    }

    ////////////////////////////////////
    // Are we getting money from trade with them
    ////////////////////////////////////
    int iCurrentTradeValue = GetPlayer()->GetTrade()->GetAllTradeValueFromPlayerTimes100(YIELD_GOLD, ePlayer) / 100;
    if(iCurrentTradeValue > 0) // todo: add thresholds
    {
        // sanity check - if we will go negative from war with this player, don't go to war
        int iGPT = GetPlayer()->calculateGoldRate();
        int iDeltaGPT = ((iGPT - iCurrentTradeValue) / 2);
        if (iDeltaGPT < 0)
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += (iDeltaGPT / 2);
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += (iDeltaGPT / 2);
            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += (iDeltaGPT * -2);
            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += (iDeltaGPT * -2);
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += (iDeltaGPT * -2);
        }
    }

#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
    if (MOD_DIPLOMACY_CIV4_FEATURES)
    {
        //Master? Let's consider opinion of other people
        if (GET_TEAM(GET_PLAYER(ePlayer).getTeam()).GetNumVassals() > 0)
        {
            TeamTypes eLoopTeam;
            for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
            {
                eLoopPlayer = (PlayerTypes)iPlayerLoop;

                if (IsPlayerValid(eLoopPlayer))
                {
                    eLoopTeam = GET_PLAYER(eLoopPlayer).getTeam();
                    if (GET_TEAM(eLoopTeam).IsVassal(GET_PLAYER(ePlayer).getTeam()))
                    {
                        // Add opinion of vassal into this.
                        switch (GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ false))
                        {
                        case MAJOR_CIV_APPROACH_HOSTILE:
                            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
                            break;
                        case MAJOR_CIV_APPROACH_WAR:
                            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
                            break;
                        case MAJOR_CIV_APPROACH_DECEPTIVE:
                            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
                            break;
                        case MAJOR_CIV_APPROACH_GUARDED:
                            viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
                            break;
                        }
                    }
                }
            }
            //we like our vassal.
            if (GET_TEAM(GET_PLAYER(ePlayer).getTeam()).GetMaster() == GetPlayer()->GetID())
            {
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] = 0;
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] = 0;
            }
        }

        else if (IsVassal(ePlayer))
        {
            // Change approach based on how we are treated
            // todo: magic numbers
            switch(GetVassalTreatmentLevel(ePlayer))
            {
                case VASSAL_TREATMENT_CONTENT:
                    viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += 5;
                    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += 2;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] +=  -5;
                    viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += -5;
                    break;
                case VASSAL_TREATMENT_DISAGREE:
                    viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += 0;
                    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += 2;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] +=  2;
                    viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += 2;
                    break;
                case VASSAL_TREATMENT_MISTREATED:
                    viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += 0;
                    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += 2;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] +=  4;
                    viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += 4;
                    break;
                case VASSAL_TREATMENT_UNHAPPY:
                    viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += -6;
                    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += -4;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] +=  6;
                    viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += 8;
                    break;
                case VASSAL_TREATMENT_ENSLAVED:
                    viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += -6;
                    viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += -8;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] +=  10;
                    viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += 10;
                    break;
            }
        }
        if(IsAngryAboutPlayerVassalageForcefullyRevoked(ePlayer))
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += /*4*/ GC.getAPPROACH_WAR_VASSAL_FORCEFULLY_REVOKED();
            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += /*-10*/ GC.getAPPROACH_DECEPTIVE_VASSAL_FORCEFULLY_REVOKED();
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += /*-10*/ GC.getAPPROACH_FRIENDLY_VASSAL_FORCEFULLY_REVOKED();
        }
        if(IsHappyAboutPlayerVassalagePeacefullyRevoked(ePlayer))
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += /*-4*/ GC.getAPPROACH_WAR_VASSAL_PEACEFULLY_REVOKED();
            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += /*2*/ GC.getAPPROACH_DECEPTIVE_VASSAL_PEACEFULLY_REVOKED();
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += /*5*/ GC.getAPPROACH_FRIENDLY_VASSAL_PEACEFULLY_REVOKED();
        }
    }
#endif

    ////////////////////////////////////
    // WAR PROJECTION - how do we think a war against ePlayer will go?
    ////////////////////////////////////

    switch(GetWarProjection(ePlayer))
    {
    case WAR_PROJECTION_DESTRUCTION:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 15;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        break;
    case WAR_PROJECTION_DEFEAT:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        break;
    case WAR_PROJECTION_STALEMATE:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case WAR_PROJECTION_UNKNOWN:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case WAR_PROJECTION_GOOD:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        break;
    case WAR_PROJECTION_VERY_GOOD:
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_AFRAID] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        break;
    }

    switch(GetPlayerTargetValue(ePlayer))
    {
    case TARGET_VALUE_IMPOSSIBLE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        break;
    case TARGET_VALUE_BAD:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        break;
    case TARGET_VALUE_AVERAGE:
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        break;
    case TARGET_VALUE_FAVORABLE:
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        break;
    case TARGET_VALUE_SOFT:
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        break;
    }

    // Military Aggressive Posture
    switch(GetMilitaryAggressivePosture(ePlayer))
    {
    case AGGRESSIVE_POSTURE_NONE:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        break;
    case AGGRESSIVE_POSTURE_LOW:
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        break;
    case AGGRESSIVE_POSTURE_MEDIUM:
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED];
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE];
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL];
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY];
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR];
        break;
    case AGGRESSIVE_POSTURE_HIGH:
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE];
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 2;
        break;
    case AGGRESSIVE_POSTURE_INCREDIBLE:
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        break;
    }

    ////////////////////////////////////
    // Is this player a reckless expander?
    ////////////////////////////////////

    if(IsPlayerRecklessExpander(ePlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
    }

    ////////////////////////////////////
    // Is this player already in a war with someone who isn't us?
    ////////////////////////////////////
    int iBonus = 0;
    bool bThinkingAboutDogpiling = false;
    for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
    {
        eLoopPlayer = (PlayerTypes) iPlayerLoop;

        // Is this a player we have relations with?
        if(eLoopPlayer != ePlayer && eLoopPlayer != GetPlayer()->GetID() && GET_PLAYER(eLoopPlayer).isMajorCiv() && GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->IsPlayerValid(ePlayer))
        {
            if(GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()))
            {
                WarProjectionTypes eWarProjection = GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->GetWarProjection(ePlayer);
                if(eWarProjection >= WAR_PROJECTION_GOOD)
                {
                    bThinkingAboutDogpiling = true;
                }
                DisputeLevelTypes eDisputeLevel = GetVictoryDisputeLevel(ePlayer);
                if(eDisputeLevel >= DISPUTE_LEVEL_STRONG)
                {
                    bThinkingAboutDogpiling = true;
                }
                BlockLevelTypes eBlockLevel = GetVictoryBlockLevel(ePlayer);
                if(eDisputeLevel >= BLOCK_LEVEL_STRONG)
                {
                    bThinkingAboutDogpiling = true;
                }
                if(GetPlayerTargetValue(eLoopPlayer) <= TARGET_VALUE_BAD)
                {
                    bThinkingAboutDogpiling = false;
                }
                if(bThinkingAboutDogpiling)
                {
                    iBonus += (int)eBlockLevel + (int)eDisputeLevel + (int)eWarProjection + GetPlayerTargetValue(eLoopPlayer);
                }
            }
        }
    }
    if (bThinkingAboutDogpiling && (iBonus > 0))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += iBonus / 2;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += iBonus / 2;
    }
#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
    if (MOD_DIPLOMACY_CIV4_FEATURES)
    {
        // This player is not our master
        if(GET_TEAM(GetTeam()).GetMaster() != GET_PLAYER(ePlayer).getTeam())
        {
            int iNumVassals = 0;
            PlayerTypes eLoopPlayer;
            for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
            {
                eLoopPlayer = (PlayerTypes) iPlayerLoop;
    
                if(GET_PLAYER(eLoopPlayer).isMinorCiv())
                    continue;

                if(GET_TEAM(GetTeam()).isHasMet(GET_PLAYER(eLoopPlayer).getTeam()))
                {
                    if(GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).GetMaster() == GET_PLAYER(ePlayer).getTeam())
                    {
                        iNumVassals++;
                    }
                }
            }

            viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= (100 + (iNumVassals * /*10*/ GC.getAPPROACH_WAR_TOO_MANY_VASSALS()));    // 1 vassal = 110%, 2 vassals = 120%
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
            viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] *= (100 + (iNumVassals * /*10*/ GC.getAPPROACH_GUARDED_TOO_MANY_VASSALS()));    // 1 vassal = 110%, 2 vassals = 120%
            viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] /= 100;
        }
    }
#endif

    ////////////////////////////////////
    // PEACE TREATY - have we made peace with this player before?  If so, reduce war weight
    ////////////////////////////////////

    if(GetNumWarsFought(ePlayer) > 0)
    {
        int iPeaceTreatyTurn = GET_TEAM(GetTeam()).GetTurnMadePeaceTreatyWithTeam(eTeam);
        if(iPeaceTreatyTurn > -1)
        {
            int iTurnsSincePeace = GC.getGame().getElapsedGameTurns() - iPeaceTreatyTurn;
            if(iTurnsSincePeace < /*25*/ GC.getTURNS_SINCE_PEACE_WEIGHT_DAMPENER())
            {
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
            }
        }
    }
    ////////////////////////////////////
    // DUEL - If there's only 2 players in this game, no friendly
    ////////////////////////////////////

    int iNumMajorsLeft = GC.getGame().countMajorCivsAlive();
    if(iNumMajorsLeft == 2)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
        if(IsGoingForWorldConquest())
        {
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = 0;
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += 1000;
        }
    }

    ////////////////////////////////////
    // COOP WAR - agreed to go to war with someone?
    ////////////////////////////////////

    if(IsLockedIntoCoopWar(ePlayer))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] += 100;
    }

    // DEFENSIVE PACT
    if(GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsHasDefensivePact(GET_PLAYER(ePlayer).getTeam()))
    {
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 15;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * 5;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * 5;
    }

#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
    if (MOD_DIPLOMACY_CIV4_FEATURES) {
        ////////////////////////////////////
        // Made a military promise?
        ////////////////////////////////////

        // Don't declare war if we made a military promise
        if(IsPlayerMadeMilitaryPromise(ePlayer))
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        }
    }
#endif

#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
    if (MOD_DIPLOMACY_CIV4_FEATURES) {
        // If we agreed not to go to war with this player, destroy weight for that
        if(IsPlayerMoveTroopsRequestAccepted(ePlayer))
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 10;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 10;
        }
    }
#endif

    ////////////////////////////////////
    // CAN WE DECLARE WAR?
    ////////////////////////////////////

#if defined(MOD_EVENTS_WAR_AND_PEACE)
    if(!GET_TEAM(GetTeam()).canDeclareWar(GET_PLAYER(ePlayer).getTeam(), GetPlayer()->GetID()))
#else
    if(!GET_TEAM(GetTeam()).canDeclareWar(GET_PLAYER(ePlayer).getTeam()))
#endif
    {
        // If we're already at war with this player don't cancel out the weight for them!
        if(!GET_TEAM(GetTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()))
        {
            if (MOD_DIPLOMACY_CIV4_FEATURES)
            {
                //If a vassal reduce but do not remove the value.
                if (GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsVassalOfSomeone())
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
                }
                else
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] = 0;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] = 0;
                }
            }
            else
            {
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] = 0;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] = 0;
            }
        }
        else
        {
            viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * 5;
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 5;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] += viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 5;
        }
    }
    ////////////////////////////////////
    // On the same team?
    ////////////////////////////////////
    if(GetTeam() == GET_PLAYER(ePlayer).getTeam())
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_AFRAID] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] = 0;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] = 100;
    }

    ////////////////////////////////////
    // DISTANCE - the farther away a player is the less likely we are to want to attack them!
    ////////////////////////////////////
    //Target capacity should matter! If we can't get to them, let's not try to war on them!
    if(!GET_TEAM(GetTeam()).isAtWar(GET_PLAYER(ePlayer).getTeam()) && (viApproachWeights[MAJOR_CIV_APPROACH_WAR] > 0 || viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] > 0))
    {
        bool bTargetLand = GetPlayer()->GetMilitaryAI()->HaveCachedAttackTarget(ePlayer, AI_OPERATION_CITY_SNEAK_ATTACK);
        bool bTargetSeaPure = GetPlayer()->GetMilitaryAI()->HaveCachedAttackTarget(ePlayer, AI_OPERATION_NAVAL_ONLY_CITY_ATTACK);
        bool bTargetSea = GetPlayer()->GetMilitaryAI()->HaveCachedAttackTarget(ePlayer, AI_OPERATION_NAVAL_INVASION_SNEAKY);
        if(!bTargetLand && !bTargetSeaPure && !bTargetSea)
        {
            CvMilitaryTarget target = GetPlayer()->GetMilitaryAI()->FindBestAttackTargetCached(AI_OPERATION_CITY_SNEAK_ATTACK, ePlayer);
            if(target.m_pTargetCity != NULL && target.m_pMusterCity != NULL)
            {
                if(target.m_bAttackBySea)
                {
                    bTargetSea = true;    
                }
                if (!target.m_bNoLandPath)
                {
                    bTargetLand = true;
                }
            }
            else
            {
                CvMilitaryTarget target = GetPlayer()->GetMilitaryAI()->FindBestAttackTargetCached(AI_OPERATION_NAVAL_ONLY_CITY_ATTACK, ePlayer);
                if (target.m_pTargetCity != NULL && target.m_pMusterCity != NULL)
                {
                    if (target.m_bAttackBySea)
                    {
                        bTargetSea = true;
                    }
                    if (!target.m_bNoLandPath)
                    {
                        bTargetLand = true;
                    }
                }
            }
        }
        //No target? Abort!
        if(!bTargetLand && !bTargetSeaPure && !bTargetSea)
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 15;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 15;
        }
        //Can't embark everywhere? Let's only target neighbors.
        else if(!GetPlayer()->CanCrossOcean())
        {
            // Factor in distance - only nearby land wars before the Renaissance.
            switch(GetPlayer()->GetProximityToPlayer(ePlayer))
            {
            case PLAYER_PROXIMITY_NEIGHBORS:
                if(bTargetLand)
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= (/*150*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS());
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*150*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                else
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                }
                break;
            case PLAYER_PROXIMITY_CLOSE:
                if(bTargetLand)
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                else
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 2;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 2;
                }
                break;
            case PLAYER_PROXIMITY_FAR:
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 3;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 3;
                break;
            case PLAYER_PROXIMITY_DISTANT:
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * 4;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] -= viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * 4;
                break;
            }
        }
        else
        {
            // Factor in distance
            switch(GetPlayer()->GetProximityToPlayer(ePlayer))
            {
            case PLAYER_PROXIMITY_NEIGHBORS:
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*150*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS();
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*150*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS();
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                break;
            case PLAYER_PROXIMITY_CLOSE:
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                break;
            case PLAYER_PROXIMITY_FAR:
                if(!IsGoingForWorldConquest())
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*75*/ GC.getAPPROACH_WAR_PROXIMITY_FAR();
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*75*/ GC.getAPPROACH_WAR_PROXIMITY_FAR();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                else
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS();
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_NEIGHBORS();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                break;
            case PLAYER_PROXIMITY_DISTANT:
                if(!IsGoingForWorldConquest())
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*50*/ GC.getAPPROACH_WAR_PROXIMITY_DISTANT();
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*50*/ GC.getAPPROACH_WAR_PROXIMITY_DISTANT();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                else
                {
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                    viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= /*125*/ GC.getAPPROACH_WAR_PROXIMITY_CLOSE();
                    viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;
                }
                break;
            }
        }
    }

    //we've got a UU? Let's see if it is time to go.
    if (GetPlayer()->HasUUPeriod())
    {
        bool bHasUU = GetPlayer()->HasUUActive();
        //We got it? Let's strike!
        if (GetPlayer()->GetPlayerTechs()->HasUUTech() && bHasUU)
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= 10;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= 10;
        }
        //Have tech but not UU? Hurry Up!
        else if (GetPlayer()->GetPlayerTechs()->HasUUTech() && !bHasUU)
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] *= 2;
        }

        //Don't have it but will have it soon? Delay.
        if (GetPlayer()->GetPlayerTechs()->WillHaveUUTechSoon())
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 5;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 5;
            viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] *= 2;
        }
        //Don't have it and won't have it soon? Delay.
        else
        {
            viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
            viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
        }
    }

    if (GetBiggestCompetitor() != ePlayer)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
    }
    else
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= 25;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= 25;
    }
    if (GetMostValuableDoF(false) == ePlayer)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] *= 25;
    }
    if (GetMostValuableDefensivePact(false) == ePlayer)
    {
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 10;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] *= 25;
    }

    ////////////////////////////////////
    // OPINION
    ////////////////////////////////////

    int iWarMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_WAR] * GetBoldness() * 2);
    int iHostileMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_HOSTILE] * GetDenounceWillingness() * 2);
    int iDeceptiveMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_DECEPTIVE] * GetMeanness() * 2);
    int iGuardedMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_GUARDED] * (10 - GetForgiveness()) * 2);
    int iFriendlyMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_FRIENDLY] * GetLoyalty() * 2);
    int iNeutralMod = (viApproachWeightsPersonality[MAJOR_CIV_APPROACH_NEUTRAL] * GetDiploBalance() * 2);

    int iOpinionWeight = GetMajorCivOpinionWeight(ePlayer);

    //Using weight as +/- % - a bit more fluid than the switch table.
    if(iOpinionWeight > 0)
    {
        //Increase
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= (100 + iWarMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= 100;

        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= (100 + iHostileMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= 100;

        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] *= (100 + iDeceptiveMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] /= 100;

        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] *= (100 + iGuardedMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] /= 100;

        //Decrease
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] *= 100;
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] /= max(100, (100 + iFriendlyMod + iOpinionWeight));

        //Above the flavor line? Drop neutral.
        if(iOpinionWeight > GC.getOPINION_THRESHOLD_COMPETITOR())
        {
            //Decrease Neutral
            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] *= 100;
            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] /=  max(100, (100 + iNeutralMod + iOpinionWeight));
        }
    }
    else if(iOpinionWeight < 0)
    {
        //Flip it!
        iOpinionWeight *= -1;

        //Increase
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] *= (100 + iFriendlyMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_FRIENDLY] /= 100;

        //Decrease
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] *= 100;
        viApproachWeights[MAJOR_CIV_APPROACH_WAR] /= max(100,(100 + iWarMod + iOpinionWeight));

        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] *= 100;
        viApproachWeights[MAJOR_CIV_APPROACH_HOSTILE] /= max(100,(100 + iHostileMod + iOpinionWeight));

        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] *= 100;
        viApproachWeights[MAJOR_CIV_APPROACH_DECEPTIVE] /= max(100,(100 + iDeceptiveMod + iOpinionWeight));

        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] *= 100;
        viApproachWeights[MAJOR_CIV_APPROACH_GUARDED] /= max(100,(100 + iGuardedMod + iOpinionWeight));

        //Below the flavor line? Drop neutral.
        if(iOpinionWeight < GC.getOPINION_THRESHOLD_FAVORABLE())
        {
            //Decrease Neutral
            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] *= 100;
            viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] /= max(100,(100 + iNeutralMod + iOpinionWeight));
        }
    }
    if (iOpinionWeight > GC.getOPINION_THRESHOLD_FAVORABLE() && iOpinionWeight < GC.getOPINION_THRESHOLD_COMPETITOR())
    {
        //Flip it!
        iOpinionWeight *= -1;

        //Increase Neutral
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] *= (100 + iNeutralMod + iOpinionWeight);
        viApproachWeights[MAJOR_CIV_APPROACH_NEUTRAL] /= 100;
    }

    bool bAllZero = true;

    //Save off the scratch value for logging!
    FStaticVector< int, 128, true, c_eCiv5GameplayDLL > viApproachWeightsScratch;
    viApproachWeightsScratch.clear();

    //Let's make this a gradual process no rapid jumping from value to value!
    for(iApproachLoop = 0; iApproachLoop < NUM_MAJOR_CIV_APPROACHES; iApproachLoop++)
    {
        int iLastTurnValue = GetPlayer()->GetApproachScratchValue(ePlayer, (MajorCivApproachTypes)iApproachLoop);
        viApproachWeightsScratch.push_back(iLastTurnValue);

        int iApproachValue = viApproachWeights[(MajorCivApproachTypes)iApproachLoop];

        if(iApproachValue > 0)
        {
            bAllZero = false;
        }

        float fAlpha = 0.10f;
        int  iAverage = int(0.5f + (iApproachValue * fAlpha) + (iLastTurnValue * ( 1 - fAlpha)));
        viApproachWeights[(MajorCivApproachTypes)iApproachLoop] = iAverage;

        //Set the new average for next turn.
        GetPlayer()->SetApproachScratchValue(ePlayer, (MajorCivApproachTypes)iApproachLoop, iAverage);
    }

    // This vector is what we'll use to sort
    CvWeightedVector< MajorCivApproachTypes, 128 > vApproachWeightsForSorting;
    vApproachWeightsForSorting.clear();

    // Transfer values from our normal int vector (which we need for logging) to the Weighted Vector we can sort
    for(iApproachLoop = 0; iApproachLoop < NUM_MAJOR_CIV_APPROACHES; iApproachLoop++)
    {
        vApproachWeightsForSorting.push_back((MajorCivApproachTypes) iApproachLoop, viApproachWeights[iApproachLoop]);
    }

    vApproachWeightsForSorting.SortItems();

    eApproach = vApproachWeightsForSorting.GetElement(0);
    iHighestWeight = vApproachWeightsForSorting.GetWeight(0);

    // If we're going to war then update how we're acting
    if(eApproach == MAJOR_CIV_APPROACH_WAR)
    {
        eWarFace = GetWarFaceWithPlayer(ePlayer);

        // If we haven't set WarFace on a previous turn, figure out what it should be
        if(eWarFace == NO_WAR_FACE_TYPE)
        {
            MajorCivApproachTypes eTempApproach;

            // Use index of 1 since we already know element 0 is war; that will give us the most reasonable approach
            eTempApproach = vApproachWeightsForSorting.GetElement(1);

            // Pick among the Approach types
            switch(eTempApproach)
            {

            case MAJOR_CIV_APPROACH_HOSTILE:
                eWarFace = WAR_FACE_HOSTILE;
                break;

            case MAJOR_CIV_APPROACH_DECEPTIVE:
                eWarFace = WAR_FACE_NEUTRAL;
                break;
            case MAJOR_CIV_APPROACH_AFRAID:
                eWarFace = WAR_FACE_HOSTILE;
                break;
            case MAJOR_CIV_APPROACH_FRIENDLY:
                eWarFace = WAR_FACE_FRIENDLY;
                break;
            default:
                eWarFace = WAR_FACE_NEUTRAL;
                break;
            }
        }
    }
    else
    {
        eWarFace = NO_WAR_FACE_TYPE;
    }

    // Don't want to log if we're just seeing what the highest weight is and don't care about what Approach we like
    if(bLog)
    {
        LogMajorCivApproachUpdate(ePlayer, viApproachWeights.begin(), eApproach, eOldApproach, eWarFace);
        LogApproachValueDeltas(ePlayer, viApproachWeights.begin(), viApproachWeightsScratch.begin());
    }
    //All at zero? Return neutral.
    if(bAllZero)
    {
        return MAJOR_CIV_APPROACH_NEUTRAL;
    }
#endif
    return eApproach;
}


/// What is our Diplomatic approach to this Major Civ?
MajorCivApproachTypes CvDiplomacyAI::GetMajorCivApproach(PlayerTypes ePlayer, bool bHideTrueFeelings) const
{
    CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");
    CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");

    MajorCivApproachTypes eApproach = (MajorCivApproachTypes) m_paeMajorCivApproach[ePlayer];

    // If we're hiding our true feelings then use the War Face or Friendly if we're Deceptive
    if(bHideTrueFeelings)
    {
        // Deceptive = Friendly
        if(eApproach == MAJOR_CIV_APPROACH_DECEPTIVE)
        {
            eApproach = MAJOR_CIV_APPROACH_FRIENDLY;
        }

        // War Face
        else if(eApproach == MAJOR_CIV_APPROACH_WAR)
        {
            switch(GetWarFaceWithPlayer(ePlayer))
            {
            case WAR_FACE_HOSTILE:
                eApproach = MAJOR_CIV_APPROACH_HOSTILE;
                break;
            case WAR_FACE_FRIENDLY:
                eApproach = MAJOR_CIV_APPROACH_FRIENDLY;
                break;
            case WAR_FACE_NEUTRAL:
                eApproach = MAJOR_CIV_APPROACH_NEUTRAL;
                break;
            default:
                CvAssert(false);
                break;
            }
        }
    }

    return eApproach;
}
 
Last edited:
Here's my (more complete and seemingly mostly correct understanding) of the way the function works. But I'd still appreciate clarifications from people who know more, if they have any comments. :)

Anyway, it should help people understand how the AI chooses their approach.

Every AI has a leader bias number for every different approach (the approaches being WAR, HOSTILE, AFRAID, GUARDED, DECEPTIVE, NEUTRAL, FRIENDLY).

These bias/flavor numbers (or "personality weight") are used many times in the calculations. They are defined XML values that are not randomized from game to game, and I don't believe Vox Populi changed them from BNW.

Every turn, the AI starts with:
WAR: 0
HOSTILE: 0
AFRAID: 0
GUARDED: 0
NEUTRAL: 0
DECEPTIVE: 0
FRIENDLY: 0

And then adds and removes points from each approach many times, using their bias/"personality weight" in some way, based on a number of factors. The approach with the highest number at the end of this process is the one selected.

The WAR approach just means this AI values war with the player most highly and they will plan a war against you, it does not necessarily mean war will be declared that very turn.

The DECEPTIVE approach is when the AI appears as FRIENDLY but is secretly plotting against you.

The process is as follows:
Code:
1. Current Approach Bias
What approach did we have towards this player last turn? This in some way modifies the final calculation. If we didn't have an approach towards this player last turn, assume it's NEUTRAL.


2. Default Weights
Add our NEUTRAL bias to the NEUTRAL approach.

Check if we were planning a war against them last turn. If yes, add 5x our WAR bias to the WAR approach.

Check if we were planning to demand from them last turn. If yes, add 5x our HOSTILE bias to the HOSTILE approach.

Domination Victory bias: If we're not at war yet, or we are at war and it's a stalemate or better (we're not playing defensively), and we're going for domination victory, add 10x WAR bias to the WAR approach.


3. City-State Quests
If a city-state gave us a quest to declare war on them, capture one of their cities, or liberate one of their cities, add 4x WAR bias to the WAR approach.


4. Declaration of Friendship
We have a Declaration of Friendship with this player:
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract 10x WAR bias from the WAR approach.
- Subtract 10x HOSTILE bias from the HOSTILE approach.
- Subtract 10x GUARDED bias from the GUARDED approach.
- Subtract 10x DECEPTIVE bias from the DECEPTIVE approach.
- Subtract 10x NEUTRAL bias from the NEUTRAL approach.


5. Denunciations
We've currently denounced this player:
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Set approach score for FRIENDLY to 0.

We were friends and they denounced us (at any time in the past):
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Set approach score for FRIENDLY to 0.


This player has currently denounced us:
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Set approach score for FRIENDLY to 0.


6. Co-Op War Request
They refused our request to do a co-op war at least once:

- Subtract 2x the # of times they refused the request from the FRIENDLY approach.
- Add 2x the # of times they refused the request to the DECEPTIVE approach.


7. Military Threat
What is this player's military threat level? (GetMilitaryThreat function)

CRITICAL
- Add 8x WAR bias to the WAR approach.
- Add 5x AFRAID bias to the AFRAID approach.
- Add GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract 4x HOSTILE bias from the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

SEVERE
- Add 3x AFRAID bias to the AFRAID approach.
- Add 5x WAR bias to the WAR approach.
- Add 4x GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract 3x HOSTILE bias from the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MAJOR
- Add 3x WAR bias to the WAR approach.
- Add 3x DECEPTIVE bias to the DECEPTIVE approach.
- Add 3x HOSTILE bias to the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.

MINOR
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Add DECEPTIVE bias to the DECEPTIVE approach.

NONE
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract GUARDED bias from the GUARDED approach.
- Subtract HOSTILE bias from the HOSTILE approach.


8. Warmonger Threat
What is this player's warmonger threat level? (GetWarmongerThreat function)

CRITICAL
- Add 15x WAR bias to the WAR approach.
- Add 7x AFRAID bias to the AFRAID approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Add 8x HOSTILE bias to the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

SEVERE
- Add 5x AFRAID bias to the AFRAID approach.
- Add 10x WAR bias to the WAR approach.
- Add 4x HOSTILE bias to the HOSTILE approach.
- Add GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MAJOR
- Add 4x WAR bias to the WAR approach.
- Add 3x HOSTILE bias to the HOSTILE approach.
- Add GUARDED bias to the GUARDED approach.
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MINOR
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract 2x HOSTILE bias from the HOSTILE approach.

NONE
- Add 3x NEUTRAL bias to the NEUTRAL approach.
- Add 3x FRIENDLY bias to the FRIENDLY approach.
- Subtract 3x HOSTILE bias from the HOSTILE approach.


9. Victory Block Level
How much do we want to stop this player from winning? (GetVictoryBlockLevel function; the farther you are in the lead, the more they hate you)

NO DESIRE
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK DESIRE
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG DESIRE
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

FIERCE DESIRE
- Add 15x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.




10. Wonder Competitiveness Level
How much are we competing with this player for World Wonders? (GetWonderDisputeLevel function)

NO COMPETITION
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK COMPETITION
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG COMPETITION
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add GUARDED bias to the GUARDED approach.
- Add WAR bias to the WAR approach.
- Add HOSTILE bias to the HOSTILE approach.

FIERCE COMPETITION
- Add 5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.



11. Victory Competitiveness Level
What is their level of competitiveness with us for the same victory condition? (GetVictoryDisputeLevel function)

NO COMPETITION
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK COMPETITION
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG COMPETITION
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

FIERCE COMPETITION
- Add 15x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 12x HOSTILE bias to the HOSTILE approach.



12. Territory Dispute Level
How much do we want their lands? (GetLandDisputeLevel function)

NO DESIRE
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract DECEPTIVE bias from the DECEPTIVE approach.
- Subtract GUARDED bias from the GUARDED approach.
- Subtract 2x WAR bias from the WAR approach.
- Subtract 2x HOSTILE bias from the HOSTILE approach.

WEAK DESIRE
- Subtract 0.5x FRIENDLY bias from the FRIENDLY approach.
- Add 0.5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 0.5x GUARDED bias to the GUARDED approach.
- Add 0.5x WAR bias to the WAR approach.
- Add 0.5x HOSTILE bias to the HOSTILE approach.

STRONG DESIRE
- Subtract FRIENDLY bias from the FRIENDLY approach.
- Add DECEPTIVE bias to the DECEPTIVE approach.
- Add GUARDED bias to the GUARDED approach.
- Add WAR bias to the WAR approach.
- Add HOSTILE bias to the HOSTILE approach.

FIERCE DESIRE
- Subtract 2x FRIENDLY bias from the FRIENDLY approach.
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.


13. Are Either Of Us Close to Winning the Game?
If they're winning, go into panic mode. If we're close to winning, a different approach might be better (unless we're close to domination).
Note that this function doesn't check whether the AI is currently going for the victory condition they're close to; seems they will shoot for other victories if the opportunity strikes.

They're Close to Domination Victory
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

We're Close to Domination Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.

They Control More than One Capital
- Add (2 * # of capitals they control * WAR bias) to the WAR approach.
- Add (2 * # of capitals they control * HOSTILE bias) to the HOSTILE approach.
- Add (2 * # of capitals they control * DECEPTIVE bias) to the DECEPTIVE approach.



They're Close to Science Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.

We're Close to Science Victory
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract 5x WAR bias from the WAR approach.
- Subtract 5x HOSTILE bias from the HOSTILE approach.


They're Close to Diplomatic Victory
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.

We're Close to Diplomatic Victory
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract 10x WAR bias from the WAR approach.
- Subtract 10x HOSTILE bias from the HOSTILE approach.


They're Close to Cultural Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.
- Add 20x DECEPTIVE bias to the DECEPTIVE approach.

We're Close to Cultural Victory
Is this player the civ we have the lowest influence towards?

If yes, and our military strength is greater than theirs:
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.

If yes, and our military strength is equal or less than theirs:
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract 10x WAR bias from the WAR approach.
- Subtract 10x HOSTILE bias from the HOSTILE approach.

If no:
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract 5x WAR bias from the WAR approach.
- Subtract 5x HOSTILE bias from the HOSTILE approach.


14. Disabled Victory Types
Science, Diplomatic and Cultural Victories are all Disabled
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.

Domination Victory is Disabled
- Divide the current WAR approach score by 10.
- Divide the current HOSTILE approach score by 10.


15. We're Cramped (Surrounded/Can't Expand)
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.


16. Other Player's War Weariness
If the other player has more than 0 War Weariness and their empire is very unhappy:
- Add (WAR bias * their War Weariness * 10) to the WAR approach.
- Add (HOSTILE bias * their War Weariness * 10) to the HOSTILE approach.
- Add (FRIENDLY bias * their War Weariness * 5) to the FRIENDLY approach.


17. Nukes
If the other player is human, assume their likelihood of using nukes against us is 100.

Otherwise:
- If nukes have been used by or against the other AI, their likelihood of using nukes against us is 100.
- If the other AI's war projection of a war against us is DESTRUCTION (they would surely lose a war against us), then their likelihood of using nukes against us is 100.
- Otherwise, take the other AI's flavor for using nukes, add 1 to it, and multiply it by itself (since they need to roll twice before using nukes).

We Have Nukes and They Don't
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

They Have Nukes and We Don't
If they are human, or an AI with a likelihood of nuking us greater than 50:
- Add 25x AFRAID bias to the AFRAID approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract 5x WAR bias from the WAR approach.
- Subtract 5x HOSTILE bias from the HOSTILE approach.

We Both Have Nukes
If they are human, or an AI with a likelihood of nuking us greater than 25:
- Add 2x WAR bias to the WAR approach.
- Add 2x GUARDED bias to the GUARDED approach.



18. Current Wars
For each other player (not on this player's team) that we're at war with:

If the war state is CALM or STALEMATE (we're equal):
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Add 0.5x FRIENDLY bias to FRIENDLY approach.

If the war state is DEFENSIVE or NEARLY DEFEATED (we're losing this war):
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 4x HOSTILE bias from HOSTILE approach.

If the war state is OFFENSIVE or NEARLY WON (we're winning this war):
- Add NEUTRAL bias to NEUTRAL approach.
- Add 0.5x DECEPTIVE bias to DECEPTIVE approach.


19. Approaches We've Adopted Towards Other Players
For each other player:

If we're planning war against this other player OR are planning to demand from this other player OR our approach towards them is WAR or HOSTILE:
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Add 2x FRIENDLY bias to FRIENDLY approach, and also see below;

If the person whose approach we're deciding right now is our neighbor (proximity CLOSE), we want them on our good side (since we're being hostile to the other guy):
- Add 3x FRIENDLY bias to FRIENDLY approach.
- Subtract WAR bias from WAR approach.
- Subtract HOSTILE bias from HOSTILE approach.

Is the target of our hostilities also our neighbor? Then it's doubly important to have the neighbor we're examining on our good side:
- Add 3x FRIENDLY bias to FRIENDLY approach.
- Subtract WAR bias from WAR approach.
- Subtract HOSTILE bias from HOSTILE approach.


Approach towards other player is HOSTILE:
- Add NEUTRAL bias to NEUTRAL approach.

Approach towards other player is AFRAID:
- Add FRIENDLY bias to FRIENDLY approach.

Approach towards other player is DECEPTIVE:
- Add FRIENDLY bias to FRIENDLY approach.

Approach towards other player is GUARDED:
- Add NEUTRAL bias to NEUTRAL approach.


Other player has a Defensive Pact with the player we're looking at
If the other player's military strength is equal to or greater than ours:
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.


Other player is at war with the player we're looking at
If the other player is our biggest competitor (GetBiggestCompetitor function), we're happy this guy is at war with them:
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.
- Add 2x FRIENDLY bias to FRIENDLY approach.

If the other player is our most valuable friend (GetMostValuableDoF function), we're mad at this guy for being at war with them:
- Add 2x WAR bias to WAR approach.
- Add 2x HOSTILE bias to HOSTILE approach.

If the other player is not our most valuable friend, but they are our most valuable Defensive Pact (GetMostValuableDefensivePact function), we're mad at this guy for being at war with them:
- Add 2x WAR bias to WAR approach.
- Add 2x HOSTILE bias to HOSTILE approach.


20. Sanity Check: Trade with Them
If we're earning GPT from this player, and ((our GPT - GPT from them) / 2) is less than 0, meaning our economy would go negative from going to war with them, then:

- Add ((our GPT - GPT from them) / 2) to the WAR approach.
- Add ((our GPT - GPT from them) / 2) to the HOSTILE approach.
- Add ((our GPT - GPT from them) / -2) to the DECEPTIVE approach.
- Add ((our GPT - GPT from them) / -2) to the NEUTRAL approach.
- Add ((our GPT - GPT from them) / -2) to the FRIENDLY approach.


21. Vassalage
The other player, or his team, has vassals:
For each vassal:

If our approach towards the vassal is HOSTILE:
- Add 5x HOSTILE bias to HOSTILE approach.

If our approach towards the vassal is WAR:
- Add 5x WAR bias to WAR approach.

If our approach towards the vassal is DECEPTIVE:
- Add 2x DECEPTIVE bias to DECEPTIVE approach.

If our approach towards the vassal is GUARDED:
- Add 2x GUARDED bias to GUARDED approach.


The player is our vassal, or our team's vassal
- Set HOSTILE approach score to 0.
- Set WAR approach score to 0.


We're a vassal of this player, or of their team:
What do we think about how they're treating us?

CONTENT
- Add 5 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add -5 to HOSTILE approach.
- Add -5 to GUARDED approach.

DISAGREE
- Add 0 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add 2 to HOSTILE approach.
- Add 2 to GUARDED approach.

MISTREATED
- Add 0 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add 4 to HOSTILE approach.
- Add 4 to GUARDED approach.

UNHAPPY
- Add -6 to FRIENDLY approach.
- Add -4 to NEUTRAL approach.
- Add 6 to HOSTILE approach.
- Add 8 to GUARDED approach.

ENSLAVED
- Add -6 to FRIENDLY approach.
- Add -8 to NEUTRAL approach.
- Add 10 to HOSTILE approach.
- Add 10 to GUARDED approach.


We're unhappy because they forcefully declared independence from us
- Add 4 to WAR approach score.
- Add -10 to DECEPTIVE approach score.
- Add -10 to FRIENDLY approach score.

We're happy because they gave us our independence peacefully
- Add -4 to WAR approach score.
- Add 2 to DECEPTIVE approach score.
- Add 5 to FRIENDLY approach score.



22. War Projection
How well do we a think a war against this player would go? (GetWarProjection function)
Estimated outcome of the war for us:

DESTRUCTION (we would be destroyed)
- Add 15x AFRAID bias to AFRAID approach.
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.
- Add 5x FRIENDLY bias to FRIENDLY approach.

DEFEAT
- Add 5x AFRAID bias to AFRAID approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.
- Add 2x FRIENDLY bias to FRIENDLY approach.

STALEMATE
- Add AFRAID bias to AFRAID approach.
- Subtract WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.
- Add FRIENDLY bias to FRIENDLY approach.

UNKNOWN
- Subtract AFRAID bias from AFRAID approach.
- Add WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Subtract FRIENDLY bias from FRIENDLY approach.

GOOD
- Subtract 2x AFRAID bias from AFRAID approach.
- Add 2x WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Subtract FRIENDLY bias from FRIENDLY approach.

VERY GOOD
- Subtract 5x AFRAID bias from AFRAID approach.
- Add 5x WAR bias to WAR approach.
- Add 5x HOSTILE bias to HOSTILE approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.


23. Target Value
Our assessment of this player's value as a military target (based on city strength/comparative military power/defensive pacts/vassalage and some other things) (GetPlayerTargetValue function)

IMPOSSIBLE
- Add 5x FRIENDLY bias to FRIENDLY approach.
- Add 5x NEUTRAL bias to NEUTRAL approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.

BAD
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.

AVERAGE
- Add NEUTRAL bias to NEUTRAL approach.
- Add FRIENDLY bias to FRIENDLY approach.
- Subtract HOSTILE bias from HOSTILE approach.
- Subtract WAR bias from WAR approach.

FAVORABLE
- Add HOSTILE bias to HOSTILE approach.
- Subtract NEUTRAL bias from NEUTRAL approach.
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add WAR bias to WAR approach.

SOFT
- Add 2x HOSTILE bias to HOSTILE approach.
- Subtract 2x NEUTRAL bias from NEUTRAL approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.
- Add 2x WAR bias to WAR approach.


24. Military Aggressive Posture
This is how much threat is posed by their military deployment near our borders (GetMilitaryAggressivePosture function).

NONE
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Add 2x NEUTRAL bias to NEUTRAL approach.

LOW
- Add FRIENDLY bias to FRIENDLY approach.
- Add NEUTRAL bias to NEUTRAL approach.
- Add GUARDED bias to GUARDED approach.

MEDIUM
- Add GUARDED bias to GUARDED approach.
- Add DECEPTIVE bias to DECEPTIVE approach.
- Subtract NEUTRAL bias from NEUTRAL approach.
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add WAR bias to WAR approach.

HIGH
- Add 2x GUARDED bias to GUARDED approach.
- Add 2x WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Add 2x DECEPTIVE bias to DECEPTIVE approach.
- Subtract 2x NEUTRAL bias from NEUTRAL approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.

INCREDIBLE
- Add 5x GUARDED bias to GUARDED approach.
- Add 2x HOSTILE bias to HOSTILE approach.
- Add 5x WAR bias to WAR approach.
- Add 5x DECEPTIVE bias to DECEPTIVE approach.
- Subtract 5x NEUTRAL bias from NEUTRAL approach.
- Subtract 5x FRIENDLY bias from FRIENDLY approach.


25. Reckless Expansion
If this player is a reckless expander ("They believe we are building new cities too aggressively!")
- Add 2x WAR bias to WAR approach.
- Add 2x DECEPTIVE bias to DECEPTIVE approach.
- Add 2x HOSTILE bias to HOSTILE approach.


26. Other Player's War Status
If the player is already at war with another major civilization, and we've met the other player, we might want to gang up on the guy we're looking at:

If WarProjection >= GOOD, VictoryDisputeLevel >= STRONG, VictoryBlockLevel >= STRONG, TargetValue >= AVERAGE:

For each other player we've met that they're at war with:
- Add these integer values together to get a bonus value: victory block level + victory dispute level + war projection level + target value level
- Add 0.5x of this bonus value to the WAR approach.
- Add 0.5x of this bonus value to the HOSTILE approach.


27. Other Player Vassal Penalty
If the other player is not our master, for each vassal the other player has, increase the WAR and GUARDED approach scores by 10%.

i.e. 1 vassal = 110%, 2 vassals = 120%, etc.


28. Peace Treaty Consideration
If we made a peace treaty with this player or their team less than 25 turns ago:
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


29. Only Two Players Left
If there are only two major civilizations alive:
- Set FRIENDLY approach score to 5x FRIENDLY bias.

If going for Domination Victory:
- Set FRIENDLY approach score to 0.
- Add 1000 to WAR approach score.


30. Locked into Co-Op War Against This Player
- Add 100 to WAR approach score.


31. Defensive Pact
We have a Defensive Pact with this player or their team:
- Add 15x FRIENDLY bias to FRIENDLY approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.
- Subtract 5x GUARDED bias from GUARDED approach.
- Subtract 5x DECEPTIVE bias from DECEPTIVE approach.


32. Co-Op War Promise
We made a co-op war promise to this player:
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


33. Agreed to Remove Troops from their Borders
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


34. Can We Declare War on this Player?
If they're a vassal:
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.

We're not able to declare war on them:
- Set WAR approach score to 0.
- Set HOSTILE approach score to 0.

We are able to declare war on them:
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add 5x WAR bias to WAR approach.
- Add 5x HOSTILE bias to HOSTILE approach.


35. Same Team
If we're on the same team, set FRIENDLY approach score to 100 and all other approach scores to 0.


36. Distance
(Less likely to want to attack targets that are far away, more likely to want to attack targets that are closer.)

If we're not currently at war with them and our WAR or HOSTILE approach score is > 0, do the following function, otherwise skip:

If we can't reach the target by land, by sea or with a naval invasion, abort!
- Subtract 15x WAR bias from WAR approach score.
- Subtract 15x HOSTILE bias from HOSTILE approach score.

Before they're able to embark over oceans, the AI strongly prefers to start wars with neighbors and close targets, and prefers land-based attacks.

After they're able to embark over oceans, AIs that are going for world conquest treat far and distant targets as if they were neighbors and close targets, respectively.

(Polynesia can embark over oceans from the start of the game)


PLAYER PROXIMITY CHECK (We can't cross oceans yet)
Target is a NEIGHBOR who we can reach by land:
- Increase WAR approach score by 15%.
- Increase HOSTILE approach score by 15%.

Target is a NEIGHBOR who we can't reach by land
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.


Target is CLOSE and we can reach them by land:
- No change.

Target is CLOSE and we can't reach them by land:
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.


Target is FAR:
- Subtract 3x WAR bias from WAR approach.
- Subtract 3x HOSTILE bias from HOSTILE approach.

Target is DISTANT:
- Subtract 4x WAR bias from WAR approach.
- Subtract 4x HOSTILE bias from HOSTILE approach.



PLAYER PROXIMITY CHECK (We can cross oceans)
Target is a NEIGHBOR:
- Increase WAR approach score by 15%.
- Increase HOSTILE approach score by 15%.

Target is CLOSE:
- No change.


Target is FAR and we're not going for Domination Victory:
- Decrease WAR approach score by 40%.
- Decrease HOSTILE approach score by 40%.

Target is FAR and we're going for Domination Victory:
- Increase WAR approach score by 15%.
- Increase HOSTILE approach score by 15%.


Target is DISTANT and we're not going for Domination Victory:
- Decrease WAR approach score by 50%.
- Decrease HOSTILE approach score by 50%.

Target is DISTANT and we're going for Domination Victory:
- No change.


37. Has Unique Unit
If this civilization has a unique unit:

We have the unique unit unlocked, and at least one of them active
- Multiply WAR approach score by 10.
- Multiply HOSTILE approach score by 10.

We have the unique unit tech unlocked, but none of them constructed
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.
- Multiply DECEPTIVE approach score by 2.

We don't have the unique unit tech, but will have it soon
- Divide WAR approach score by 5.
- Divide HOSTILE approach score by 5.
- Multiply DECEPTIVE approach score by 2.

We don't have it, and we won't have it soon
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.


38. Most Important Player Modifiers
If this player is not our greatest competitor (GetBiggestCompetitor function):
- Divide WAR approach score by 2.
- Divide HOSTILE approach score by 2.

If they are our greatest competitor:
- Multiply WAR approach score by 2.
- Multiply HOSTILE approach score by 2.

If they are our most valuable friend (GetMostValuableDoF function):
- Divide WAR approach score by 2.
- Divide HOSTILE approach score by 2.
- Multiply FRIENDLY approach score by 2.

If they are our most valuable Defensive Pact (GetMostValuableDefensivePact function):
- Divide WAR approach score by 2.
- Divide HOSTILE approach score by 2.
- Multiply FRIENDLY approach score by 2.


39. Opinion Modifier
The opinion score is obtained from the positive and negative modifiers shown in the diplomacy screen when mousing over their approach, messages like:
- "You have no contested borders.", or
- "Territorial disputes strain your relationship."

These modifiers have a numerical value attached to them which can be seen with the Transparent Diplomacy advanced setting enabled.

The sum total of the positive and negative modifier values is the Opinion score, with one change: in the code, positive modifiers reduce your opinion value (so a negative opinion score is good), and negative modifiers increase your opinion value (so a positive opinion score is bad).

The following values affect how opinion applies in approach calculation:
iWarMod - the WAR bias * the leader's Boldness * 2
iHostileMod - the HOSTILE bias * the leader's Denounce Willingness * 2
iDeceptiveMod - the DECEPTIVE bias * the leader's Meanness * 2
iGuardedMod - the GUARDED bias * (10 - the leader's Forgiveness) * 2
iFriendlyMod - the FRIENDLY bias * the leader's Loyalty * 2
iNeutralMod - the NEUTRAL bias * the leader's DiploBalance score * 2

The various flavors like Boldness, Denounce Willingness and Loyalty have a defined XML value which is randomized game to game to make each game less predictable.

The way these flavors work is as follows (example):
- If Boldness is high, then having a negative opinion score will greatly increase the WAR approach, but having a positive opinion score will greatly decrease the WAR approach.
- If Boldness is low, then having a negative opinion score will slightly increase the WAR approach, but having a positive opinion score will slightly decrease the WAR approach.

A higher opinion always means less likelihood of hostile behavior, and more likelihood of friendly behavior, and the reverse for a lower opinion. This is a key modifier.

Now for the actual opinion calculation:
If Opinion > 0 (bad opinion)
Increase WAR approach score by (iWarMod + Opinion)%.

Increase HOSTILE approach score by (iHostileMod + Opinion)%.

Increase DECEPTIVE approach score by (iDeceptiveMod + Opinion)%.

Increase GUARDED approach score by (iGuardedMod + Opinion)%.

Multiply FRIENDLY approach score by 100.
Divide FRIENDLY approach score by (100 + iFriendlyMod + Opinion) or 100, whichever is greater.

If the opinion score for this player is worse than the "Competitor" threshold:
Multiply NEUTRAL approach score by 100.
Divide NEUTRAL approach score by (100 + iNeutralMod + Opinion) or 100, whichever is greater.


If Opinion < 0 (good opinion)
Multiply Opinion by -1.

Increase FRIENDLY approach score by (iFriendlyMod + Opinion)%.

Multiply WAR approach score by 100.
Divide WAR approach score by (100 + iWarMod + Opinion) or 100, whichever is greater.

Multiply HOSTILE approach score by 100.
Divide HOSTILE approach score by (100 + iHostileMod + Opinion) or 100, whichever is greater.

Multiply DECEPTIVE approach score by 100.
Divide DECEPTIVE approach score by (100 + iDeceptiveMod + Opinion) or 100, whichever is greater.

Multiply GUARDED approach score by 100.
Divide GUARDED approach score by (100 + iGuardedMod + Opinion) or 100, whichever is greater.

If the opinion score for this player is better than the "Favorable" threshold:
Multiply NEUTRAL approach score by 100.
Divide NEUTRAL approach score by (100 + iNeutralMod + Opinion) or 100, whichever is greater.


If the opinion score for this player is between the "Competitor" and "Favorable" thresholds:
Multiply Opinion by -1.

Increase NEUTRAL approach score by (iNeutralMod + Opinion)%.


40. Make Changes in Approach Gradual
For each of the approaches:

A. Calculate the "average" value of this turn's score and the last turn's score using this formula: (0.5f + (Approach Score * 0.10f) + (Approach Score Last Turn * (1 - 0.10f)))
B. Set the approach score to this "average" value.


41. Pick a War Face If Going to War
If the highest approach score after all these calculations is WAR (therefore the AI is planning a war), but the AI is not currently at war with you or declaring war right this second, AI will pick a "War Face", which determines how it will act towards you until either WAR isn't the highest approach anymore or war is declared.

If the AI had a War Face last turn, it will use that one. Otherwise, it will figure out the next-highest APPROACH score (after WAR), and based on the result, pick a war face.

If the next-highest approach score is:

HOSTILE
- AI will act HOSTILE to you until it's ready for war.

DECEPTIVE
- AI will act NEUTRAL to you until it's ready for war.

AFRAID
- AI will act HOSTILE to you until it's ready for war.

FRIENDLY
- AI will act FRIENDLY to you until it's ready for war.

OTHERWISE
- AI will act NEUTRAL to you until it's ready for war.


42. Decide What Approach to Show to the Player
The AI picks its highest approach and uses that towards you. If all approach scores are 0, it will use the NEUTRAL approach.

If the AI is currently at war with you, the WAR! approach is shown.

If the AI is planning war with you, they will use their War Face (see #41 above).

If the AI's approach towards you is DECEPTIVE, it will show up as FRIENDLY.

Otherwise, the approach shown to you is the AI's approach towards you.

EDIT: Updated this guide on 8-8 with the new changes to diplomacy AI. (section 38)
 
Last edited:
Here's my (incomplete and probably partially incorrect understanding) of the way the function works. I'd appreciate clarifications from people who know more, if they have any comments. :)
[/CODE]

Pretty much spot on, just want to note:

'And then adds and removes points from each approach many times, using their bias/"personality weight" in some way, based on a number of factors. The approach with the highest number at the end of this process is the one selected.'

As you noted, the function looks at last turn's values and then makes it a smooth curve, so the change from turn to turn is limited.

G
 
Pretty much spot on, just want to note:

'And then adds and removes points from each approach many times, using their bias/"personality weight" in some way, based on a number of factors. The approach with the highest number at the end of this process is the one selected.'

As you noted, the function looks at last turn's values and then makes it a smooth curve, so the change from turn to turn is limited.

G

Good to know I'm on the right track! I'll work on figuring out the values I don't understand next. :)
 
Here's my (incomplete and probably partially incorrect understanding) of the way the function works. I'd appreciate clarifications from people who know more, if they have any comments. :)

But anyway, it should help people understand how the AI chooses their approach.

Every AI has a leader bias number for every different approach (the approaches being WAR, HOSTILE, AFRAID, GUARDED, DECEPTIVE, NEUTRAL, FRIENDLY).

These bias/flavor numbers (or "personality weight") are used many times in the calculations, and probably are randomized a bit from game to game.

Every turn, the AI starts with:
WAR: 0
HOSTILE: 0
AFRAID: 0
GUARDED: 0
NEUTRAL: 0
DECEPTIVE: 0
FRIENDLY: 0

And then adds and removes points from each approach many times, using their bias/"personality weight" in some way, based on a number of factors. The approach with the highest number at the end of this process is the one selected.

The WAR approach just means this AI values war with the player most highly and they will plan a war against you, it does not necessarily mean war will be declared that very turn.

The DECEPTIVE approach is when the AI appears as FRIENDLY but is secretly plotting against you.

The process is as follows:
Code:
1. Current Approach Bias
What approach did we have towards this player last turn? This in some way modifies the final calculation. If we didn't have an approach towards this player last turn, assume it's NEUTRAL.


2. Default Weights
Add our NEUTRAL bias to the NEUTRAL approach.

Check if we were planning a war against them last turn. If yes, add 5x our WAR bias to the WAR approach.

Check if we were planning to demand from them last turn. If yes, add 5x our HOSTILE bias to the HOSTILE approach.

An additional check is made to see if we wanted a war last turn - effect unclear.

Domination Victory bias: If we're not at war yet, or we are at war and it's a stalemate or better (we're not playing defensively), and we're going for domination victory, add 10x WAR bias to the WAR approach.


3. City-State Quests
If a city-state gave us a quest to declare war on them, capture one of their cities, or liberate one of their cities, add 4x WAR bias to the WAR approach.


4. Declaration of Friendship
We have a Declaration of Friendship with this player:
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract 10x WAR bias from the WAR approach.
- Subtract 10x HOSTILE bias from the HOSTILE approach.
- Subtract 10x GUARDED bias from the GUARDED approach.
- Subtract 10x DECEPTIVE bias from the DECEPTIVE approach.
- Subtract 10x NEUTRAL bias from the NEUTRAL approach.


5. Denunciations
We've currently denounced this player:
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Set approach score for FRIENDLY to 0.

We were friends and they denounced us (at any time in the past):
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Set approach score for FRIENDLY to 0.


This player has currently denounced us:
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Set approach score for FRIENDLY to 0.


6. Co-Op War Request
They refused our request to do a co-op war at least once:

- Subtract 2x the # of times they refused the request from the FRIENDLY approach.
- Add 2x the # of times they refused the request to the DECEPTIVE approach.


7. Military Threat
What is this player's military threat level? (GetMilitaryThreat function)

CRITICAL:
- Add 8x WAR bias to the WAR approach.
- Add 5x AFRAID bias to the AFRAID approach.
- Add GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract 4x HOSTILE bias from the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

SEVERE:
- Add 3x AFRAID bias to the AFRAID approach.
- Add 5x WAR bias to the WAR approach.
- Add 4x GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract 3x HOSTILE bias from the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MAJOR:
- Add 3x WAR bias to the WAR approach.
- Add 3x DECEPTIVE bias to the DECEPTIVE approach.
- Add 3x HOSTILE bias to the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.

MINOR:
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Add DECEPTIVE bias to the DECEPTIVE approach.

NONE:
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract GUARDED bias from the GUARDED approach.
- Subtract HOSTILE bias from the HOSTILE approach.





8. Warmonger Threat
What is this player's warmonger threat level? (GetWarmongerThreat function)

CRITICAL:
- Add 15x WAR bias to the WAR approach.
- Add 7x AFRAID bias to the AFRAID approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Add 8x HOSTILE bias to the HOSTILE approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

SEVERE:
- Add 5x AFRAID bias to the AFRAID approach.
- Add 10x WAR bias to the WAR approach.
- Add 4x HOSTILE bias to the HOSTILE approach.
- Add GUARDED bias to the GUARDED approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MAJOR:
- Add 4x WAR bias to the WAR approach.
- Add 3x HOSTILE bias to the HOSTILE approach.
- Add GUARDED bias to the GUARDED approach.
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Subtract NEUTRAL bias from the NEUTRAL approach.
- Subtract FRIENDLY bias from the FRIENDLY approach.

MINOR:
- Add 2x NEUTRAL bias to the NEUTRAL approach.
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract 2x HOSTILE bias from the HOSTILE approach.

NONE:
- Add 3x NEUTRAL bias to the NEUTRAL approach.
- Add 3x FRIENDLY bias to the FRIENDLY approach.
- Subtract 3x HOSTILE bias from the HOSTILE approach.


9. Victory Block Level
How much do we want to stop this player from winning? (GetVictoryBlockLevel function; the farther you are in the lead, the more they hate you)

NO DESIRE
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK DESIRE
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG DESIRE
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

FIERCE DESIRE
- Add 15x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.




10. Wonder Competitiveness Level
How much are we competing with this player for World Wonders? (GetWonderDisputeLevel function)

NO COMPETITION
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK COMPETITION
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG COMPETITION
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add GUARDED bias to the GUARDED approach.
- Add WAR bias to the WAR approach.
- Add HOSTILE bias to the HOSTILE approach.

FIERCE COMPETITION
- Add 5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.



11. Victory Competitiveness Level
What is their level of competitiveness with us for the same victory condition? (GetVictoryDisputeLevel function)

NO COMPETITION
- Add 2x FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

WEAK COMPETITION
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract WAR bias from the WAR approach.
- Subtract HOSTILE bias from the HOSTILE approach.

STRONG COMPETITION
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

FIERCE COMPETITION
- Add 15x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 12x HOSTILE bias to the HOSTILE approach.



12. Territory Dispute Level
How much do we want their lands? (GetLandDisputeLevel function)

NO DESIRE
- Add FRIENDLY bias to the FRIENDLY approach.
- Subtract DECEPTIVE bias from the DECEPTIVE approach.
- Subtract GUARDED bias from the GUARDED approach.
- Subtract 2x WAR bias from the WAR approach.
- Subtract 2x HOSTILE bias from the HOSTILE approach.

WEAK DESIRE
- Subtract 0.5x FRIENDLY bias from the FRIENDLY approach.
- Add 0.5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 0.5x GUARDED bias to the GUARDED approach.
- Add 0.5x WAR bias to the WAR approach.
- Add 0.5x HOSTILE bias to the HOSTILE approach.

STRONG DESIRE
- Subtract FRIENDLY bias from the FRIENDLY approach.
- Add DECEPTIVE bias to the DECEPTIVE approach.
- Add GUARDED bias to the GUARDED approach.
- Add WAR bias to the WAR approach.
- Add HOSTILE bias to the HOSTILE approach.

FIERCE DESIRE
- Subtract 2x FRIENDLY bias from the FRIENDLY approach.
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.


13. Are Either Of Us Close to Winning the Game?
If they're winning, go into panic mode. If we're close to winning, a different approach might be better (unless we're close to domination).
Note that this function doesn't check whether the AI is currently going for the victory condition they're close to; seems they will shoot for other victories if the opportunity strikes.

They're Close to Domination Victory
- Add 2x DECEPTIVE bias to the DECEPTIVE approach.
- Add 2x GUARDED bias to the GUARDED approach.
- Add 10x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

We're Close to Domination Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.

They Control More than One Capital
- Add (2 * # of capitals they control * WAR bias) to the WAR approach.
- Add (2 * # of capitals they control * HOSTILE bias) to the HOSTILE approach.
- Add (2 * # of capitals they control * DECEPTIVE bias) to the DECEPTIVE approach.



They're Close to Science Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.

We're Close to Science Victory
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract -5x WAR bias from the WAR approach.
- Subtract -5x HOSTILE bias from the HOSTILE approach. (this is a subtraction, I wonder why they're negative)


They're Close to Diplomatic Victory
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.
- Add 10x DECEPTIVE bias to the DECEPTIVE approach.

We're Close to Diplomatic Victory
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract -10x WAR bias from the WAR approach.
- Subtract -10x HOSTILE bias from the HOSTILE approach.


They're Close to Cultural Victory
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.
- Add 20x DECEPTIVE bias to the DECEPTIVE approach.

We're Close to Cultural Victory
Is this player the civ we have the lowest influence towards?

If yes, and our military strength is greater than theirs:
- Add 10x WAR bias to the WAR approach.
- Add 10x HOSTILE bias to the HOSTILE approach.

If yes, and our military strength is equal or less than theirs:
- Add 10x FRIENDLY bias to the FRIENDLY approach.
- Subtract -10x WAR bias from the WAR approach.
- Subtract -10x HOSTILE bias from the HOSTILE approach.

If no:
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract -5x WAR bias from the WAR approach.
- Subtract -5x HOSTILE bias from the HOSTILE approach.


14. Disabled Victory Types
Science, Diplomatic and Cultural Victories are all Disabled
- Add 20x WAR bias to the WAR approach.
- Add 20x HOSTILE bias to the HOSTILE approach.

Domination Victory is Disabled
- Divide the current WAR approach value by 10.
- Divide the current HOSTILE approach value by 10.


15. We're Cramped (Surrounded/Can't Expand)
- Add 2x WAR bias to the WAR approach.
- Add 2x HOSTILE bias to the HOSTILE approach.


16. Other Player's War Weariness
If the other player has more than 0 War Weariness and their empire is very unhappy:
- Add (WAR bias * their War Weariness * 10) to the WAR approach.
- Add (HOSTILE bias * their War Weariness * 10) to the HOSTILE approach.
- Add (FRIENDLY bias * their War Weariness * 5) to the FRIENDLY approach.


17. Nukes
If the other player is human, assume their likelihood of using nukes against us is 100.

Otherwise:
- If nukes have been used by or against the other AI, their likelihood of using nukes against us is 100.
- If the other AI's war projection of a war against us is DESTRUCTION (they would surely lose a war against us), then their likelihood of using nukes against us is 100.
- Otherwise, take the other AI's flavor for using nukes, add 1 to it, and multiply it by itself (since they need to roll twice before using nukes).

We Have Nukes and They Don't
- Add 5x WAR bias to the WAR approach.
- Add 5x HOSTILE bias to the HOSTILE approach.

They Have Nukes and We Don't
If they are human, or an AI with a likelihood of nuking us greater than 50:

- Add 25x AFRAID bias to the AFRAID approach.
- Add 5x GUARDED bias to the GUARDED approach.
- Add 5x DECEPTIVE bias to the DECEPTIVE approach.
- Add 5x FRIENDLY bias to the FRIENDLY approach.
- Subtract 5x WAR bias from the WAR approach.
- Subtract 5x HOSTILE bias from the HOSTILE approach.

We Both Have Nukes
If they are human, or an AI with a likelihood of nuking us greater than 25:

- Add 2x WAR bias to the WAR approach.
- Add 2x GUARDED bias to the GUARDED approach.



18. Current Wars
For each other player (not on this player's team) that we're at war with:

If the war state is CALM or STALEMATE (we're equal):
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Add 0.5x FRIENDLY bias to FRIENDLY approach.

If the war state is DEFENSIVE or NEARLY DEFEATED (we're losing this war):
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 4x HOSTILE bias from HOSTILE approach.

If the war state is OFFENSIVE or NEARLY WON (we're winning this war):
- Add NEUTRAL bias to NEUTRAL approach.
- Add 0.5x DECEPTIVE bias to DECEPTIVE approach.


19. Approaches We've Adopted Towards Other Players
For each other player:

If we're planning war against this other player OR are planning to demand from this other player OR our approach towards them is WAR or HOSTILE:
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Add 2x FRIENDLY bias to FRIENDLY approach, and also see below;

If the person whose approach we're deciding right now is our neighbor (proximity CLOSE), we want them on our good side (since we're being hostile to the other guy):
- Add 3x FRIENDLY bias to FRIENDLY approach.
- Subtract WAR bias from WAR approach.
- Subtract HOSTILE bias from HOSTILE approach.

Is the target of our hostilities also our neighbor? Then it's doubly important to have the neighbor we're examining on our good side:
- Add 3x FRIENDLY bias to FRIENDLY approach.
- Subtract WAR bias from WAR approach.
- Subtract HOSTILE bias from HOSTILE approach.


Approach towards other player is HOSTILE:
- Add NEUTRAL bias to NEUTRAL approach.

Approach towards other player is AFRAID:
- Add FRIENDLY bias to FRIENDLY approach.

Approach towards other player is DECEPTIVE:
- Add FRIENDLY bias to FRIENDLY approach.

Approach towards other player is GUARDED:
- Add NEUTRAL bias to NEUTRAL approach.


Other player has a Defensive Pact with the player we're looking at
If the other player's military strength is equal to or greater than ours:
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.


Other player is at war with the player we're looking at
If the other player is our biggest competitor (GetBiggestCompetitor function), we're happy this guy is at war with them:
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.
- Add 2x FRIENDLY bias to FRIENDLY approach.

If the other player is our most valuable friend (GetMostValuableDoF function), we're mad at this guy for being at war with them:
- Add 2x WAR bias to WAR approach.
- Add 2x HOSTILE bias to HOSTILE approach.

If the other player is not our most valuable friend, but they are our most valuable Defensive Pact (GetMostValuableDefensivePact function), we're mad at this guy for being at war with them:
- Add 2x WAR bias to WAR approach.
- Add 2x HOSTILE bias to HOSTILE approach.


20. Sanity Check: Trade with Them
If we're earning GPT from this player, and ((our GPT - GPT from them) / 2) is less than 0, meaning our economy would go negative from going to war with them, then:

- Add ((our GPT - GPT from them) / 2) to the WAR approach.
- Add ((our GPT - GPT from them) / 2) to the HOSTILE approach.
- Add ((our GPT - GPT from them) / -2) to the DECEPTIVE approach.
- Add ((our GPT - GPT from them) / -2) to the NEUTRAL approach.
- Add ((our GPT - GPT from them) / -2) to the FRIENDLY approach.


21. Vassalage
The other player, or his team, has vassals:
For each vassal:

If our approach towards the vassal is HOSTILE:
- Add 5x HOSTILE bias to HOSTILE approach.

If our approach towards the vassal is WAR:
- Add 5x WAR bias to WAR approach.

If our approach towards the vassal is DECEPTIVE:
- Add 2x DECEPTIVE bias to DECEPTIVE approach.

If our approach towards the vassal is GUARDED:
- Add 2x GUARDED bias to GUARDED approach.


The player is our vassal, or our team's vassal
- Set HOSTILE approach score to 0.
- Set WAR approach score to 0.


We're a vassal of this player, or of their team:
What do we think about how they're treating us?

CONTENT
- Add 5 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add -5 to HOSTILE approach.
- Add -5 to GUARDED approach.

DISAGREE
- Add 0 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add 2 to HOSTILE approach.
- Add 2 to GUARDED approach.

MISTREATED
- Add 0 to FRIENDLY approach.
- Add 2 to NEUTRAL approach.
- Add 4 to HOSTILE approach.
- Add 4 to GUARDED approach.

UNHAPPY
- Add -6 to FRIENDLY approach.
- Add -4 to NEUTRAL approach.
- Add 6 to HOSTILE approach.
- Add 8 to GUARDED approach.

ENSLAVED
- Add -6 to FRIENDLY approach.
- Add -8 to NEUTRAL approach.
- Add 10 to HOSTILE approach.
- Add 10 to GUARDED approach.


We're unhappy because they forcefully declared independence from us
- Modifies WAR, DECEPTIVE and FRIENDLY approaches in an unclear way.

We're happy because they gave us our independence peacefully
- Modifies WAR, DECEPTIVE, and FRIENDLY approaches in an unclear way.



22. War Projection
How well do we a think a war against this player would go? (GetWarProjection function)
Estimated outcome of the war for us:

DESTRUCTION (we would be destroyed)
- Add 15x AFRAID bias to AFRAID approach.
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.
- Add 5x FRIENDLY bias to FRIENDLY approach.

DEFEAT
- Add 5x AFRAID bias to AFRAID approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.
- Add 2x FRIENDLY bias to FRIENDLY approach.

STALEMATE
- Add AFRAID bias to AFRAID approach.
- Subtract WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.
- Add FRIENDLY bias to FRIENDLY approach.

UNKNOWN
- Subtract AFRAID bias from AFRAID approach.
- Add WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Subtract FRIENDLY bias from FRIENDLY approach.

GOOD
- Subtract 2x AFRAID bias from AFRAID approach.
- Add 2x WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Subtract FRIENDLY bias from FRIENDLY approach.

VERY GOOD
- Subtract 5x AFRAID bias from AFRAID approach.
- Add 5x WAR bias to WAR approach.
- Add 5x HOSTILE bias to HOSTILE approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.


23. Target Value
Not sure how this is calculated (uses GetPlayerTargetValue function).

IMPOSSIBLE
- Add 5x FRIENDLY bias to FRIENDLY approach.
- Add 5x NEUTRAL bias to NEUTRAL approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.

BAD
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Add 2x NEUTRAL bias to NEUTRAL approach.
- Subtract 2x WAR bias from WAR approach.
- Subtract 2x HOSTILE bias from HOSTILE approach.

AVERAGE
- Add NEUTRAL bias to NEUTRAL approach.
- Add FRIENDLY bias to FRIENDLY approach.
- Subtract HOSTILE bias from HOSTILE approach.
- Subtract WAR bias from WAR approach.

FAVORABLE
- Add HOSTILE bias to HOSTILE approach.
- Subtract NEUTRAL bias from NEUTRAL approach.
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add WAR bias to WAR approach.

SOFT
- Add 2x HOSTILE bias to HOSTILE approach.
- Subtract 2x NEUTRAL bias from NEUTRAL approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.
- Add 2x WAR bias to WAR approach.


24. Military Aggressive Posture
This is how much threat is posed by their military deployment near our borders (GetMilitaryAggressivePosture function).

NONE
- Add 2x FRIENDLY bias to FRIENDLY approach.
- Add 2x NEUTRAL bias to NEUTRAL approach.

LOW
- Add FRIENDLY bias to FRIENDLY approach.
- Add NEUTRAL bias to NEUTRAL approach.
- Add GUARDED bias to NEUTRAL approach. (is this a bug? looks like a typo)

MEDIUM
- Add GUARDED bias to GUARDED approach.
- Add DECEPTIVE bias to DECEPTIVE approach.
- Subtract NEUTRAL bias from NEUTRAL approach.
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add WAR bias to WAR approach.

HIGH
- Add 2x GUARDED bias to GUARDED approach.
- Add 2x WAR bias to WAR approach.
- Add HOSTILE bias to HOSTILE approach.
- Add 2x DECEPTIVE bias to DECEPTIVE approach.
- Subtract 2x NEUTRAL bias from NEUTRAL approach.
- Subtract 2x FRIENDLY bias from FRIENDLY approach.

INCREDIBLE
- Add 5x GUARDED bias to GUARDED approach.
- Add 2x HOSTILE bias to HOSTILE approach.
- Add 5x WAR bias to WAR approach.
- Add 5x DECEPTIVE bias to DECEPTIVE approach.
- Subtract 5x NEUTRAL bias from NEUTRAL approach.
- Subtract 5x FRIENDLY bias from FRIENDLY approach.


25. Reckless Expansion
If this player is a reckless expander ("They believe we are building new cities too aggressively!")
- Add 2x WAR bias to WAR approach.
- Add 2x DECEPTIVE bias to DECEPTIVE approach.
- Add 2x HOSTILE bias to HOSTILE approach.


26. Other Player's War Status
If the player is already at war with another major civilization, and we've met this other player:

For each other player we've met that they're at war with, check if we think ganging up on them would be a good idea based on our own situation:

If WarProjection >= GOOD, VictoryDisputeLevel >= STRONG, VictoryBlockLevel >= STRONG, TargetValue >= AVERAGE
- Add these integer values together to get a bonus value: victory block level + victory dispute level + war projection level + target value level
- Add 0.5x of this bonus value to the WAR approach.
- Add 0.5x of this bonus value to the HOSTILE approach.


27. Other Player Vassal Penalty
If the other player is not our master, for each vassal the other player has, add 10% to the WAR and GUARDED approaches.

i.e. 1 vassal = 110% of normal GUARDED and WAR scores, 2 vassals = 120%, etc.


28. Peace Treaty Consideration
If we made a peace treaty with this player or their team less than 25 turns ago:
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


29. Only Two Players Left
If there are only two major civilizations alive:
- Add 5x FRIENDLY bias to FRIENDLY approach.

If going for Domination Victory:
- Set FRIENDLY approach score to 0.
- Add 1000 to WAR approach score.


30. Locked into Co-Op War Against This Player
- Add 100 to WAR approach score.


31. Defensive Pact
We have a Defensive Pact with this player or their team:
- Add 15x FRIENDLY bias to FRIENDLY approach.
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.
- Subtract 5x GUARDED bias from GUARDED approach.
- Subtract 5x DECEPTIVE bias from DECEPTIVE approach.


32. Made Military Promise
Unsure what this means, but if a military promise was made with this player:
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


33. Agreed to Remove Troops from their Borders
- Subtract 10x WAR bias from WAR approach.
- Subtract 10x HOSTILE bias from HOSTILE approach.


34. Can We Declare War on this Player?
If they're a vassal:
- Subtract 5x WAR bias from WAR approach.
- Subtract 5x HOSTILE bias from HOSTILE approach.

We're not able to declare war on them:
- Set WAR approach score to 0.
- Set HOSTILE approach score to 0.

We are able to declare war on them:
- Subtract FRIENDLY bias from FRIENDLY approach.
- Add 5x WAR bias to WAR approach.
- Add 5x HOSTILE bias to HOSTILE approach.


35. Same Team
If we're on the same team, set FRIENDLY approach score to 100 and all other approach scores to 0.


36. Distance
Less likely to want to attack targets that are far away.

We're not currently at war with them and our WAR or HOSTILE approach score is > 0
If our troops are unable to find a path to the target:
- Subtract 15x WAR bias from WAR approach.
- Subtract 15x HOSTILE bias from HOSTILE approach.

If we're not able to cross ocean tiles yet, only consider attacks on neighbors.

Not sure how this works, but the WAR and HOSTILE approaches are now adjusted based on proximity to the target (farther = less enticing).

If going for Domination Victory, the reduction in likelihood to attack is lessened.


37. Has Unique Unit
If this civilization has a unique unit:

We have the unique unit unlocked, and at least one of them active
- Multiply WAR approach score by 10.
- Multiply HOSTILE approach score by 10.

We have the unique unit tech unlocked, but none of them constructed
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.
- Multiply DECEPTIVE approach score by 2.

We don't have the unique unit tech, but will have it soon
- Divide WAR approach score by 5.
- Divide HOSTILE approach score by 5.
- Multiply DECEPTIVE approach score by 2.

We don't have it, and we won't have it soon
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.


38. Most Important Player Modifiers
If this player is not our greatest competitor (GetBiggestCompetitor function):
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.

If they are our greatest competitor:
- Multiply WAR approach score by 25.
- Multiply HOSTILE approach score by 25.

If they are our most valuable friend (GetMostValuableDoF function):
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.
- Multiply FRIENDLY approach score by 25.

If they are our most valuable Defensive Pact (GetMostValuableDefensivePact function):
- Divide WAR approach score by 10.
- Divide HOSTILE approach score by 10.
- Multiply FRIENDLY approach score by 25.


39. Opinion Modifier
The opinion score is obtained from the positive and negative modifiers shown in the diplomacy screen when mousing over their approach, messages like:
- "You have no contested borders.", or
- "Territorial disputes strain your relationship."

These modifiers have a numerical value attached to them which can be seen with the Transparent Diplomacy advanced setting enabled.

The sum total of the positive and negative modifier values is the Opinion score, with one change: in the code, positive modifiers reduce your opinion value (so a negative opinion score is good), and negative modifiers increase your opinion value (so a positive opinion score is bad).

The following values affect how opinion applies in approach calculation:
iWarMod - the WAR bias * the leader's Boldness * 2
iHostileMod - the HOSTILE bias * the leader's Denounce Willingness * 2
iDeceptiveMod - the DECEPTIVE bias * the leader's Meanness * 2
iGuardedMod - the GUARDED bias * (10 - the leader's Forgiveness) * 2
iFriendlyMod - the FRIENDLY bias * the leader's Loyalty * 2
iNeutralMod - the NEUTRAL bias * the leader's DiploBalance score * 2

The calculation is as follows:
If Opinion > 0 (bad opinion)
Multiply WAR approach score by (100 + iWarMod + Opinion).
Divide WAR approach score by 100.

Multiply HOSTILE approach score by (100 + iHostileMod + Opinion).
Divide HOSTILE approach score by 100.

Multiply DECEPTIVE approach score by (100 + iDeceptiveMod + Opinion).
Divide DECEPTIVE approach score by 100.

Multiply GUARDED approach score by (100 + iGuardedMod + Opinion).
Divide GUARDED approach score by 100.

Multiply FRIENDLY approach score by 100.
Divide FRIENDLY approach score by (100 + iFriendlyMod + Opinion) or 100, whichever is greater.

If the opinion score for this player is worse than the "Competitor" threshold:
Multiply NEUTRAL approach score by 100.
Divide NEUTRAL approach score by (100 + iNeutralMod + Opinion) or 100, whichever is greater.


If Opinion < 0 (good opinion)
Multiply Opinion by -1.

Multiply FRIENDLY approach score by (100 + iFriendlyMod + Opinion).
Divide FRIENDLY approach score by 100.

Multiply WAR approach score by 100.
Divide WAR approach score by (100 + iWarMod + Opinion) or 100, whichever is greater.

Multiply HOSTILE approach score by 100.
Divide HOSTILE approach score by (100 + iHostileMod + Opinion) or 100, whichever is greater.

Multiply DECEPTIVE approach score by 100.
Divide DECEPTIVE approach score by (100 + iDeceptiveMod + Opinion) or 100, whichever is greater.

Multiply GUARDED approach score by 100.
Divide GUARDED approach score by (100 + iGuardedMod + Opinion) or 100, whichever is greater.

If the opinion score for this player is better than the "Favorable" threshold:
Multiply NEUTRAL approach score by 100.
Divide NEUTRAL approach score by (100 + iNeutralMod + Opinion) or 100, whichever is greater.


If the opinion score for this player is between the "Competitor" and "Favorable" thresholds:
Multiply Opinion by -1.

Multiply NEUTRAL approach score by (100 + iNeutralMod + Opinion).
Divide NEUTRAL approach score by 100.


40. Make Changes in Approach Gradual
For each of the approaches:

A. Calculate the "average" value of this turn's score and the last turn's score using this formula: (0.5f + (Approach Score * 0.10f) + (Approach Score Last Turn * (1 - 0.10f)))
B. Set the approach score to this "average" value.


41. Pick a War Face If Going to War
If the highest approach score after all these calculations is WAR (therefore the AI is planning a war), but the AI is not currently at war with you or declaring war right this second, AI will pick the next highest APPROACH score:

HOSTILE
- AI will act HOSTILE to you until it's ready for war.

DECEPTIVE
- AI will act NEUTRAL to you until it's ready for war.

AFRAID
- AI will act HOSTILE to you until it's ready for war.

FRIENDLY
- AI will act FRIENDLY to you until it's ready for war.

OTHERWISE
- AI will act NEUTRAL to you until it's ready for war.


42. Decide What Approach to Show to the Player
The AI picks its highest approach and uses that towards you. If all approach scores are 0, it will use the NEUTRAL approach.

If the AI is currently at war, the WAR! approach is shown.

If the AI is planning war, they will use their War Face (see #41 above).

If the AI's approach is DECEPTIVE, it will show up as FRIENDLY.

Otherwise, the approach shown to you is the AI's approach towards you.
Wow! Great work!
 
Impressiv work you have done. Wow.
The point Iam most suprised is the "refuse co-op-war request". I always thought as long as I didnt take the first answer, refusing the request have no influence. But now I can see, the more often I refuse, the more this civilization dislikes me.
And the AI is less like hostile or war like if the domination victory is disabled..... is this a good idea? Doing successful conquest are in the most cases an advantage, but the AI is 10 times less like to do so if domination victory is disabled.

Other player has a Defensive Pact with the player we're looking at If the other player's military strength is equal to or greater than ours: - Subtract 2x WAR bias from WAR approach. - Subtract 2x HOSTILE bias from HOSTILE approach.

Some aspects add 5 times, 10 times, 15 times the bias towards hostility or war.... and the fact the potential enemy has a defensive pact is only considered with a 2 times bias towards hostility ?
I thought this would be considered as much greater factor, like modifying the final value by -50% or something, but it is only a minor value instead?

22. War Projection How well do we a think a war against this player would go? (GetWarProjection function) Estimated outcome of the war for us:
Ok, this part is the interesting one.

One option is to implement the previous war modification into the GetWarProjection function, to influence the outcome of the projection.

Or, the more often one rejects their demand for a common war, the more the friendly aspect is reduced, and the more often the hostile aspect increases.
The function thus allows a multiple modification.
This would allow us the addition of:

22.5 Previous Wars

Devastating (losing a war with less than -25 warscore)
- Add 2x the # of times we lost a war against them to AFRAID bias to AFRAID approach.
- Add 2x the # of times we lost a war against them to FRIENDLY bias to FRIENDLY approach.
- Subtract 2x the # of times we lost a war against them to WAR bias to WAR approach.
- Subtract 2x the # of times we lost a war against them to HOSTILE bias to HOSTILE approach.

Senseless (finishing a war with a warscore between -25 and 0)
- Add 1x the # of times we were at war with no result to FRIENDLY bias to FRIENDLY approach.
- Subtract 1x the # of times we were at war with no result to HOSTILE bias to HOSTILE approach.
- Subtract 1x the # of times we were at war with no result to WAR bias to WAR approach.

Hoping (finishing a war with a warscore between 0 and +25)
- Subtract 1x the # of times we were at war with no result to to FRIENDLY bias to FRIENDLY approach.
- Add 1x the # of times we were at war with no result to HOSTILE bias to HOSTILE approach.
- Add 1x the # of times we were at war with no result to WAR bias to WAR approach.

Promising (winning a war with more than +25 warscore)
- Subtract 2x the # of times we lost a war against them to AFRAID bias to AFRAID approach.
- Subtract 2x the # of times we lost a war against them to FRIENDLY bias to FRIENDLY approach.
- Add 2x the # of times we lost a war against them to WAR bias to WAR approach.
- Add 2x the # of times we lost a war against them to HOSTILE bias to HOSTILE approach.

The sum total of the positive and negative modifier values is the Opinion score, with one change: in the code, positive modifiers reduce your opinion value (so a negative opinion score is good), and negative modifiers increase your opinion value (so a positive opinion score is bad). The following values affect how opinion applies in approach calculation: iWarMod - the WAR bias * the leader's Boldness * 2 iHostileMod - the HOSTILE bias * the leader's Denounce Willingness * 2 iDeceptiveMod - the DECEPTIVE bias * the leader's Meanness * 2 iGuardedMod - the GUARDED bias * (10 - the leader's Forgiveness) * 2 iFriendlyMod - the FRIENDLY bias * the leader's Loyalty * 2 iNeutralMod - the NEUTRAL bias * the leader's DiploBalance score * 2
This could be also used to modify the final values. As mentioned earlier, all former wars influence a PreviousWarModifier and this is multiplied with the hostile/war approach.
 
And the AI is less like hostile or war like if the domination victory is disabled..... is this a good idea? Doing successful conquest are in the most cases an advantage, but the AI is 10 times less like to do so if domination victory is disabled.

Remember there are still many other factors that come after that one in the function, including ones which greatly increase or decrease WAR/HOSTILE score (such as having a Unique Unit, or the other player being the biggest competitor), so to say the AI is 10 times less likely to do so isn't accurate...overall I don't think it's anything to be worried about. There haven't been many complaints about the AI being passive - which was a HUGE issue in vanilla, and which VP has solved in most cases.

The function thus allows a multiple modification.
Reading through all this code has made it clear that you need to be careful about where exactly in it a change is made, and what that change is. :crazyeye:

Your idea is interesting, and I certainly like the idea of the AI factoring previous wars into its decision-making (currently it doesn't look more than 25 turns back, as far as I'm aware - other functions may consider it), but any change done would need careful consideration and review first, since this function greatly impacts how every AI in the game behaves.

Furthermore, if it factors previous wars too much when making decisions, it could be human exploitable (i.e. crush the AI in the ancient era and they won't bother you till the modern era type exploits).

I think that any factoring of previous wars should be based on comparative military power throughout the war as well as how badly the AI lost (or how well it won). The idea being it would have an additional tendency to attack if it had a stronger military compared to the player than last time if it lost, and less of a tendency otherwise - or there was some other condition, like other AIs being at war with the player or a tech lead.

Should also factor in some time decay, and other factors should be able to override it. Proposing changes here is a complicated process. :p

I'm impressed by how the existing function works, it takes more into consideration than I'd thought. Using leader biases rather than hardcoded values was a smart idea, and a clever way to incorporate flavors.
 
Last edited:
I have a question about this topic.

How exactly is my military score calculated? Because I currently have 4 Mandekalu cavalry, a scout, and a warrior, which I consider a really powerful military for turn 60. I have a score of 5. My neighbor the Huns, who as far as I can tell have only warriors, archers, and handaxes, has a score of 12 and attacks me. He is slaughtered easily, because, well his military is trash and I can kill any of his units in 1 hit.

Fast forward 50 turns, I still have the lowest military score by a huge margin, and I'm attacked by all three civs on the continent, probably because my military score is 7. I'm actually doing just fine in this war, but like, what is going on? The Huns have a score of 29, the Dutch (who don't seem to even have any iron and 2 horses total) have 24, the Ottomans have 35.

I also noticed that the Huns had a score of 29. They lost two horsemen, and still had 29 the next turn. I'm fine with the concept of the AI attacking someone with a weak military, I just cannot figure out how to not have a weak military or how their scores are so high (especially since they still have warriors, which are useless by this stage of the game). How does the score scale? It can't be linear, if so I could be at my supply cap with just Mandekalu cavalry and I would have a score of.....like 21?
 
I have a question about this topic.

How exactly is my military score calculated? Because I currently have 4 Mandekalu cavalry, a scout, and a warrior, which I consider a really powerful military for turn 60. I have a score of 5. My neighbor the Huns, who as far as I can tell have only warriors, archers, and handaxes, has a score of 12 and attacks me. He is slaughtered easily, because, well his military is trash and I can kill any of his units in 1 hit.

Fast forward 50 turns, I still have the lowest military score by a huge margin, and I'm attacked by all three civs on the continent, probably because my military score is 7. I'm actually doing just fine in this war, but like, what is going on? The Huns have a score of 29, the Dutch (who don't seem to even have any iron and 2 horses total) have 24, the Ottomans have 35.

I also noticed that the Huns had a score of 29. They lost two horsemen, and still had 29 the next turn. I'm fine with the concept of the AI attacking someone with a weak military, I just cannot figure out how to not have a weak military or how their scores are so high (especially since they still have warriors, which are useless by this stage of the game). How does the score scale? It can't be linear, if so I could be at my supply cap with just Mandekalu cavalry and I would have a score of.....like 21?
Could it be that you have more cities? Each unit increase your score and each city decrease it.

(From memory, the formula is something like Total strength / Base+4*Nb cities)
 
Could it be that you have more cities? Each unit increase your score and each city decrease it.

(From memory, the formula is something like Total strength / Base+4*Nb cities)
I only have 5 cities. Dutch had 5, Ottomans and Huns had 6.
 
I have a question about this topic.

How exactly is my military score calculated? Because I currently have 4 Mandekalu cavalry, a scout, and a warrior, which I consider a really powerful military for turn 60. I have a score of 5. My neighbor the Huns, who as far as I can tell have only warriors, archers, and handaxes, has a score of 12 and attacks me. He is slaughtered easily, because, well his military is trash and I can kill any of his units in 1 hit.

Fast forward 50 turns, I still have the lowest military score by a huge margin, and I'm attacked by all three civs on the continent, probably because my military score is 7. I'm actually doing just fine in this war, but like, what is going on? The Huns have a score of 29, the Dutch (who don't seem to even have any iron and 2 horses total) have 24, the Ottomans have 35.

I also noticed that the Huns had a score of 29. They lost two horsemen, and still had 29 the next turn. I'm fine with the concept of the AI attacking someone with a weak military, I just cannot figure out how to not have a weak military or how their scores are so high (especially since they still have warriors, which are useless by this stage of the game). How does the score scale? It can't be linear, if so I could be at my supply cap with just Mandekalu cavalry and I would have a score of.....like 21?

Code:
int CvPlayer::GetScoreFromMilitarySize() const
{
    return (GetMilitaryMight() / (20 + getNumCities()));
}

Code:
//    --------------------------------------------------------------------------------
#if defined(MOD_BATTLE_ROYALE)
int CvPlayer::calculateMilitaryMight(DomainTypes eDomain) const
#else
int CvPlayer::calculateMilitaryMight() const
#endif
{
    int rtnValue = 0;
    const CvUnit* pLoopUnit;
    int iLoop;

    for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
    {
        if(!pLoopUnit->IsCombatUnit())
            continue;
        // Current combat strength or bombard strength, whichever is higher
        int iPower =  pLoopUnit->GetPower();
#if defined(MOD_BATTLE_ROYALE)
        if (eDomain == NO_DOMAIN)
        {
            rtnValue += iPower;
        }
        else if (pLoopUnit->getDomainType() == eDomain)
        {
            rtnValue += iPower;
        }
#else
        rtnValue += iPower;
#endif
    }

#if defined(MOD_BALANCE_CORE_MILITARY)
    //Finally, divide our power by the number of cities we own - the more we have, the less we can defend.
    return int( rtnValue / max(1.f, sqrt((float)getNumCities())));
#else

    //Simplistic increase based on player's gold
    //500 gold will increase might by 22%, 2000 by 45%, 8000 gold by 90%
    float fGoldMultiplier = 1.0f + (sqrt((float)GetTreasury()->GetGold()) / 100.0f);
    if(fGoldMultiplier > 2.0f) fGoldMultiplier = 2.0f;
    rtnValue = (int)(rtnValue * fGoldMultiplier);
    return rtnValue;
#endif
}
 
What if AI's evaluation of the power of your troops increased as you won wars and based on a units killed to lost ratio? If you win war after war without losing units, the AI should be more weary than if you stalemate with equal losses. It would make the AI perform better because they would be better at choosing when to fight a player. Maybe also have a global modifier based on how you performed versus expectations. If you trounce an enemy with 2 times your projected military score the AI should take notice and attack with a bigger force if they choose to.
 
It seems to me that this comes up repeatedly because many want to play the game in a role playing sense.

What I think many players really want is the AI to play an expansionist game without paying attention to the player.

Of course, it would be impossible at this stage to separate the AI algorithms, but I can understand the frustation for players who want a casual experience.
 
Back
Top Bottom