Based on feedback from Carados and Wien1938, I've made some substantive changes to the AI formations file in two days of serious coding. First, I've removed almost all of the default melee states. Both humans and the AI are capable of handling that themselves, and there were some problems with those and ranged units and hoplites.

Second, I've changed all of the three-line spear formations to be staggered. This will require a diagram.

S = Spear
I = Other infantry
R = Ranged units

So before, it was like this:
Code:
         RRRRRR
IIIII   SSSSSSS  IIIIIII
        SSSSSSS
        SSSSSSS
Now, it's like this:
Code:
                 RRRRRR
                SSSSSSS  
IIIIII  SSSSSSS         SSSSSSS  IIIIIII
That maintains the flexibility of the three-block structure, but helps the AI keep itself from getting flanked so easily.

I've attached the file here. Please download it and give it a try. It'll work with ExRM 3.X versions, though the Illyrians may behave a little strangely. I think you'll find it superior to your current AI formations. I'd also like as many eyes on it as possible. I believe I did it perfectly, and it's showing up in-game now. However, if one of the dozens of formations I altered is bugged, I'd like to fix that. And the only way we're going to find that reliably is if we get lots of eyes on it.

Happy fighting!