It shouldn't be beyond the scope of the AI to see "Should I convert to Buddhism? Well, less than 25% of my provinces are Buddhist so no"
Seems there is exactly such a limit but it's set to 1/6 rather than 1/4. Then of course, there are a bunch of exceptions.
I did not come here to debate that code because it's ancient. Rather, I wanted to point out that it's always easy to come up with a specific instance where the AI is behaving badly, and to formulate a rule that would work in that particular case. There are problems with this, however:
- The rule might not work well in other cases that are probably not apparent to you at the time of conception.
- It might not even make sense for development time to be directed to that area, because of marginal effects on gameplay compared to time spent. While the ideal solution to your problem would be to employ one AI Religion Programmer (or more), it should illustrate the resource allocation issue. The biggest reasons for the game being (too) easy to play for veterans include army and diplomacy AI in my opinion, and I'd rather spend time there to the extent possible.