I had an interesting moment when, on a "Heroes of Might and Magic, but not Magic" map with a complete ban on magic, the enemy AI somehow used a magic arrow in one battle.
Yeah, sometimes there are absurd bugs like AI flying or walking on water.
Regarding the Grail, the computer doesn't know where the Grail is hidden. It searches for it based on fragments of the map, as evidenced by the many holes where the computer digs for the Grail.