Suddenly realized that I can't clearly explain when the computer-controlled hero leaves the castle and when it doesn't.
[Heroes 3] University: Lecture 1. Sieging a City
[Heroes 3] University: Lecture 2. Using Computer-Controlled Hero Priorities on the Battlefield
The first one discusses how the AI decides in battle: whether to leave the city or not.
Dandy promises to continue the series, so check out his channel.
(Василь Симоненко. Люди – прекрасні)