Hi guys, so I'm trying to improve the battle AI of my game, so for those who haven't seen my previous post the battle system is similar to total war (meaning you command groups of soldiers)

So my AI so far is pretty simple:
I just split the map into sections and each section has 5 vars(Infantry/Spears/Heavy Inf/Ranged /Cavalry) and it gets the values by the units that are near them.
So eg. a cavalry regiment will prefer to attack high infantry and ranged numbers while avoid spears and will go to the optimal section of the map to attack.

But all this is just a guided slaughter, do you have any ideas to improve the AI??

This is a complex issue of the number of available states. There isn't really an easy answer. What you may what to do is prepare a list of preferred... attitudes. So say you have cautious AI, aggressive AI, lazy AI. And then you program their behaviors.

So a cautious AI would always send scouts ahead and would only take fights in which the losses would be minimal. An aggressive AI fire nations the whole game up and just attacks others indisciminately, attempting to overcome with superior numbers and power. And a lazy AI just does random moves, some of which might not even make sense.
There are several ways to tackle this. To make your life simpler (and to keep this answer short), here's what I've successfully used in the past:
  • Simple approach - Use a simple Finite State Machine: Link
  • Complex approach - Use a Behavior Tree: Link

In your case, I'd recommend starting out with a FSM. Get one rolling and show us your results. If you have any questions, just bump this thread!

PS. Neat read: Link