Ideologies are stupid...

(edit: sorry, quoted wrong post)
Here is the code that governs how the AI chooses an ideology :

Code:
void CvPolicyAI::DoChooseIdeology(CvPlayer *pPlayer)
{
	int iFreedomPriority = 0;
	int iAutocracyPriority = 0;
	int iOrderPriority = 0;
	int iFreedomMultiplier = 1;
	int iAutocracyMultiplier = 1;
	int iOrderMultiplier = 1;
	PolicyBranchTypes eFreedomBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_FREEDOM();
	PolicyBranchTypes eAutocracyBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_AUTOCRACY();
	PolicyBranchTypes eOrderBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_ORDER();
	if (eFreedomBranch == NO_POLICY_BRANCH_TYPE || eAutocracyBranch == NO_POLICY_BRANCH_TYPE || eOrderBranch == NO_POLICY_BRANCH_TYPE)
	{
		return;
	}

	// First consideration is our victory type
	int iConquestPriority = max(0, pPlayer->GetGrandStrategyAI()->GetConquestPriority());
	int iDiploPriority = max(0, pPlayer->GetGrandStrategyAI()->GetUnitedNationsPriority());
	int iTechPriority = max(0, pPlayer->GetGrandStrategyAI()->GetSpaceshipPriority());
	int iCulturePriority = max(0, pPlayer->GetGrandStrategyAI()->GetCulturePriority());

	// Rule out one ideology if we are clearly (at least 25% more priority) going for the victory this ideology doesn't support
	int iClearPrefPercent = GC.getIDEOLOGY_PERCENT_CLEAR_VICTORY_PREF();
	if (iConquestPriority > (iDiploPriority   * (100 + iClearPrefPercent) / 100) &&
		iConquestPriority > (iTechPriority    * (100 + iClearPrefPercent) / 100) &&
		iConquestPriority > (iCulturePriority * (100 + iClearPrefPercent) / 100))
	{
		iFreedomMultiplier = 0;
	}
	else if (iDiploPriority > (iConquestPriority * (100 + iClearPrefPercent) / 100) &&
		iDiploPriority > (iTechPriority     * (100 + iClearPrefPercent) / 100) &&
		iDiploPriority > (iCulturePriority  * (100 + iClearPrefPercent) / 100))
	{
		iOrderMultiplier = 0;
	}
	else if (iTechPriority > (iConquestPriority * (100 + iClearPrefPercent) / 100) &&
		iTechPriority > (iDiploPriority    * (100 + iClearPrefPercent) / 100) &&
		iTechPriority > (iCulturePriority  * (100 + iClearPrefPercent) / 100))
	{
		iAutocracyMultiplier = 0;
	}

	int iFreedomTotal = iDiploPriority + iTechPriority + iCulturePriority;
	int iAutocracyTotal = iDiploPriority + iConquestPriority + iCulturePriority;
	int iOrderTotal = iTechPriority + iConquestPriority + iCulturePriority;
	int iGrandTotal = iFreedomTotal + iAutocracyTotal + iOrderTotal;

	if (iGrandTotal > 0)
	{
		int iPriorityToDivide = GC.getIDEOLOGY_SCORE_GRAND_STRATS();
		iFreedomPriority = (iFreedomTotal * iPriorityToDivide) / iGrandTotal;
		iAutocracyPriority = (iAutocracyTotal * iPriorityToDivide) / iGrandTotal;
		iOrderPriority = (iOrderTotal * iPriorityToDivide) / iGrandTotal;
	}

	CvString stage = "After Grand Strategies";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Next look at free policies we can get
	iFreedomPriority += PolicyHelpers::GetNumFreePolicies(eFreedomBranch) * GC.getIDEOLOGY_SCORE_PER_FREE_TENET();
	iAutocracyPriority += PolicyHelpers::GetNumFreePolicies(eAutocracyBranch) * GC.getIDEOLOGY_SCORE_PER_FREE_TENET();
	iOrderPriority += PolicyHelpers::GetNumFreePolicies(eOrderBranch) * GC.getIDEOLOGY_SCORE_PER_FREE_TENET();;

	stage = "After Free Policies";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Finally see what our friends (and enemies) have already chosen
	PlayerTypes eLoopPlayer;
	for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
	{
		eLoopPlayer = (PlayerTypes) iPlayerLoop;
		if (eLoopPlayer != pPlayer->GetID() && pPlayer->GetDiplomacyAI()->IsPlayerValid(eLoopPlayer))
		{
			CvPlayer &kOtherPlayer = GET_PLAYER(eLoopPlayer);
			PolicyBranchTypes eOtherPlayerIdeology;
			eOtherPlayerIdeology = kOtherPlayer.GetPlayerPolicies()->GetLateGamePolicyTree();

			switch(pPlayer->GetDiplomacyAI()->GetMajorCivApproach(eLoopPlayer, /*bHideTrueFeelings*/ true))
			{
			case MAJOR_CIV_APPROACH_HOSTILE:
				if (eOtherPlayerIdeology == eFreedomBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_HOSTILE();
					iOrderPriority += GC.getIDEOLOGY_SCORE_HOSTILE();
				}
				else if (eOtherPlayerIdeology == eAutocracyBranch)
				{
					iFreedomPriority += GC.getIDEOLOGY_SCORE_HOSTILE();
					iOrderPriority += GC.getIDEOLOGY_SCORE_HOSTILE();
				}
				else if (eOtherPlayerIdeology == eOrderBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_HOSTILE();;
					iFreedomPriority += GC.getIDEOLOGY_SCORE_HOSTILE();
				}
				break;
			case MAJOR_CIV_APPROACH_GUARDED:
				if (eOtherPlayerIdeology == eFreedomBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_GUARDED();
					iOrderPriority += GC.getIDEOLOGY_SCORE_GUARDED();
				}
				else if (eOtherPlayerIdeology == eAutocracyBranch)
				{
					iFreedomPriority += GC.getIDEOLOGY_SCORE_GUARDED();
					iOrderPriority += GC.getIDEOLOGY_SCORE_GUARDED();
				}
				else if (eOtherPlayerIdeology == eOrderBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_GUARDED();
					iFreedomPriority += GC.getIDEOLOGY_SCORE_GUARDED();
				}
				break;
			case MAJOR_CIV_APPROACH_AFRAID:
				if (eOtherPlayerIdeology == eFreedomBranch)
				{
					iFreedomPriority += GC.getIDEOLOGY_SCORE_AFRAID();
				}
				else if (eOtherPlayerIdeology == eAutocracyBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_AFRAID();
				}
				else if (eOtherPlayerIdeology == eOrderBranch)
				{
					iOrderPriority += GC.getIDEOLOGY_SCORE_AFRAID();
				}
				break;
			case MAJOR_CIV_APPROACH_FRIENDLY:
				if (eOtherPlayerIdeology == eFreedomBranch)
				{
					iFreedomPriority += GC.getIDEOLOGY_SCORE_FRIENDLY();
				}
				else if (eOtherPlayerIdeology == eAutocracyBranch)
				{
					iAutocracyPriority += GC.getIDEOLOGY_SCORE_FRIENDLY();
				}
				else if (eOtherPlayerIdeology == eOrderBranch)
				{
					iOrderPriority += GC.getIDEOLOGY_SCORE_FRIENDLY();
				}
				break;
			case MAJOR_CIV_APPROACH_NEUTRAL:
				// No changes
				break;
			}
		}
	}

	stage = "After Relations";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Look at Happiness impacts
	int iHappinessModifier = GC.getIDEOLOGY_SCORE_HAPPINESS();

	// -- Happiness we could add through tenets
	int iHappinessDelta;
	int iHappinessPoliciesInBranch;
	iHappinessDelta = GetBranchBuildingHappiness(pPlayer, eFreedomBranch);
	iHappinessPoliciesInBranch = GetNumHappinessPolicies(pPlayer, eFreedomBranch);
	if (iHappinessPoliciesInBranch > 0)
	{
		iFreedomPriority += iHappinessDelta * iHappinessModifier / iHappinessPoliciesInBranch;		
	}
	iHappinessDelta = GetBranchBuildingHappiness(pPlayer, eAutocracyBranch);
	iHappinessPoliciesInBranch = GetNumHappinessPolicies(pPlayer, eAutocracyBranch);
	if (iHappinessPoliciesInBranch > 0)
	{
		iAutocracyPriority += iHappinessDelta * iHappinessModifier / iHappinessPoliciesInBranch;		
	}
	iHappinessDelta = GetBranchBuildingHappiness(pPlayer, eOrderBranch);
	iHappinessPoliciesInBranch = GetNumHappinessPolicies(pPlayer, eOrderBranch);
	if (iHappinessPoliciesInBranch > 0)
	{
		iOrderPriority += iHappinessDelta * iHappinessModifier / iHappinessPoliciesInBranch;		
	}

	stage = "After Tenet Happiness Boosts";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// -- Happiness we'd lose through Public Opinion
	iHappinessDelta = max (0, 100 - pPlayer->GetCulture()->ComputeHypotheticalPublicOpinionUnhappiness(eFreedomBranch));
	iFreedomPriority += iHappinessDelta * iHappinessModifier;
	iHappinessDelta = max (0, 100 - pPlayer->GetCulture()->ComputeHypotheticalPublicOpinionUnhappiness(eAutocracyBranch));
	iAutocracyPriority += iHappinessDelta * iHappinessModifier;
	iHappinessDelta = max (0, 100 - pPlayer->GetCulture()->ComputeHypotheticalPublicOpinionUnhappiness(eOrderBranch));
	iOrderPriority += iHappinessDelta * iHappinessModifier;

	stage = "After Public Opinion Happiness";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Small random add-on
	iFreedomPriority += GC.getGame().getJonRandNum(10, "Freedom random priority bump");
	iAutocracyPriority += GC.getGame().getJonRandNum(10, "Autocracy random priority bump");
	iOrderPriority += GC.getGame().getJonRandNum(10, "Order random priority bump");

	stage = "After Random (1 to 10)";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Rule out any branches that are totally out of consideration
	iFreedomPriority = iFreedomPriority * iFreedomMultiplier;
	iAutocracyPriority = iAutocracyPriority * iAutocracyMultiplier;
	iOrderPriority = iOrderPriority * iOrderMultiplier;

	stage = "Final (after Clear Victory Preference)";
	LogIdeologyChoice(stage, iFreedomPriority, iAutocracyPriority, iOrderPriority);

	// Pick the ideology
	PolicyBranchTypes eChosenBranch;
	if (iFreedomPriority >= iAutocracyPriority && iFreedomPriority >= iOrderPriority)
	{
		eChosenBranch = eFreedomBranch;
	}
	else if (iAutocracyPriority >= iFreedomPriority && iAutocracyPriority >= iOrderPriority)
	{
		eChosenBranch = eAutocracyBranch;
	}
	else
	{
		eChosenBranch = eOrderBranch;
	}
	pPlayer->GetPlayerPolicies()->SetPolicyBranchUnlocked(eChosenBranch, true, false);
	LogBranchChoice(eChosenBranch);
}


Whoever designed that code seems pretty 'pointer-happy'! So many pointers to pointers...
 
I don't know the weighing between them, but I would probably guess 1 and 3 are probably both given lots of weight. Likewise, the one with the strongest pressure would be a bit factor as well. My point was just that it's clear they aren't just going to take the one others have taken, the value of being first is quite high.

Yeah, I followed. Sorry I wasn't meaning to be argumentative, I was more just reiterating the situation (IMO of course) in light of the OP's setup and how that will overwhelm the rest of the calculation eventually.

I have had a look at the individual weights but don't remember off hand so cannot comment either way. That said I would say your assertion is probably correct, although I don't imagine any part is insignificant for a balanced setup. The problem is that only part 3 has the capacity to become unbounded (or the reverse).

There are quite a few areas of the code that lack sanity checks for creative game setups. Not really blaming Firaxis for this, more just acknowledging the fact. As such quite a few gameplay mechanics become unwieldy, unbalanced or even broken under certain setups.

I guess the moral of the story is that if you are going to alter the setup to support your own particular playstyle, you need to be cognisant that as a result of your selection, the flow, challenge and balance of the game will change in unforseen ways.
 
(edit: sorry, quoted wrong post)



Whoever designed that code seems pretty 'pointer-happy'! So many pointers to pointers...

:)

Yeah well there are performance benefits for it particularly when dealing with a large memory footprint. Additionally certain data structures require them to as part of the underlying implementation.

But yes indirection, OO compartmentalization and other forms of abstraction make for code that at first glance is not easy to follow.

The good thing about Firaxis is that usually you can find most of the functions/constants/structures that pertain to the code you are reading in the same file. Which is very very handy, to a newcomer.

At least its not like deciphering scripts for the Guild 2 Renaissance, they were in German, ridiculously buggy, and comments what comments :)
 
In my current game, everyone took autocracy ideology because 2 major civilizations took it. out of 22 civilizations so far 10 took autocracy, 2 order and 1 freedom, and the 3 who didn't take order have -22 happiness now.
It is very unrealistic and broken. Do you know how to fix it?
I would like everyone to take ideology they find best for their civilizations and not because it's the safest one to take.

Not realistic? Well, what happened irl? Everyone took freedom, one or two took order and autocracy, and they got slammed with revolutionary waves from all the unhappiness because the freedom cultures were too influential. Ideologies are very realistic. Most of the time, the AIs DO take the ideology they want most, even if it puts them in revolution.
 
I would be fine if everyone took freedom or even order but autocracy? It should always be taken the least by everyone ...
 
I would be fine if everyone took freedom or even order but autocracy? It should always be taken the least by everyone ...

Well the ideologies are chosen due to in game circumstance and gameplay advantage. Saying Autocracy should be the least chosen is like saying Conquest should be the least chosen Victory. Why ?

I believe Civs should choose what is best for them. How is it realistic for a Civ who will gain the most for their given victory type, by choosing Autocracy to choose something else instead ????? Remember Civ is meant to be modelling an alternate history using existing Civs, as if they all popped into existnece in 4000BC.

As I have said already your Civ number is contributing heavily to this. Dial down the number if you want more balanced gameplay, otherwise once a bunch of Civs choose a given IDEOLOGY, their relationship with a new civ will dictate this Civs ideological choices.

If you really want to be able pursue Freedom, without penalty. You CAN do this. You just need to make more friends with people and try to choose your ideology before others have made their choices, whilst keeping your culture strong. Then your choice will influence theirs. However if you are hated by the world, then whatever ideology you choose will likely be chosen much less. This is both a good thing, and an historically accurate one. Nations are more likely to embrace the beliefs and ideologies of their friends then their enemies.

I have done my best to explain the mechanics to you, and how you can manipulate them to your own advantage. I hope it helps.
 
The OP is right. There is something wrong with the way ideology is set up; the AIs will often go toward one ideology because the happiness hit is so extreme under what should be trifling circumstances. All the other factors named cannot compete with this.

In my current game, I'm playing Morocco, with order ideology, on huge with 12 civs; three civs with different ideologies are influencing me. All of them are exotic; one is autocracy, two freedom. Those three exotic cultures are enough to give -29 public opinion and produce civil resistance, close to a revolutionary wave. Not influential, popular, or even familiar, but exotic. One exotic culture choosing freedom was enough to drop my overall happiness about fifteen points.

That is not balanced, and that is causing AIs to flip ideologies in waves.
 
The OP is right. There is something wrong with the way ideology is set up; the AIs will often go toward one ideology because the happiness hit is so extreme under what should be trifling circumstances. All the other factors named cannot compete with this.

In my current game, I'm playing Morocco, with order ideology, on huge with 12 civs; three civs with different ideologies are influencing me. All of them are exotic; one is autocracy, two freedom. Those three exotic cultures are enough to give -29 public opinion and produce civil resistance, close to a revolutionary wave. Not influential, popular, or even familiar, but exotic. One exotic culture choosing freedom was enough to drop my overall happiness about fifteen points.

That is not balanced, and that is causing AIs to flip ideologies in waves.

Are they exotic to you or are you exotic to them? Because that's what the Influence tab shows for your civ.
 
They are exotic to me. I went over that screen very carefully.

Edit: I tried to upload the save for anyone interested, but it is 2.11 mb and above the 2 mb limit for attachments.
 
I've had similar problems. The AI leans very heavily toward Order in the 3 games I've played. In my current game, as Poland, I chose Freedom. One other civ, Portugal, had also chosen Freedom, another had chosen Autocracy, and 3 had chosen Order. My unhappiness started at 0. But as a few more civs chose order, I incurred first a -6 happiness penalty, then -15. I finally decided to give up Freedom and switch to Order. Later, two other civs faced revolt and were forced to switch to Order as well. Portugal continued to hold onto Freedom but was quickly denounced by all of the AI civs, then promptly invaded and lost most of their cities.

Also, it's silly to say that irl countries are easily swayed by other countries. Most countries resist the influence of outsiders and are even put off by it. America is not influenced a whit by the beliefs of Cuba, Iran, North Korea, etc., nor they by us. The size and success of a country is a far bigger factor. Our attempts to force countries to adopt capitalism in the 80s or democracy in the 00s have largely back-fired. Soviet influence over the Eastern bloc stemmed largely from military might (crushing the Hungarian Spring) than anything else.
 
That's C(++) for you. It's how it generally works when trying to be efficient.

Hey, don't lump C in with C++! C++ is absolutely awful at everything, but C is fantastic! If you're writing nonsense like "pPlayer->GetGrandStrategyAI()->GetSpaceshipPriority()" in C, then you're doing it wrong. :p
 
They are exotic to me. I went over that screen very carefully.

Edit: I tried to upload the save for anyone interested, but it is 2.11 mb and above the 2 mb limit for attachments.

Are you sure because exotic civs shouldn't cause ideological pressure at all.

(ie on the screen that has a drop down selection on top, if Your civ is in the droppdown selection, then the effects below is Your influence on those civs... not their influence on you)
 
The OP is right. There is something wrong with the way ideology is set up; the AIs will often go toward one ideology because the happiness hit is so extreme under what should be trifling circumstances. All the other factors named cannot compete with this.

In my current game, I'm playing Morocco, with order ideology, on huge with 12 civs; three civs with different ideologies are influencing me. All of them are exotic; one is autocracy, two freedom. Those three exotic cultures are enough to give -29 public opinion and produce civil resistance, close to a revolutionary wave. Not influential, popular, or even familiar, but exotic. One exotic culture choosing freedom was enough to drop my overall happiness about fifteen points.

That is not balanced, and that is causing AIs to flip ideologies in waves.

3 civs at exotic compared to you being unknown is 3 pressure points against you. Really, dont neglect toursim so much. It takes practially little effort to get to exotic with everybody.
 
Exotic - Unknown = 1 pressure point

I thought they had to be at least Familiar to exert pressure... but I guess that is possible.

(although 3 pressure points should not be enough to cause serious problems... unless you had a Massive Empire)
 
Are you sure because exotic civs shouldn't cause ideological pressure at all.

(ie on the screen that has a drop down selection on top, if Your civ is in the droppdown selection, then the effects below is Your influence on those civs... not their influence on you)

Yes, I am very sure. I know how to read these screens. Three civs, exotic to me, -29 public opinion.

Three pressure points from three exotic civs should not produce that much discontent. My tourism is not neglected; it is decent if not excellent. I have the Eiffel Tower, the Louvre, the Uffizi. I don't see why excuses are being made for this; it's absurd. Hopefully it will be patched.
 
Yes, I am very sure. I know how to read these screens. Three civs, exotic to me, -29 public opinion.

Three pressure points from three exotic civs should not produce that much discontent. My tourism is not neglected; it is decent if not excellent. I have the Eiffel Tower, the Louvre, the Uffizi. I don't see why excuses are being made for this; it's absurd. Hopefully it will be patched.

Upload the save somewhere that doesn't have the same attachment limit as here. This sounds like a bug (like, an actual bug instead of the game just playing in a way someone doesn't like), if it's actually the way you describe.
 
Yes, I am very sure. I know how to read these screens. Three civs, exotic to me, -29 public opinion.

Three pressure points from three exotic civs should not produce that much discontent. My tourism is not neglected; it is decent if not excellent. I have the Eiffel Tower, the Louvre, the Uffizi. I don't see why excuses are being made for this; it's absurd. Hopefully it will be patched.

Well 3 pressure points is enough for civil disorder I believe.. (Is there a World Ideology.. that would add 2 more points?)

2 unhappiness per city or 1 per 5 pop (whichever is more)... so -29 is possible [I guess you have 245 total population]

I guess you could be unknown to them on a huge map... they (and you) would be producing lots of culture from lots of cities. That might explain how you are unknown to them.

I agree it sounds buggy If you actually have Louvre/Uffizi filled (even if not themed), then you should probably be to exotic at least [and I do remember hearing that Familiar was required to exert ideological pressure]
 
Yes, I am very sure. I know how to read these screens. Three civs, exotic to me, -29 public opinion.

Three pressure points from three exotic civs should not produce that much discontent. My tourism is not neglected; it is decent if not excellent. I have the Eiffel Tower, the Louvre, the Uffizi. I don't see why excuses are being made for this; it's absurd. Hopefully it will be patched.

You have shown 0 proof there is an issue. Nor will a patch be coming soon. Upload your save, if you cannot here. Contact a Firaxis dev that comes here and send them your save.

I assure you of one thing, your word is not enough.
 
Top Bottom