What error would let the AI pick Pantheon beliefs as their Enhancer slot?

Machiavelli24

Mod creator
Joined
May 9, 2012
Messages
818
In my Race for Religion mod I am seeing AI players take Pantheon beliefs in their enhancer belief slot. Pantheon, Founder and Follower slots all seem to be working correctly and the enhancer slot is only being taken by a Pantheon belief or Enhancer belief.

Has anyone else seen similar behavior? I'm not doing any dll modding, only changing the XML and the table looks correct when I examine it via SQLiteManager. There aren't any extra belief that are listed as enhancer. Does the game assume that all enhancer beliefs are contiguous rows in the table?
 
Does the game assume that all enhancer beliefs are contiguous rows in the table?
No

Working fine (sort of) for me.

But the Religion Overview screen is "broken" - so is there another mod somewhere that's correcting the overflowing text but at the same time breaking the enhancer belief choice?
 

Attachments

  • RaceForReligion.jpg
    RaceForReligion.jpg
    90.1 KB · Views: 68
I've been able to produce the behavior with only Race for Religion, no other mods involved. As for the UI, Race does not alter it. Much of the Religion UI does not gracefully present the strings in Race for Religion. However for a human player everything functions correctly (as in, they can not take non-enhancer beliefs in their enhancer slot).

I did some more testing and realized what seems to be happening is that AI players are taking the 0th row in the Religion table (a Pantheon belief: "Goddess of Hunting and Foraging" type= BELIEF_GODDESS_HUNT) as their enhancer belief even if another player has legitimately taken the belief via normal means. This result seems to imply that some logic the AI uses to pick an enhancer belief is erroring out and potentially returning a value that gets parsed as 0 being the index of the belief to add.
 
Firaxis do assume that there are at least as many enhancer beliefs as the maximum number of religions that can be founded (which is true in the core game but may be false if beliefs have been removed or the number of religions by map size increased). If there aren't there is a very good chance that belief 0 will be used.
 
There are 9 enhancer beliefs and on a huge map the total number of religions is 7. So I don't think the cause is running out of beliefs. I seem to remember seeing the AI player take an enhancer belief at some point. This implies that what ever is cause AI players to take the zero'th belief isn't always happening.
 
I believe I've figured it out. Let this be a warning, be careful about using negative values in counter-intuitive locations.

I give all enhancer beliefs a negative spread distance as part of a hack to have enhancing a religion reduce its spread distance. When the AI is evaluating what beliefs to pick it assigns a weight to various factors. The negative spread distance has negative weight (which is not something the evaluation code expects). If this negative weight swamps the positive weight calculated from other factors such that the total end weight is negative the belief is not added to the list of candidates. If all the enhancer beliefs end up with negative net weight than the candidate list is empty and the game picks the 0th index belief.

I can probably work around this (with out modding the DLL) by finding a way to artificially inflate the weight of every enhancer belief (probably by having the belief boost a building that can't be built).
 
I'll stick a fix in my DLL ... "for future generations" ;)

Edit: I've removed the code in the DLL (5 places) that only pushes the belief onto the list of possible beliefs to choose from if the score is positive. Given that this list is sorted by score and then one chosen from the top 3, there really is no need for the "must have a positive score" test (in fact, reading the comment further down where it is limited to the top three, it's quite clearly an artefact from a prior reworked implementation)
 
I noticed that comment. It took me a second to parse it because it was a comment responding to another comment.
 
Back
Top Bottom