The AI is capable of cheating (perhaps this is not intentional, but simply an oversight in the AI algorithms): it can cast City Portal from cursed land, and it can cast Dimension Door or Fly even when it doesn’t have these spells in its spellbook, or artifacts that grant them (Angel Wings, Tome of Air Magic, Wizard’s Hat).
And I also noticed in battle that the AI enemy always knows in advance what artifacts the hero has that are used in the battle (worn or inserted into the appropriate slots, and not just lying in the backpack), and, accordingly, does not use those spells that could harm it (unfortunately, I can’t remember a specific case, but this definitely happened).
Everything else that is not obvious can be verified in practice.
(Василь Симоненко. Люди – прекрасні)