I just went through the AIchooseProduction function in cvgameutils.py, which handles AI production now in almost all cases if I understand the code correctly. Sometimes it appears that this function gets bypassed. It would be nice if anyone could explain why this happens.
There are some very huge flaws in that function, most notably:
A lot of stuff is missing, so the AI will never produce the following unless in the very rare cases that the function gets bypassed:
1)All rituals, so the AI will only extremely rarely build the Pact of the Nilhorn or any of the Illian related Auric progression path.
2) Several lategame units: All nationals (Knights, Beastmasters,Crossbowmen), Muskets, Horse archers.
This means the AI will build the lower tier units and upgrade them. Since they get a huge discount on upgrades at all levels (75% on noble, i. e. the AI pays only 1/4th of what a human player pays) this is kind of an exploity strategy.
3) All ships apart from workboats.
4) A few world wonders: Bone palace, the pillar of chains has a value of 0(meaning it never gets built), which is bizarre as it's one of the better wonders.
There is also some code at the beginning that aims to prevent the Sheaim from building Pyre zombies as primary city defenders, because they don't function as military police. This check should be modified to also include warriors if the city can build any other kind of troop, as the AI will simply upgrade all warriors to Pyre zombies anyway.