This has been a very long and painful road... very long post coming, so up to you if you read all this but wanted to explain what's been going on. Programming AIs in games is by far the most complicated part by far. Most AIs in games utterly suck, MoM being no exception as I'm sure everyone here is well aware (Ascendancy being another really awesome 4X game but completely ruined by the terrible AI). I'd started work on the overland AI several years ago, came up with a plan for how I thought it might work well, after a long effort had something workable and... it was so terrible. The AI wizards hardly did anything at all. I'd put so much effort into it and it was just terrible, and I had no clue how to fix it.
That made me leave the project alone for a while to get a breather and try to understand why. Also, I had a bigger problem. There was another game I worked on even before MoM, which I can't discuss in any great detail because its based on what's still a very active intellectual property, but given when I had worked on it, it was all in Delphi still and worked on peer-to-peer connections from back in the days where we actually had to take our PCs over to a friends house to play games together. Things then moved on, and all games started shifting to a hub-and-spokes model with servers on the internet hosting games, to avoid problems where players started to be behind routers and thus not have public IPs. I tried to convert it to a client/server model, and completely failed to grasp just what a huge paradigm shift this was, made a complete mess of it and ruined the project. And worse, this was before I'd learned about using source control systems at work so I only had sporadic backups with half the code being one version and half the code being another version and no complete backups of it before I wrecked it. But the one thing was, the AI in that game was brilliant. With no cheats (extra resources) whatsoever, it would quite often beat me. So when I'd based the MoM IME AI on it, and that turned out to be terrible, I couldn't understand what I'd done wrong.
But it also bothered me that I'd let me other favourite project sit wrecked for such a long time. I had to get it working again before the spotty backups of things I did have of it fell to dust. I had to understand why the AI in it worked so brilliantly but so terribly in MoM IME. So I started porting the entire thing into Java and client/server. Its not quite as big and complicated as MoM, but still that was no small task and taken me a few years. And in doing so, I got the answers I was looking for - I came to the conclusion that there was actually nothing particularly "good" about the AI in my other game and nothing particularly "bad" about the AI in MoM IME - the differences were fundamentally in the design of the game itself:
- In MoM, you start off knowing nothing about the map, where enemy wizards are, or anything at all. You have to scout around to figure out where to go. In my other game, the terrain of the map is known to all players at the start, as well as the location of all objectives you need to try to capture. The AI immediately knows exactly where it should be going, so that's a lot simpler.
- In MoM you tend to just work on the best unit you can possibly get, be that Great/Sky Drakes, pimped up longbowmen, amandantium hammerhands, or whatever you like, and just churn out tons of them. In my other game, that doesn't work at all. There are no "better" or "worse" units - every unit is good at one thing or another, and if you just buy one type of unit, you will do terribly. You need both scouting units, close combat units, ranged units, and so on - you need a mixture. The AI in that game literally picks which units to buy at random and that's one of things that makes it difficult to play against, as you never have any idea what units you're going to be facing.
- In my other game, each unit is fundamentally of a particular type. A close combat unit is always a close combat unit. A long range attacker is always a long range attacker. So I wrote scripts for every unit in the game that the AI follows to work out what to do with that kind of unit. There are some piecemeal upgrades you can get to units, but they're minor and don't fundamentally change the nature of the unit, so the scripts don't change, and the AI knows how to play every time of unit. In MoM, one of the things we love about it is there's just so much freedom to come up with crazy things to try. A warship would have a script telling it to scout oceans for enemy boats and transport friendly units... until you cast flight on it. Even just a regular unit of swordsmen, if you stick it in a stack with the hero with wind walking, suddenly you need to play it completely differently. You just can't write AI scripts in MoM for each type of unit - it has to be able to classify units itself and assign the right AI script to each unit depending on the unit's capability at the time.
The other difficult decision I had was whether to let the AI "cheat", by getting bonuses to city growth, production and so on. I really didn't want to, because that's something people criticize about the original MoM AI. But the fact is without this, the AI was struggling so badly and boringly easy to beat. The AI is pretty good at deciding where to scout, which lairs it can attack, how big of a stack it needs to attack an enemy city (yours!), how much defence it needs to leave in its own cities - where it struggles is trying to decide the relative importance of all of these - do I sacrifice some defence to make a bigger unit stack to attack with? In the original MoM you see the AI players with hordes of units running around the map, and there's no way that's ever going to happen unless the AI gets some free advantages. So, I tried putting in exactly the same bonuses as in the original MoM (they're documented in the strategy guide) and now... the AI actually has hordes of units running around just like the original. I've been sat just trying to get my city production started, and he's already showing up with stacks of 6-8 units kicking my ass, and that's exactly what I wanted to see :D
A final note about Raiders. In the original MoM, raiders had their own custom rules about city sizes, units in garrison and so on. The raiders cities don't even "build" units - there's a formula about how often, how many, what experience level units the raiders cities just "spit out" without actually building them, and come and attack you. Much like rampaging monsters that just appear out of nodes and ruins. In MoM IME, the raiders are subject to the same economy as wizards - they're really just a wizard player who cannot cast spells. They have to actually build units, pay upkeep on units - to generate units with higher experience, they actually have to build a Fighters' Guild / War College, it doesn't just happen because of some formula. This makes them act a bit differently - in the last game I tested out, I saw it built Javelineers in a Lizardman city, and moved them to a Gnoll (I think) city, so when I attacked it there was a mixed race of defenders, so that was really cool to see. I have not yet actually seen Raiders build a settler and go make a new city, but that should happen too.
That raises some questions about how Raiders should work:
- Should they get the same economy boosts that AI wizards do - currently I've said yes, because again I want to see hordes of raider units running all over the map making things difficult for me, and that's not going to happen if they build at normal rates. (A side effect of this is, much like in the original MoM when you capture a wizard city you often loot a big stack of gold coins - the raider cities in MoM IME now do this too because they are raking in insane amounts of coins).
- Should the raiders player have to scout the map? In the original MoM I'm fairly certain they don't - you never see raider units just wandering around scouting - when there are raider units, they already know exactly where your city is and make a beeline for it. In MoM IME, I think it works better if raiders have to scout around the map to find you first just like AI wizards do.
Also, sorry I am not on being more active on the forum. I just find it too distracting and time I'm on here is time I am not working on writing code and then I never get anywhere with it.