posted 11-06-20 05:48 PM CT (US)   
This article is for data modders who want to make their mod ai-friendly in hope that a good AI or collection of AIs will be incorporated in first release or in a subsequent one. If you are not a data modder but rather a graphics modder, then you do not need to read this article. If you are not interested in covering AI, then do not read this. I believe that a data mod is an umbrella project and its creator does not necessarily have to possess strong knowledge in the 4 key areas of Graphics, AI, RMS and Scenario. But a basic understanding of all 4 of these areas is crucial to make the mod friendly for creators. All I want to do with the present is to help the modder better in the AI area: better in communicating with the AI creator, better in attracting AI creators, better in avoiding early “mistakes” that would take a lot of time to fix later.

Being an AI scripter for a long time, having dealt with numerous mods and seeing how hard it is for otherwise excellent mods to have a quality AI collection, I decided to take this initiative and append to all modders who want their umbrella projects to attract creators, in particular AI scripters. Of course, certain mods are easy for AIs while others are a real pain. I would never ask the creator of a mod that is very hard for AIs, such as Age of Chivalry, to change his plans in order to make his mod more AI friendly. Only he knows what he wants for his mod, not anyone else. But there are ideas that help in this direction without altering the character of the mod.

-I asked various AI scripters that dealt with mods: what was the hardest challenge?
They all agreed that it was unit IDs. I gave them a preliminary version of this article and some of them asked me to emphasise more on this exact problem. So I will discuss it in more detail further down in the present article.

-Do not shuffle things around constantly. I know, a modder needs to play with his creation. Very often key things are changed for reasons of balance or for gameplay reasons. I can tell you that an AI scripter needs to know the game pretty well in order to create a good AI. It takes quite some time to study a mod that radically changes many things and learn it well enough to guess which strategies and units are viable. If you change key things very often, the AI scripter will be driven away in frustration.

-Create a gameplay guide for users. The AI scripter will certainly read it and he will benefit. If you prefer, only share such a guide with AI scripters and do not include it with your generic upload.

-Create a list of constants in the form of (ideally) a .per file, but a simple .txt could do it. Certainly not a PDF. This could help RMS scripters and scenario makers as well. If an AI scripter gives you a modified list of IDs (which will 100% be in the form of a .per file) you should adopt it after a check for errors and include it with your uploads.

-Inform any AI scripters of potential challenging issues. For example, a civ cannot gather sheep but rather garrisons them. Or a soldier belongs to a different unit class than the traditional ones. Class 29 for example do not group with double click and if you somehow have them all selected you cannot move them somewhere. The AI maker needs to know such issues. Challenging issues are also new maps with too little wood or space, or new units and buildings that civs cannot normally build.

-Inform AI scripters of future plans, for example new civs or units. Try to give them a preliminary version to help them work on AI. This preliminary version does not need to have proper graphics: give them something with proper .dat and .exe and replace your graphics with whatever graphics you want. This way you do not risk being ripped off your graphics too early, and the AI scripter has his time to work.

-Do your schedule wisely: the most time consuming things in a mod are graphics, AI and scenario, perhaps in this order. While you are working on the graphics, the AI maker can work on the AI. It really takes time! Search for AI makers early.
For a rich mod, a development period of 1 year is typical. Often it takes more but let’s say that there is a realistic schedule and that it includes 1 year from initiation of development till version 1.0 upload. This schedule should try to compress the period until the solidification of key gameplay changes (for example, different cost for feudal age upgrade, availability of certain units in dark and feudal age, the presence of very atypical civs, different costs for farms, TCs or villagers, availability of market for selling since dark age, units with extra pop cost) so that the AI scripters can start working already. While AI is in development, it’s ok to have a working mod with replacement graphics. The AI scripter only cares about the data.

-Give the AI maker some recorded games, together with the correct .dat and .exe for each game. He will certainly study them and see how humans try to play the game. Inviting him to play a game or two is also a good idea.

-When making the Userpatch installation for your .exe, press CTRL+F5 and a new tab of features will appear with the title Restricted Features. There you can check which features you need, but an AI scripter would certainly just LOVE to have the 2 features to the bottom starting with “Rec/Spec”: one displays market selling/buying and the other displays current researches. These do not work in the actual games, except when (guess what) there are only AIs playing! So the AI scripter can have his AI in a game 8 times and watch for bugs simultaneously in all. I strongly suggest selecting these 2 features. PCM mod is the only mod that has them by default, check it to see how they work.

-An immovable object should have a rectangular shape that covers fully all tiles it lies upon. An item with radius 1.8 in one direction will trick the AI to think that the edge tiles are unoccupied. Pathfinding may then suffer, while (most importantly) the fact (can-build-line) may be true for AIs, which then try to build the building on the specified tile indefinitely, thus blocking their entire build orders. So always choose size (“radius”) to be 0.5*n, where n positive integer.

-Attempting to make an irregularly shaped building with the use of protruding annex units will only mess up AI pathfinding (even human AI may suffer).

-While Voobly is very popular for users (and I suggest all UP1.5 modders to upload there as well), it is VERY unfriendly to creators. Make sure to have a typical installation .exe uploaded at AOKH and perhaps also ModDb. ModDb is more popular, but AOKH is more practical. These 2 places should have the same proper installation: it should move everything to \Age of Empires 2\Games\ and include a proper .xml and .exe. If you have uploaded a Voobly installation somewhere outside Voobly, PLEASE make sure to notify that it is a Voobly installation, or it will overwrite stuff and someone will be frustrated. Remember to include information with your installation: the .per and a strategy/gameplay guide for example.

-AI scripters take breaks from AI scripting. An AI is comparable in complexity to a mod: a single change somewhere may need several modifications elsewhere to not break something. This does not allow the AI maker to work for 10 minutes today, 30 minutes tomorrow etc. He needs an hour or two every time he sits to script something. Anyway, for whatever reason, AI scripters take their breaks. Keep that in mind when working with them.

-Give proper credits, especially to graphics creators. This will help you maintain good relationships with the modding communities (remember that most modders are also graphics creators and they are very sensitive to plagiarism). Having interaction with other modders will make you better and is something to be desired. But also AI scripters want credit if someone takes and modifies their AI. A typical request for permission is advisable beforehand.

-Remember that a modder does not need to know how to make graphics, AI, maps or scenario. He only needs some basic knowledge on these areas.

Now, specifically about the Unit ID problem:

-From the very start, be careful with UnitIDs and ResearchIDs. If your mod is an expansion mod, you should, of course, not touch any existing IDs. You should start your unitIDs from a high number such as 1450, to leave room for all DE units, including the unavoidable civ expansion that will come. Now, why on earth would a modder who works on UP1.5 care about DE? The answer is simple: there is a chance that an AI for DE can, with minor modifications, become able to cover this mod. You want to leave all options open, especially since a mod should ideally have multiple AIs and not just one.

-If your mod is a conversion mod, then you should try to replace existing units with their analogous ones. Here, there are 2 cases: before DE it was impossible to add unit-lines, while the JSON file in DE allows anyone to create custom lines. So, for UP it is very important to put new units in the place of the correct old ones. If you have a basic archer, with 4 levels, you replace the 3 archer-line IDs and you add a 4th ID in the 1450+ ID range.
(unit-type-count-total archer-line < 40); this covers archer, crossbowman & arbalest
(unit-type-count-total imperial-arbalest < 40); this only counts the last upgraded unit

Now, the same mod can have 4 units in the militiaman line. There is no 5th unit. So, leave the ID of the Champion intact. Leave him there. Why not just remove him? Because certain scenarios and maps may need this unit. It is better to have an out-of-place unit in a scenario or a map than to have a crash. Much better. Yeah, people use the same maps and even scenarios in various mods.

-Now, what happens if your mod has 5 archers in the line but only 3 swordsmen? Well, if your mod is very close to standard in terms of gameplay, you should prefer to put the 3 swordsmen in the militiaman line and leave the final 2 slots empty. This would allow unprepared AIs to play the mod with minimal work. If, however, your mod changes gameplay too much, then unprepared AIs will be unsuitable for it and it would be better to fit the 5 archers in the 5-slot militiaman line.

-Unit IDs over 2000 can cause crashes when they are trying to target something. The limit for DE is even lower, with some people mentioning 1720 as the limit. In any case, any extra objects with some importance should spend the lowest available unit IDs (starting from 1450 for example) and neutral objects such as eye candy or birds can go as high as desired (over 2000 for Userpatch is safe). This is a very recent discovery of mine.

-The 900-999 range of IDs should be left empty or be filled with neutral objects that the AI will never count for any reason. If an AI tries to count unit 912, it counts cavalry class instead! Basically, when you add 900 to the class ID as you see it in AGE, you get a wildcard for counting all units of this class. But an AI will never try to count a bird. Well, ok there might be a rare use of birds for boar stealing but I doubt anyone will ever care to code for this.

-A list of units/researches and their IDs should ideally be included with your closed betas that you share with AI scripters. For the 1.0 version it is very important. A .per file is enough for AI scripters. When testing the unit IDs, do not do so in scenario because some things are (weirdly) different in scenarion than in rms/regicide/whatever non-scenario game.
With your list you could include the list of civs. An AI scripter can take them from the xml, but it is cool to see them there already.
Extra resources used as unit limits or for whatever innovative reason should be included. An AI scripter that works for mods, he has AGE open when scripting but AGE is not his specialty and he wastes energy to compile the list of units/researches/resources himself.

To help modders reach a better level of understanding the difficulties of making AIs for mods, I will give one example from each of some popular mods I have tried to script an AI for.

-Portuguese Civ Mod: there is a 5th resource, in the place of Ore, called Experience. I was informed of it, so I just used a constant:
(defconst amount-experience amount-ore)
and I keep track of it.

-Age of Chivalry: Blacksmith researches do not affect whole classes like in vanilla. Instead, there is, for example, Heavy Armor, that affects units belonging to both infantry and cavalry classes. At the time I was driven away because of this simple challenge, but as Userpatch evolved I now have the tools to keep track of any units I want so I will revisit this mod.

-Age of Vampires: certain civs depend on training and slaughtering sheep instead of farming. But an AI cannot auto-target its owned-from-start sheep (including Inca llama). So, for all those civs, the AI had poor access too food and any existing AIs simply failed to play. I made a code that somewhat allows Petersen AI to use sheep.

-AG3: actually this one was the easiest among all. But I had a problem with Chariots. I was confused about them and only after its maker described to me how they are an upgrade of LCav I got it. So I added a simple line to my scout training rules and job done. If it wasn’t so easy, I would never have dealt with it simply because it is a voobly-only mod.

-Tzars and Salesmen: Saxon Miners are extremely powerful there, but the AI cannot auto-task them correctly. So, I added a code that sends them to a not-that-busy gold tile. Its maker used my feedback and experimented with class and tasks to make it as easy for AI as possible, allowing me to achieve a good result despite some suicidal behaviour.

-Age of Realms: there are several very interesting maps with extra features. Its maker eagerly helped to create a list of constants from all the objects and researches for them so I made an AI that plays all of them, perhaps not smartly but at least it does not ignore possibilities.

-AOFE: it had a comprehensive list of constants from start. Its maker maintained a good contact with the AI community, and he eventually made it so easy that most AIs of its time could play it. But I remember the frustration with eagle warriors and other injected units (fire galley for example). Eventually, instead of putting a new ID for fire galley, he used the ID of fire ship, thus allowing unprepared AIs such as Petersen to at least train them.

-ToME: most of its standard maps are a hell for AIs to play. The atmosphere is epic, the gameplay challenging, but this lack of wood, the cliffs and twisted paths, water maps etc. make it practically impossible to make a working AI for most of standard maps. This does not look good for naïve players who want to get a feeling. These maps should be put in custom folder.

-Dawn of Rome: this mod even had a description of its additions (basically a gameplay guide) so it was easy for me to instantly see the potential of Aqueducts. But when I tried to make a code for them, I realized it was not UP1.5 but rather UP1.4. This forced me to skip on the idea for the time being.

If the above seem too much for you, then you can simply choose to do 2-3 of the above in hope that your chances of getting an AI scripter will increase.
You may decide that you will release your 1.0 without a working AI at all. It's your choice and it is fully respected by me, but for the typical player who searches for data mods an AI is very important, even a very weak one.
An attempt to try to make your own AI for your own mod will prove to be an unexpectedly hard challenge if you are not pretty into AI scripting already. I, as an AI scripter, would like to see more people in our community, but honestly this is going to eat up a lot of your time and energy.

This topic of discussion is very broad and somewhat vague. I hope I helped, I hope that we will finally see mods with a collection of AIs for them.
Contributions by others are very much desired.