What is the formula used to calculate Faith pressure?

asura_

Chieftain
Joined
Jul 17, 2014
Messages
76
Location
USA
Does it depend on your generated faith per turn? Also any info on how followers are calculated
 
I'm not sure, but this is what I found in the game source code. See if you can extract anything out of it. Do you know C++?
Spoiler :
Code:
/// Is there a religion that at least half of the population follows?
ReligionTypes CvCityReligions::GetReligiousMajority()
{
	int iTotalFollowers = 0;
	int iMostFollowerPressure = 0;
	int iMostFollowers = -1;
	ReligionTypes eMostFollowers = NO_RELIGION;
	ReligionInCityList::iterator religionIt;

	for(religionIt = m_ReligionStatus.begin(); religionIt != m_ReligionStatus.end(); ++religionIt)
	{
		iTotalFollowers += religionIt->m_iFollowers;

		if(religionIt->m_iFollowers > iMostFollowers || religionIt->m_iFollowers == iMostFollowers && religionIt->m_iPressure > iMostFollowerPressure)
		{
			iMostFollowers = religionIt->m_iFollowers;
			iMostFollowerPressure = religionIt->m_iPressure;
			eMostFollowers = religionIt->m_eReligion;
		}
	}

	if ((iMostFollowers * 2) >= iTotalFollowers)
	{
		return eMostFollowers;
	}
	else
	{
		return NO_RELIGION;
	}
}

/// Just asked to simulate a conversion - who would be the majority religion?
ReligionTypes CvCityReligions::GetSimulatedReligiousMajority()
{
	int iTotalFollowers = 0;
	int iMostFollowerPressure = 0;
	int iMostFollowers = -1;
	ReligionTypes eMostFollowers = NO_RELIGION;
	ReligionInCityList::iterator religionIt;

	for(religionIt = m_SimulatedStatus.begin(); religionIt != m_SimulatedStatus.end(); ++religionIt)
	{
		iTotalFollowers += religionIt->m_iFollowers;

		if(religionIt->m_iFollowers > iMostFollowers || religionIt->m_iFollowers == iMostFollowers && religionIt->m_iPressure > iMostFollowerPressure)
		{
			iMostFollowers = religionIt->m_iFollowers;
			iMostFollowerPressure = religionIt->m_iPressure;
			eMostFollowers = religionIt->m_eReligion;
		}
	}

	if ((iMostFollowers * 2) >= iTotalFollowers)
	{
		return eMostFollowers;
	}
	else
	{
		return NO_RELIGION;
	}
}

/// What is the most popular religion in this city?
ReligionTypes CvCityReligions::GetFavoredReligion()
{
	int iTotalFollowers = 0;
	int iMostFollowers = -1;
	ReligionTypes eMostFollowers = NO_RELIGION;
	ReligionInCityList::iterator religionIt;

	for(religionIt = m_ReligionStatus.begin(); religionIt != m_ReligionStatus.end(); ++religionIt)
	{
		iTotalFollowers += religionIt->m_iFollowers;

		if(religionIt->m_iFollowers >= iMostFollowers && religionIt->m_eReligion != NO_RELIGION)
		{
			iMostFollowers = religionIt->m_iFollowers;
			eMostFollowers = religionIt->m_eReligion;
		}
	}

	CvAssertMsg(eMostFollowers != NO_RELIGION, "Improper call usage: called GetFavoredReligion() with no religion present in city");

	return eMostFollowers;
}

/// How many followers are there of religions OTHER than this one?
int CvCityReligions::GetFollowersOtherReligions(ReligionTypes eReligion)
{
	int iOtherFollowers = 0;
	ReligionInCityList::iterator religionIt;

	for(religionIt = m_ReligionStatus.begin(); religionIt != m_ReligionStatus.end(); ++religionIt)
	{
		if (religionIt->m_eReligion > RELIGION_PANTHEON && religionIt->m_eReligion != eReligion)
		{
			iOtherFollowers += religionIt->m_iFollowers;
		}
	}

	return iOtherFollowers;
}

/// Total pressure exerted by all religions
int CvCityReligions::GetTotalPressure()
{
	int iTotalPressure = 0;

	ReligionInCityList::iterator it;
	for(it = m_ReligionStatus.begin(); it != m_ReligionStatus.end(); it++)
	{
		iTotalPressure += it->m_iPressure;
	}

	return iTotalPressure;
}

/// Pressure exerted by one religion
int CvCityReligions::GetPressure(ReligionTypes eReligion)
{
	ReligionInCityList::iterator it;
	for(it = m_ReligionStatus.begin(); it != m_ReligionStatus.end(); it++)
	{
		if(it->m_eReligion == eReligion)
		{
			return it->m_iPressure;
		}
	}

	return 0;
}

/// Pressure exerted by one religion per turn
int CvCityReligions::GetPressurePerTurn(ReligionTypes eReligion)
{
	int iPressure = 0;

	// Loop through all the players
	for(int iI = 0; iI < MAX_PLAYERS; iI++)
	{
		CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI);
		if(kPlayer.isAlive())
		{
			// Loop through each of their cities
			int iLoop;
			CvCity* pLoopCity;
			for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))
			{
				// Ignore the same city
				if (m_pCity == pLoopCity)
				{
					continue;
				}

				// Does this city have the matching majority religion?
				ReligionTypes eMajorityReligion = pLoopCity->GetCityReligions()->GetReligiousMajority();
				if(eMajorityReligion == eReligion)
				{
					iPressure += GC.getGame().GetGameReligions()->GetAdjacentCityReligiousPressure (eMajorityReligion, pLoopCity, m_pCity);
				}
			}
		}
	}

	// Holy city for this religion?
	if (IsHolyCityForReligion(eReligion))
	{
		int iHolyCityPressure = GC.getGame().getGameSpeedInfo().getReligiousPressureAdjacentCity();
		iHolyCityPressure *=  GC.getRELIGION_PER_TURN_FOUNDING_CITY_PRESSURE();
		iPressure += iHolyCityPressure;
	}

	return iPressure;
}
 
Yes, I've studied C++ and programmed in it for a while, though it never turned into a professional skill.
I'll look into it, thanks!

edit: if anyone figures it out before I get back from work, feel free to comment your findings
 
Assuming the player is on standard speed and it's NOT a mod:
Holy City provides 30 points of internal pressure to itself.

Normally each city that has a majority religion has 6 points of external pressure for all cities within 10 hexes. In addition though, if it has a trade route for a city more than 10 hexes away, then it will send 6 points of external pressure along the trade route.

Presence of Grand Temple doubles external pressure (from +6 to +12) for both cities within 10 hexes and trade units more than 10 hexes.

If that religion has been enhanced by RT, then it gets a 25% boost before Printing Press and a 50% boost after it for all external pressure (both natural and trade route). This will also stack with Grand Temple.

If that religion has been enhanced by IP, then all references to 10 hexes above get replaced by 13 hexes. This includes cargo routes that are 11/12/13 hexes away no longer providing religious pressure due to them now being within normal religion range.
 
The source code posted above does things like calculate the majority religion in a city or how much pressure there is in a city for a given religion. What it doesn't tell you is how the game calculates how many citizens will follow a particular religion on a given turn.

My assumption has been that, in steady state, the citizens of a city will be apportioned based on the amount of pressure each religion provides. So if three religions each have 12 pressure in a city, then if you let the game go on long enough in that situation, the citizens will be divided up equally among those three religions (because their pressures are equal). If a city gets 12 pressure from a first religion and only 6 from a second religion, then the first religion will have 2/3 of the citizens and the second will have 1/3 of them once you let the game go on for long enough.

A weaker assumption is that the rate at which citizens convert themselves based on pressure is related to the raw amount of pressure provided by a religion. So if a city is getting 6 pressure from a first religion and all of the city's citizens are following that religion, and you convert a bunch of nearby cities in the same turn so it's getting 24 pressure from your religion now, then the citizens will convert to your religion more quickly than if you only converted one nearby city so that it was getting only 6 pressure from your religion.

What I don't know is whether it's tallying up the pressure from each religion turn by turn and then apportioning the citizens according to those totals, although it probably is. If that's true, I also really don't know whether it is doing this as a running total (by which I mean the total pressure incurred over the past N turns) or an absolute total (since the city was built). And I seriously don't know how it factors in non-religious citizens into all of this (i.e., what mechanism keeps non-religious citizens from all converting all at once when the city only has pressure from a single religion in it).
 
The source code posted above does things like calculate the majority religion in a city or how much pressure there is in a city for a given religion. What it doesn't tell you is how the game calculates how many citizens will follow a particular religion on a given turn.

My assumption has been that, in steady state, the citizens of a city will be apportioned based on the amount of pressure each religion provides. So if three religions each have 12 pressure in a city, then if you let the game go on long enough in that situation, the citizens will be divided up equally among those three religions (because their pressures are equal). If a city gets 12 pressure from a first religion and only 6 from a second religion, then the first religion will have 2/3 of the citizens and the second will have 1/3 of them once you let the game go on for long enough.

A weaker assumption is that the rate at which citizens convert themselves based on pressure is related to the raw amount of pressure provided by a religion. So if a city is getting 6 pressure from a first religion and all of the city's citizens are following that religion, and you convert a bunch of nearby cities in the same turn so it's getting 24 pressure from your religion now, then the citizens will convert to your religion more quickly than if you only converted one nearby city so that it was getting only 6 pressure from your religion.

What I don't know is whether it's tallying up the pressure from each religion turn by turn and then apportioning the citizens according to those totals, although it probably is. If that's true, I also really don't know whether it is doing this as a running total (by which I mean the total pressure incurred over the past N turns) or an absolute total (since the city was built). And I seriously don't know how it factors in non-religious citizens into all of this (i.e., what mechanism keeps non-religious citizens from all converting all at once when the city only has pressure from a single religion in it).
It is one of the greater mysteries of the game exactly how pressure is converted to followers, but there is little doubt that some sort of meter that has to be filled is in play - i.e. once you reach a certain threshold of faith, first citizen converts, next threshold second citizen converts etc. - exactly how we need to fill the "food" container for new citizens to grow. Higher pressure will mean that meter fills faster, and hence citizens convert faster.

It is also quite certain that the amount of faith needed to convert a citizen grows with the number of followers already in town - first citizen converts easily, next one less easy, and so forth. This at least is consistent with a missionary typically converting more citizens on first discharge than on second.

Like you say, what is more or less completely unknown is how the game handles multiple religions excerting pressure on the same city. It is commonly seen that a city can have "hidden" followers that are subdued by followers of another religion - for instance, if an city has 10 followers of Catholicism, 3 followers of Protestantism and 2 citizens not following a religion, if you take a Protestant inquisitor to the town, typically you'll see a larger number of protestant followers after the catholic followers have been purged. It is also often seen that using a missionary of one religion will decrease the numbers of followers of other religions, so clearly these two observations show that the faith limit for followers is not independant for the different religions present in the town.
 
If you'd like to view the full source code file I stole that coding from, it's CvReligionClasses.cpp, in C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V SDK\CvGameCoreSource\CvGameCoreDLL_Expansion2. (Windows 7 filepath) Granted, you'll have to download the Civ5 SDK first, which is a tool for modding.

To download it, you just need to fire up steam, select Libraries on the top panel BUT instead of the games section where you access Civ5, you need to be in the Tools section. Scroll down until you find Sid Meier's Civilization V SDK, double-click and let it install. Good luck!
 
Top Bottom