1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

AI Favorite religion

Discussion in 'Civ4 - Better AI' started by DrakenKin, Jan 26, 2010.

  1. DrakenKin

    DrakenKin Prince

    Joined:
    Jan 8, 2010
    Messages:
    461
    Location:
    Montreal
    This is in part a question about how the AI works, and another part a suggestion on a possible AI improvement.

    Question

    I can see that each leader has a favorite religion, but I am wondering how this mechanic works in practice :

    1) Do they have to discover the religion to switch to it? For instance if I discovered Islam and have the holy city, will Saladin convert to Islam even though he used something like buddhism for the whole game?
    2) Does it make a difference if he founded buddhism or someone just spread it to him?
    3) Does switching religion to the favorite one depend on the number of cities where it is present? Again in the saladin example, do I have to significantly spread it to him so he can switch or will a couple of cities suffice?
    4) Does it take into account the possible income loss (if Saladin has the buddhism holy city) from switching to the favorite religion?
    5) Does it take into account that switching religion can alienate it towards other AIs and possibly even start wars by becoming the worst enemy of someone? (the diplomatic situation)
    6) Will it switch by itself eventually or do I have to ask for it through the diplomacy screen?
    7) Do I get extra diplomatic points if I have an AI's favorite religion? (Again if Saladin is a Buddhist and I have Islam as state religion)

    I want to use the favorite religion factor to my advantage in game and thus it would be great to know as much as possible about how it works.

    Suggestion for better AI

    FavoriteReligion is obviously a simple roleplay addition to give the different AIs some personality... It is an arbitrary choice at best and in order to provide a better challenge it should mimic an experienced human player that chooses his religion (or lack of) rationally.

    I am not familiar with the AI programming, so my apology if it is already doing this... But if it isn't I think the FavoriteReligion variable should be disabled/ignored at higher difficulty levels (I suggest monarch+) entirely. Or even better the AI should switch its own "FavoriteReligion" to the religion that would best serve its interests taking into account factors like diplomacy, its desired allies, and the military power situation.
     
  2. Lone Wolf

    Lone Wolf Deity

    Joined:
    Dec 4, 2006
    Messages:
    9,908
    FavoriteReligion tag is the religion AI will choose when "Choose Religions" is enabled. Nothing more.
     
  3. DrakenKin

    DrakenKin Prince

    Joined:
    Jan 8, 2010
    Messages:
    461
    Location:
    Montreal
    I don't understand... Isn't religion enabled in all games?
     
  4. Lone Wolf

    Lone Wolf Deity

    Joined:
    Dec 4, 2006
    Messages:
    9,908
    There's an option "Choose Religion" that allows you to choose your religion when discovering a religion-founding tech.
     
  5. Yared

    Yared That Guy

    Joined:
    May 21, 2009
    Messages:
    4,516
    Location:
    Hufvudstaden
    It's a code included in each AI's XML file.
     
  6. DrakenKin

    DrakenKin Prince

    Joined:
    Jan 8, 2010
    Messages:
    461
    Location:
    Montreal
    So are you saying that the AI only switches to a religion it founded itself?

    So if I am in a game with both saladin and mehmed all I have to do is race to islam and they will both be "religion homeless" and keep using the buddhism I spread to them for the whole game, having no reason to switch to something else?

    Any idea which AI file I should read to see how religion switching works exactly? (not sure I can understand it, but i'll give it a shot.)
     
  7. Lone Wolf

    Lone Wolf Deity

    Joined:
    Dec 4, 2006
    Messages:
    9,908
    No.

    I'm saying that if the custom option "Choose Religion" isn't enabled, the FavRel tag has no effect.

    That custom option allows you (and the AI) to found, for example, Islam with Monotheism, Christianity with Divine Right, etc.
     
  8. Still_Asleep

    Still_Asleep Warlord

    Joined:
    Apr 5, 2006
    Messages:
    152
    Location:
    Vienna, Austria
    AI's DO NOT have a favourite religion in a normal game. All religions are treated equally by everyone.

    If you check the option "choose religion", you will be able choose which religion you found whenever you are first to discover a religion-founding tech. For example, when you are first to meditation, you wouldnt automatically found buddism but the game would let you chose. And if the AI can chose in this way, it will take its favourite religion, thats all.

    To your questions:

    1.) AI will use the religion it has present in most cities. It will only switch if another relegion spread more than their original one within their empire, or if they founded a new one and it spread as much as the old one. In your game, Saladin is Buddist and therefore loves Buddism, why would he change?

    2.) AI will always use a religion it founded IF it spread at least as much as any other.

    3.) There is no constant favorite religion :) He loves Buddism because he uses it, and you will have to spread Islam to more cities than he has Buddist cities, then he might switch. But that wouldnt help you unless you use Islam yourself.

    4.) There is no income loss. Shrine = 1 gold from every city with the religion present, doesnt matter if it is statereligion in those cities or whether anyone uses it as statereligion.

    5.) No. AFAIK the AI does not care about diplomacy when it switches religion. But you have to use a certain religion yourself in order to ask them to swap to it(and they will say that not enough of their people believe in it unless it spread wide enough).

    6.) As stated above, they will swap if it is the most spread, eventually. Or close to most-spread if they control the holy city.

    7.) Saladin is Buddist in your game. Every AI's favourite religion is the one they are using. They love you when you use the same one, thats all.
     
  9. DrakenKin

    DrakenKin Prince

    Joined:
    Jan 8, 2010
    Messages:
    461
    Location:
    Montreal
    Thanks for all the clarifications, it seems I was way off track. :p

    It still might be a good idea to teach the AI how to switch religions tactically for diplomatic reasons like a human player would.
     
  10. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    People seem to be spreading some misinformation on this thread.

    The AI's favorite Religion plays into a few different calculations:
    • Tech Choices. If the AI sees that a tech gives them a religion & the religion is their favorite, they will wieght that tech higher.

    • Religion Choices. The AI choose their best religion based on a number of factors (like how many others have it [Yes, the AI considers how many other players have the religion as well], how many cities have it, etc...), but the wieght for the religion is increased by 20% if it is the AI's "Favorite Religion". So the AI will tend to like their favorite religion more, but not in excess.

    You can look this all up in the SDK, in CvPlayerAI.

    Those are the only two things the "Favorite Religion" tag effects, other than the Choose Religion option.
     
  11. Still_Asleep

    Still_Asleep Warlord

    Joined:
    Apr 5, 2006
    Messages:
    152
    Location:
    Vienna, Austria
    So basically Saladin has a 20% increased chance to switch to Islam compared to Christianity in any given game?
     
  12. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    Yes, exactly.
     
  13. Yared

    Yared That Guy

    Joined:
    May 21, 2009
    Messages:
    4,516
    Location:
    Hufvudstaden
    I don't think every leader has a fav religion, though.
     
  14. JujuLautre

    JujuLautre Deity

    Joined:
    Apr 9, 2007
    Messages:
    3,112
    Location:
    Kansai, Japan
    Just a few of them don't have one. Shaka, Gengis, Stalin... Not nice guys usually :D
     
  15. Ahovking

    Ahovking Cyber Nations

    Joined:
    Jan 12, 2010
    Messages:
    807
    Location:
    In Your Phone
    AI only switches to a religion if it founded it, or the first religion which expaned in the AI Nation
     

Share This Page