Natural Religious spread

I believe the relevant code is found in CvCity.cpp (CvCity::doReligion, which in turn is called by CvCity::doTurn. Seems a likely candidate).

If a city already has religion, doReligion is does nothing.

For cities without religion, each available religion is checked in turn, I believe in the order defined in GameInfo\CIV4ReligionInfo.xml.

If it is impossible to spread this religion to the city (Theocracy at work), we move onto the next religion.

When it is possible to spread this religion to this city, we check all of the cities of the living players, to determine the probability that this religion will spread from that city to this one. The city most likely to spread this religion is the one that is chosen.

Religion can spread to This City from Other City only if Other City is connected to This City. Connection of cities is determined by the connection of the plots the cities are on. The connection is determined by which players own the plots in question, and whether the two plots are part of the same plot group for either player (CvPlot::isConnectedTo, in CvPlot.cpp). So connections work both directions, when they work at all.

Likelihood of spreading the religion is determined by the religious influence (for this religion) of the Other City, the SpreadFactor for this religion (defined in CIV4ReligionInfos.xml), and falls off from that as determined by a scaling factor which depends upon plotDistance, RELIGION_SPREAD_DISTANCE_DIVISOR (GlobalDefines.xml), and the maxPlotDistance for the map. This number is compared against a dice roll (RELIGION_SPREAD_RAND).

The religious influence of the city is set when it becomes the holy city (HOLY_CITY_INFLUENCE in GlobalDefines.xml), and the amount of influence a city has can be changed by the buildings in it (ReligionChanges in CIV4BuildingInfos.xml).

If that religion spreads to the city, then doReligion finishes. Which means, I believe, that the game is slightly more likely to spread Judaism than the other religions (because the code breaks out of the loop as soon as religion spreads). The Great Jewish Conspiracy at work!

Example to follow....
 
OK, first note: out of the box, the influence of the Holy City and the influence of the Shrine are the same, and there are no other buildings with ReligionChanges. So to get the probability of spreading a religion from a city with a Shrine, you double the probability of spreading a religion without the Shrine (usual warnings about rounding apply).

Second note: plotDistance is "fat cross distance".

Theres a circle around the holy city, where all cities have the same maximum probability of getting the religion on a given turn. Beyond that circle, the probability falls in rings, by integer division; so immediately outside the circle is a ring where religious spread is half as likely as in the circle, then beyond that is the ring where religions spread is one third as likely, and so on.

Out of the box definitions:
HOLY_CITY_INFLUENCE=1
SpreadFactor = 100
RELIGION_SPREAD_RAND=1000

So, roll a die with 1000 sides; if a number less than 100 appears, convert!

So within the circle, we have a 10% chance of converting; the first ring outside that will be 5%, then 3.3%, 2.5%, 2%, 1.6% etc. With the shrine, these numbers double - but with rounding. 1.6% becomes 3.3%

RELIGION_SPREAD_DISTANCE_DIVISOR=100

If you are as far away as you can possibly be, the distance divisor cancels the SpreadFactor, so the probability of conversion is 0.1%

So let's get a sense for how big the rings are. (DISTANCE_DIVISOR * plotDistance)/maxPlotDistance is the important term, and rather than rewriting it over and over, I'm going to call it the ScaledDistance. The actual denominator used in CvCity::doReligion is ( ScaledDistance - 5 ); so you are outside the circle when ScaledDistance > 6.

A generic standard map is 84 plots wide, 52 plots high, and wraps east/west. So the maxPlotDistance is about 73.

On that map, a city 5 plots away would have a ScaledDistance of 6 (100*5/73 = 6.8....), so five plots away is in the circle (10% chance of conversion).

A city 6 plots away would have a ScaledDistance of 8! (600/73 = 8.2...); therefore cities 6 plots away would have a conversion percentage of 3.3%. So the description of rings, while nice, fails a little bit because not all rings actually have any tiles in them.

A city 7 plots away would have a 2.5% conversion rate. A city 8 plots away would have a 1% conversion rate, etc....

The dropoff is going to be steeper on smaller maps. For example, on a map that has a maximum distance of 50 (in other words, a little bit smaller than Great Plains), you drop from 10% at 3 plots away to 3.3% at 4 plots away to 2.0% at 5 plots away - each tile takes you two rings further away.
 
Thanks, So the only way to "Catch" a religion is from the Holy City?

As for the details of connection..Well I'm guessing if its all my culture it connects my cities on a continent that would count as connected.. but how about
My cities on two different continents or with a big gap of unclaimed territory in between?
My city and a foreign city?

do Open Borders/Sailing and Astronomy techs matter?
 
Krikkitone said:
Thanks, So the only way to "Catch" a religion is from the Holy City?

As far as I can tell, from both parsing the code and experimenting in worldbuilder.

As for the details of connection..

It works exactly the same way that connecting a city to the capital works. Roads and rivers, unobstructed coast lines with Sailing, oceans with Astronomy, subject to open borders, blah blah blah.

CvPlot::isTradeNetworkConnected in CvPlot.cpp has the implementation details.
 
VoiceOfUnreason said:
As far as I can tell, from both parsing the code and experimenting in worldbuilder.



It works exactly the same way that connecting a city to the capital works. Roads and rivers, unobstructed coast lines with Sailing, oceans with Astronomy, subject to open borders, blah blah blah.

CvPlot::isTradeNetworkConnected in CvPlot.cpp has the implementation details.

Oh, just a trade network (that's what I thought, but it sounded as if it might be different)
 
OK, first note: out of the box, the influence of the Holy City and the influence of the Shrine are the same, and there are no other buildings with ReligionChanges. So to get the probability of spreading a religion from a city with a Shrine, you double the probability of spreading a religion without the Shrine (usual warnings about rounding apply).

Second note: plotDistance is "fat cross distance".

Theres a circle around the holy city, where all cities have the same maximum probability of getting the religion on a given turn. Beyond that circle, the probability falls in rings, by integer division; so immediately outside the circle is a ring where religious spread is half as likely as in the circle, then beyond that is the ring where religions spread is one third as likely, and so on.

Out of the box definitions:
HOLY_CITY_INFLUENCE=1
SpreadFactor = 100
RELIGION_SPREAD_RAND=1000

So, roll a die with 1000 sides; if a number less than 100 appears, convert!

So within the circle, we have a 10% chance of converting; the first ring outside that will be 5%, then 3.3%, 2.5%, 2%, 1.6% etc. With the shrine, these numbers double - but with rounding. 1.6% becomes 3.3%

RELIGION_SPREAD_DISTANCE_DIVISOR=100

If you are as far away as you can possibly be, the distance divisor cancels the SpreadFactor, so the probability of conversion is 0.1%

So let's get a sense for how big the rings are. (DISTANCE_DIVISOR * plotDistance)/maxPlotDistance is the important term, and rather than rewriting it over and over, I'm going to call it the ScaledDistance. The actual denominator used in CvCity::doReligion is ( ScaledDistance - 5 ); so you are outside the circle when ScaledDistance > 6.

A generic standard map is 84 plots wide, 52 plots high, and wraps east/west. So the maxPlotDistance is about 73.

On that map, a city 5 plots away would have a ScaledDistance of 6 (100*5/73 = 6.8....), so five plots away is in the circle (10% chance of conversion).

A city 6 plots away would have a ScaledDistance of 8! (600/73 = 8.2...); therefore cities 6 plots away would have a conversion percentage of 3.3%. So the description of rings, while nice, fails a little bit because not all rings actually have any tiles in them.

A city 7 plots away would have a 2.5% conversion rate. A city 8 plots away would have a 1% conversion rate, etc....

The dropoff is going to be steeper on smaller maps. For example, on a map that has a maximum distance of 50 (in other words, a little bit smaller than Great Plains), you drop from 10% at 3 plots away to 3.3% at 4 plots away to 2.0% at 5 plots away - each tile takes you two rings further away.

So, uh, decreasing RELIGION_SPREAD_DISTANCE_DIVISOR decreases the range at which religion spreads? It's kinda hard to tell.
 
In practical terms if you want to spread a religion you'd send missionaries to cities furthest from holy city first then work inwards?
 
In practical terms if you want to spread a religion you'd send missionaries to cities furthest from holy city first then work inwards?

When it comes to my own cities I always figured it was best to go from closest to farthest, so the turns spent moving to the more distant cities aren't spent without the benefits of the religion in the closer cities. If you're talking about spreading to the AI I guess the same logic doesn't necessarily apply.
 
Top Bottom