KrikkitTwo
Immortal
- Joined
- Apr 3, 2004
- Messages
- 12,418
Has anyone worked out in detail how this works from the SDK (like exactly which other cities does a city get religion from, and what are the odds?)
Krikkitone said:Thanks, So the only way to "Catch" a religion is from the Holy City?
As for the details of connection..
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.
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.
In practical terms if you want to spread a religion you'd send missionaries to cities furthest from holy city first then work inwards?