Current functions:
ScoreCityforMissionary --> It's what missionaries use for choosing targets. A city gets a better score for being closer, when the owner is not a founder of other religion and when spreading will 'make a dent'.
ScoreCityforInquisitor --> Where it is better to use the remove heresy action.
BuyMissionaryorInquisitor --> It chooses if it is better to purchase a missionary or an inquisitor (or nothing) and purchase it (or not).
BuyMissionary --> Find the city where missionaries are cheaper and purchase one there.
BuyInquisitor --> The same as above.
HaveNearbyConversionTarget(ReligionTypes eReligion, bool bCanIncludeReligionStarter, bool bHeathensOnly) --> Checks if cities in range have a suitable target for missionaries. It can be set to ignore cities that are already converted to the founded religion of the city owner, and to look only at cities without a majority religion.
AreAllOurCitiesHaveFaithBuilding --> Checks if any of our cities can build a religious building.
HaveEnoughInquisitors --> Counts the number of our cities that are following a different religion and checks if we have already one missionary for every city that not belongs to our religion.
Let's try this logic...
STEP 1 Check if we better save faith for a Great Prophet.
// We should prioritize enhancing when there is a rival religion nearby that is taking advantage. We need a function that counts how many cities in range are suitable for spreading, and how many of them are turned to a rival religion. Let's call it NearbyCitiesCanConvert(ReligionTypes eReligion, bool bCanIncludeReligionStarter, bool bOwnCitiesOnly)
__If the number of cities in range that already belong to another religion is bigger than our own cities without a religion, then we are at risk and we need to enhance fast if we haven't done it yet.
// We must enhance in any case once ...
__If all our cities are already converted and the number of potential targets is less than the cities we have already converted, then it is time to enhance.
// Extra GP after enhanced
__If we have any owned city that it is heathen, skip. // Should convert all our cities before commiting to a second prophet.
__If we don't have enough inquisitors, skip.
__If the number of potential good targets is bigger than the cities following our religion, skip. // Easy targets are best with missionaries.
__If we have religious buildings to build, skip.
__// The real choice comes now, should we surrender our religion?
__If foreign pressure in our cities is bigger than local then
____If faith yield is low, then
______surrender religion, no more prophets, or inquisitors o missionaries. Only buildings, great people and military units are to be built.
____else
______save prophets for sacred sites. // Sacred sites increases faith and pressure, so it helps with religious strength.
__else // Our pressure is bigger locally
____If faith yield is high and there are benefits for spreading then
______save prophets for aggressive spreading
__otherwise save for other GreatPeople
STEP 2 Religious buildings
// These usually give extra pressure and extra faith yields and are usually better than purchasing inquisitors or missionaries when are available. The only reason I see
// rushing a missionary over a religious building is to convert a owned city that is not receiving any pressure.
if (!AreAllOurCitiesHaveFaithBuilding) && (pCity->Pressure(eReligion) <= 0) then
__purchase religious building
STEP 3 Inquisitor garrisons
// This is not accounted in any part of the current code. I think we need at least one inquisitor in holy city and one in every city that is receiving noticeable foreign influence.
Make a new function, HaveEnoughInquisitorGarrison, that checks if there are at least the same number of inquisitors than the cities where foreign pressure is at least the 33% of the total pressure, and one more inquisitor for the Holy City.
Then if there are not enough inquisitor garrisons, order an inquisitor.
STEP 4. Inquisitors for duty
// This is what HaveEnoughIquisitors currently does. It should only add an account for the inquisitor garrisons.
If there are owned cities with a different religion that require removing heresy, and current number of inquisitors are fewer than EnoughInquisitorGarrison + one for every city that needs removing heresy then
__purchase inquisitor.
STEP 5. Missionaries
// Question here is when is it time to stop producing missionaries.
If there are no easy targets and there's no bonus for spreading and such (city state quest?) then
__skip missionaries
otherwise
__purchase missionary
STEP 6. Purchasing inquisitors
Look for the owned city that has the highest foreign pressure and has no inquisitor garrisoned
__Look if this city has a foreign pressure that is higher than 33%
__This is our target city.
__Look for the closest city that can produce religious units that has a faith discount or
__if there is no faith discount, look for the closest city that can produce religious units.
__This is our origin city. // It could be the same as the target city
__Purchase an inquisitor in origin city
if no city needs a garrison, then
__Look for the owned city closest to the Holy City that requires removing heresy (ScoreCityForInquisitor can be used)
__This is our target city.
__Look for the closest city that can produce religious units that has a faith discount or
__if there is no faith discount, look for the closest city that can produce religious units.
__This is our origin city. // It can't be the same as the target city
__Purchase an inquisitor in origin city
STEP 7. Purchasing buildings
Just find the closest city to the Holy City that can build a religious building and build it there.
STEP 8. Purchasing missionaries
Look for the best city target (ScoreCityForMissionary can be used)
Look for the closest city that can produce religious units that has a faith discount or
if there is no faith discount, look for the closest city that can produce religious units.
This is our origin city. // It can't be the same as the target city
__Purchase a missionary in origin city
STEP 9. Moving religious units
Begin with the Great Prophet.
If it can enhance, then enhance.
If player has surrendered then use it for a sacred site.
If a city requires removing heresy and there are no inquisitors at all and faith generation is low, then use it for removing heresy.
If the conditions are right for a Sacred Site as seen in STEP 1, then go create it at the converted city that has the lowest owned religious pressure.
If the conditions are right for an aggressive spreading as seen in STEP 1, then find the sweetest foreign religion city
and send the prophet to the closest safe spot to the target city avoiding unfriendly territory.
When the GP arrives at the safe spot, send it to the target city for conversion.
If we have nothing better for it, let it wait in the Holy City until an opportunity appears.
Beginning Atomic Era, any Great Prophet not used could go for sacred sites.
Then Inquisitors.
If a city requires an inquisitor garrisoned and there is no inquisitor on the way, send it there
If a city requires removing heresy, send it there to remove heresy.
If there are more inquisitors than required, let them rest at the Holy City.
If money is negative, go expend one inquisitor to the city with the highest unfaithful citizens,
If that can't be done, remove one inquisitor.
Last missionaries.
Order the best city targets using ScoreCityForMissionary
Take next best city target and if no missionary is on the way, send one there using the same logic as the Great Prophet.
If there are more missionaries than required, then let them rest in the Holy City.
If money is low, go expend one missionary at the best close target.
*Most of the code is already doing this, it only needs a bit of shuffling in the order of the code, and a couple of new functions (garrisons and number of good targets), but they don't look especially difficult.
@ilteroi ,
@Gazebo , what do you think? Is it feasible like that?