I have a few questions over a couple of the entries in the config_ai_battle file:
1.The formed percentage value here is quite important as it dictates the priority the AI will assign to keeping its attacking line in formation as it approaches your defensive position. The reason I'm mentioning this is because a value of 20 is quite low and will mean missile units going further ahead and siege and slower moving units lagging somewhat behind. When I used to mod Med II I had changed this value to 80 and got really good results with it. This meant the missile troops would stay closer to the main force during the initial advance (normally the AI likes to sprint its archers and skirmishers way ahead of the main line). It also prevented the AI from letting its slower moving troops lag too far behind (pikes, halberds, siege). Your mileage may vary of course, but it's maybe worth investigating.<attack-battlegroup>
<tracking-tolerance>50.0</tracking-tolerance>
<formed-percentage>20</formed-percentage>
2.I found this value to be critical as well, but for the opposite reason of above. When an AI force defends and is defending a position, it can sometimes get over-fussy continuously reforming its missile units - particularly if there's a mix between shorter range skirmishers and archers. If too many stray from the battleline, the AI will spend most of a shoot-out time reforming! Presumably this is more critical while the AI is defending because the AI's other non-missile units aren't also moving/advancing and the human's 'attacking' units are moving, and are thus able to drag the AI's defensive line about more. There's also impassible terrain which can complicate matters further. Anyway, the short of it is that the AI can get rather obsessed reforming its missile troops when it should be shooting. The most effective value I found was to set this to 25, but again it's certainly worth checking yourself. Your value of 40 is probably ok and is certainly better than the vanilla value of 80.<defend-line>
<formed-percentage>40</formed-percentage>
</defend-line>
Some food for thought. Next, pikes.