Ok this is now the official MoM IME overland AI discussion thread :D Thanks very much for bringing this up, I actually started some notes on how I was planning to do the AI ages ago, and have done very little on it since because I've been plugging away at the Java port for 0.9.4, so I'll put down my thoughts so far and we can see where we go from there, because I think we need a good design on how this will work before anyone starts spending serious amounts of time on it.
AI in the game I wrote prior to MoM IME
As background discussion, I'll mention how the AI worked in the game I wrote before MoM IME (which by the way I gave up on because I'd made too many bad design decisions up front which just turned it into an overcomplicated mess... and Microsoft keep changing the DirectX API didn't help much either). The game had an overland hex map which you'd move units around on - if you've played Battle Isle 2 or 3, its quite similar. There were no cities, but there were objectives placed around the map which you'd score points for capturing. You could see all the terrain (i.e. where there were hills, trees, water and so on) right from the start, you could see where the objectives were right from the start, but you couldn't see enemy units - you had to scout for those in much the same way as in MoM IME. So basically you had to simultaneously defend the objectives you already had while trying to capture the others.
Buying units was easy, because while there were crap cheap units and expensive good units, they functioned quite differently to MoM. Different units were good at different things, e.g. guys who were slow moving but with big guns were more suited to keeping still in cover waiting to spot an enemy unit so they could kill him - walking them out in the open to try to capture an objective would be stupid. Bikers move extremely fast but their guns are almost useless, so they're suited to dashing out, capturing an objective, then zooming on to the next objective before they meet heavy resistance. A player with lots of crap units could do just as well as a player with fewer expensive units, you could win on weight of numbers and trying to get a lucky kill shot. That just doesn't work in MoM - hordes of spearmen are never going to kill those Adamantium Hammerhands
In MoM you normally just churn out as many as you can of the best unit you can build.
So the AI in my other game in the most part just bought random units, which gave it a good mix of offensive/defensive units, which is exactly what it needed. Now here's the important part. In the data for each unit, I wrote a tiny AI script. By tiny, I literally mean it was 3-8 letters long.
"A" might mean "If you can see an enemy, hide and shoot them from a distance"
"B" might mean "If you can see an enemy, rush off in the direction of the closest objective that we don't own"
"C" might mean "Sit still and wait for an enemy to appear and then shoot them"
and so on, so those slow moving guys with big guns would have an AI script of "AC". So there wasn't tons of script writing to, you just wrote a few codes which describe what that unit is good at. Even the most diverse units only had about 6-8 letter codes to describe their actions.
It worked *exceedingly* well. So much so that the AI beat me at least a third of the time. But it worked because you never had to scout aimlessley - if there were no enemy units to shoot, you knew exactly where the objectives were so still had something useful to do. That's a lot different from MoM where you don't know the terrain, don't know where the towers of wizardry are, and don't know where the enemy cities are. The overland AI in MoM IME is going to have to be a whole lot more complicated.
What I don't want to do
I don't want to have to write complicated scripts for each type of race, city or unit. MoM IME is customizable - you can add new races, buildings, spells, units, everything. I don't want modifying any of these to break the AI. So for example if you wrote a script for Klackon cities, but then someone decides Klackons are underpowered and for example allows them to build war colleges which then allow them to build some new super powerful unit that completely changes the Klackon strategy, and the Klackon scripts would then need rewriting. The AI should be clever enough to notice that Klackons can build the super powerful unit and utilize them as such, or in the unmodified version, realise that Klackon units are crap and not build them - we shouldn't have to script it to tell it all that - otherwise as you pointed out, you end up with a LOT of scripts to write - which I don't believe is the right approach.
Now, if you need to do like in my old game and write a *tiny* piece of script for a unit or a race, that's perfectly fine, because it isn't going to take much time to write those, and they'd be easy to change if someone did significantly alter the game balance enough that the AI would have to play differently.
MoM IME overland AI ideas so far
My attitude towards design and coding is that I don't have to know what steps 4, 5 and 6 are to know that steps 1, 2 and 3 are the right thing to do. And normally, by the time I've written 1, 2 and 3, it becomes increasingly clear what 4, 5 and 6 should be. So this isn't fully through through yet, although now I'm writing all this out it actually seems to fit together better than I thought :) Overall I feel the aim should be to get the AI to play like a human player, so I try to think about the way I decide what to do, and then try to figure out how I can teach the AI to make the same decision.
What the AI needs to do is:
1) Decide what spells to research
2) Decide buildings to build in each city
3) Place new cities
4) Decide how much defence is required for each of its cities
5) Scout
6) Build unit stacks to go attacking with, and work out where to attack
7) Decide the likelehood of winning a combat (don't attack if we're just going to get beaten up!)
8] Decide spells to cast overland
9) Decide allocation of magic power to mana/research/skill improvement
10) Use Alchemy when appropriate
11) Diplomacy
(1) is already done in 0.9.3, and I think it works satisfactorily enough. I basically tagged the more useful spells, so the AI picks spells to research randomly, but still tends to pick the better spells first.
(2) is also kind-of-done in 0.9.3, but needs revising since now it'll have to weigh up whether to construct buildings or units.
(3) is easy, I've got code already for deciding where are the best places to put cities.
(4) thru to (7) is what I'd like to do for 0.9.5. Worry about spells, magic, alchemy and diplomacy later.
Unit strength, friendly zones and city defence
In MoM you can't just decide city X needs better defence and build those units at city X. City Y might have an amadamtium deposit, war college and more production. On the other hand, if city Y is on the other plane and on the other side of the map, it isn't much good to us. So what I was planning to do is to get the AI to paint "friendly zones" by finding all of their own cities which are close enough together that you can reasonably expect to be able to walk units between those cities without them being ambushed. The city that can produce the best units within a friendly zone is designated the troop factory for that zone, and would be used to build defensive units and distrbute to the other cities that needed more defence, and to build attack squads. There might be multiple troop factories within the same friendly zone. Friendly zones can extend across both planes if they include a tower that's under our control. Once there's diplomacy, the AI would consider enemy units entering one of its friendly zones as a hostile action.
Unit ratings be calculated from the attributes (e.g. melee attacking rating) and skills (e.g. Fire Breath 3). Coding a value in to say e.g. Spearmen have rating 10, Swordsmen have rating 20 just isn't appropriate to MoM - if someone casts Lionheart on those spearmen, they suddenly become much better than the unimproved Swordsmen. So the unit ratings have to be calculated on the fly. Probably this will involve assigning a value to each melee point, ranged attack point and so on, and defining that for example "Fire Immunity" improves the unit quality rating by +15.
City ratings will be calculated from the size of a city, its buildings, and its terrain (cities with adamantium deposits or containing a wizard's fortress are WAY more valuable than any others). City ratings will be used both for the owner to decide how heavily they need to defend the city, and to decide which are the better targets when choosing which enemy cities to try to capture, and it will tend to put less defence in cities that are a long way inside our friendly zone (since its less likely someone can sneak an attack force that far in without us noticing... unless they're clever and use e.g. Planar Travel). Nodes and Towers will be defended in much the same way as cities.
So that I think gets us to the point where the AI can decide if a city has enough defence, if not figure out which troop factory to build more units in, get them built and send them over to the city. With some modification it will also do (7) - except now the unit ratings will be clever enough to know that for example "Fire Immunity" is MUCH higher rated when the enemy has units with lots of fire attacks than when they're just a bunch of halbardiers, and for example Pikemen are MUCH higher rated against enemy units with First Strike - so the unit ratings will take into account the actual type of enemy units.
Scouting and attacking
I think its also most of the way there for (6). The city ratings of enemy cities will tell the AI where to attack. Comparing our vs their unit ratings will tell us how big of a stack we need to build to have a reasonable chance of success.
Scouting shouldn't be too hard, just get some spare units who are preferably fast, and preferably can see >1 square, and wander around the blackness (especially coastline).
What's going to be really hard is: Using ships (loading units and shipping them to different islands), and getting an attacking force not always necessarily attack an enemy via the predicable straight line route... to try to make sneaky flanking attacks in the last place you'd expect them to attack (the AI in the original MoM was particularly bad at this - it used to just send droves of units in via exactly the same route every time).
Well... that's certainly my longest post ever :) Would love to hear your thoughts on how I was thinking to do this!
Thanks,
Implode.