We now have a trade screen class (WIP). I wonder if we can add that to CvPlayer and use that for domestic prices. The AI will then trade using those prices, except they will buy at -2 and sell at +2 (or something). We can then use regular unit and building demands to control prices.
Natives can then have different min and max prices, though any player having a demand for a yield he can't produce himself will naturally increase the price quite a lot.
We can then use the new functions to generate a "fake" demand for yields needed for professions. If the AI can use leather armors to make infantry, then it will be willing to buy those and stockpile. They will however not buy scale mails until they invent a profession, which demand those.
Now that I think about it, I think the new yield functions are too simple. To figure out how much the AI wants of each type they should likely tell how much the most expensive profession cost of each yield. It would also be useful to know the power and combined costs if you make one of each profession. That should make it easier to make the AI figure out which yields it wants to buy. For instance it would pick scale mail over leather armor because scale mail results in more power. At the same time leather armor isn't useless and if they are cheap enough, they can come up with the idea to buy lots of them to have many cheap troops instead of a few expensive ones.
I'm not sure if it already does this, but with the greatly added number of professions, it would be a good idea if AI troops check each turn if it can change profession into something with greater power. That way it will replace armor of existing troops when inventing something better.
Yields in XML also needs a cleanup. For instance bIsMilitary is the same as iPower > 0 and as such do not need to be set in XML. bIsMustBeDiscovered is calculated by the DLL on load and the value in XML is ignored. bCargo is also set in XML, yet ignored by the DLL. There are plenty of minOccurs="0", which isn't supported by
Civ4 XML Editor.
Looks like my little task of moving yield groups into XML has turned into a massive task
EDIT: added bIsLightArmor and bIsHeavyArmor to XML and removed the 3 yieldgroups regarding armor. I looked at some of the AI code using armor checks. Looks like the AI looks for YIELD_WEAPONS, YIELD_HORSES and isArmor(). Looks to me like we should replace those with CvPlayer::isYieldMilitaryCost(). That will make the AI dynamically produce and import yields used to make troops and we will not have to hint which yields can be used for this.
I have now removed 5 yieldgroups and we have 7 left. 6 of those are related to trading meaning rather than moving those to XML, it would be good to render them obsolite by implementing a better AI trading system. The last yieldgroup is luxury food. Both Kailric and me have proposed the idea of having it set at runtime to make it change with civics/civilization or something else. Yieldgroups are hardcoded and can't change during the game, which mean a changing luxury food would render that group obsolete.