As some of you may be aware, I've been building custom units for a faction I'm working on. I'm glad to announce that the AI seem to have no problems building such units, as long as you remember to include a <Class> tag in the unittype.This is a completely new step from E:wom, where the AI would simply design terrible units on its own and build only those.
For example I had a particular custom unit that would unlock at a certain tech, and cost a special resource, and didn't hold any apparent military value in itself (low hp, att, def). I couldn't get the AI to build it. But after I used <Class>Defender</Class>, one of the class tags for the pre-designed unit designs for the vanilla faction, then the AI started using the design.
There are also other classes, like <Class>Archer</Class> and <Class>Horseman</Class>. So my guess is this class-tag is actually telling the AI what kind of unit it is. It is logical to assume that the AI also has some sort of mechanic that gets decided per game, so they can for example train extra amounts of archers, or mounted units, if the AI preferences say so (see AIMilitaryStrategyTypes.xml).
Full list of the classes currently in-game as of 0.77 beta
<Class>Defender</Class> (early defending unit, has a shield. Probably upgrades all the way to the endgame)
<Class>Peasant</Class> (starting unit, does not auto-upgrade into armor or weapons)
<Class>Horseman</Class> (its mounted. duh)
<Class>Light</Class> ("warriors", quick to train, good in early game, only has a 1handed weapon and apparently no shield? no weapon upgrade)
<Class>Medium</Class> (medium melee, two-handed weapon that doesn't upgrade. Note - all medium class are specially designed, like "Battleborn" for trogs)
<Class>Baron</Class> (heavy melee, twohanded sword that doesn't upgrade, but it starts with Greatsword which is one of the strongest weapons)
<Class>Scout</Class> (scout. quick mover, bad att/def)
<Class>Spearman</Class> (description says well-suited to fight armored enemies)
Now, I have no idea how these are used by the AI - ie, does it build spearmen if the enemy builds defenders? I doubt that. More likely, these are groups for randomness. I think the AI just chooses a class at random, then selects a unittype that has the class and it can build. It is also likely to assume that it abandons some classes later in the game, such as peasant class and light class. But that's an assumption.