I am just starting to scratch the surface of AI. First, I thought I would figure out the game scoring system. Nothing directly related to AI but interesting nonetheless. Wralth gave me some big tips of course. Okay, I got the simple scoring system figured out and I can make it give a more sensible score. I've done that in a test mod. Then I looked at the value aiforce for each unit. Often they are more or less the same as the score value but not always. I rationalized aiforce values from the perspective of my test mod. It didn't seem to change what the AI did so far as I could see. Hmmm, what are the aiforce values used for exactly? Okay, next step might be to find how the the AI decides whether to build a pike or a musket. Also, I wonder how it decides what building to build next. So much to find out. Any thoughts or hints would be good.
Update Okay, I am reduced to talking to myself about AI. (1) The only place I can see aiforce used is in a routine that looks like it calculates the aiforce of a formation based on the aiforce of its troops. Makes sense I guess. (2) I have figured out how the AI decides to build a pike or a musket in the 17th C. There is a routine that looks at whether a nation is Algeria or not. Based on that, it decides when to build pikes, when to make some muskets as well and when to switch totally to muskets. The timings are based on how many free pikes plus pike guards have already been made. I have also found the random routines where it decides whether to use a nation's unique unit(s) or not in game (3) I have not figured out how it decides what building to build next. I think it just has a set list somewhere or a few lists based on starting resources. (4) I have found how it sets its first market trades based on starting resources. These are hard coded trades. I haven't found yet how it makes later trading decisions. What do we notice about all this stuff above? Well, we notice that it is scripted, unvarying and totally non-responsive to enemy actions. It is also wrong-footed by mods which change parameters. An AI has to be responsive to enemy actions, responsive to parameter changes and responsive to the unforeseen to have any chance at all of being a worthwhile AI. I am looking at these matters but I am not a good programmer. I have some ideas for a true AI but as I start put these ideas into a "design document" I realize how tough this is to figure out. Don't know if I will make any real progress but it is an interesting puzzle. Any inputs would be much appreciated.