The main problem with AI is that no matter what you make it is always predictable, and thus it becomes easy to beat once you understand what it is going to do.
Really sophisticated AIs can overcome this. There are AIs called learning AIs with things like genetic algorithms, neural networks, bayesian network inference engines and so on. They actually learn and develop and come up with new plans. I have to say up front I cannot program anywhere near such complex stuff. At a pinch, I could start beginner work on genetic algorithms but it would take me a long time to learn even them.
At my level, I would aim for a basically sound set of Economy and Military algorithms. Within that hopefully solid framework, I think I could work in some "timing window attacks" and "probability attacks". The engine can be given a set of possible "timing window" attacks which it might make if it assessed conditions were right. It can react to how the enemy plays and this will give it variety in play.
For example, if its human opponent attacks it early on and non-stop, it will be programmed to defend non-stop with technically correct internal lines defense. It will set a program parameter to "defend only". Indeed that will be the initial program setting anyway. After a certain time it will assess (count up) its losses and its opponent's losses. Then it will assess if the opponents losses are greater by a set margin than what the opponent can make up by new production at its base during the traverse time taken by the computer's remaining forces moving to the opponent's base. Thus the computer can calculate it will have more troops at the battle site even when the next battle site is right at the opponent's base. It will also make estimates about possible upgrades on both sides. Based on these assessments it will use simple pseudo "fuzzy logic" to decide if it will attack. For example, it it estimates it will have 10% more troops at the battle site near the opponent's base then there could be a 1 in 10 chance it will make a decision to attack. If it figures it will have 50% more troops then there is a 1 in 2 chance it will decide to attack. These are just examples. Then it can learn by tweaking its own parameters. It will learn and store for example that when I-the-computer attack with 10% more troops I never do decisive damage I will so now set a 1 in 10 attack likelihood only when I estimate I will have 20% more troops at the battle site. When I attack with 100% more troops (double) I always win so reset the "Always attack" level to just 90% more troops and test that.
That's just one example. The computer AI could also be given random chances of trying certain sneak attacks. For example, let it have 50% chance of sending the very first 36 man pike formation (once scouting has found the enemy) down the map side to try a sneak attack whilst reserving everything else for defence for the time being.
These are just a few examples of how assigning attack likelihoods based on numerical assessments and chance generators (varying the chances based on how good the assessments are) can help the AI vary its play. So now its attacks are not blindly scripted but depend on troop estimates, upgrades estimates and a generator which assesses its chances of making a winning attack in a given troop number situation.