What was the rationale? AI loses fights with full Mana that it could easily have won otherwise. I just removed that weird logic and now it uses it's mana and wins.
When defending the AI is now much smarter to use their defensive-structures like walls, towers and the moat to their advantage instead of allowing them to be lured out and killed in the open.
A penalty-multiplier is now applied when deciding which units to walk towards. If an ally is closer than us to the enemy unit in question, we reduce our score for walking towards that unit too. This shall help against baiting a whole flock of AI-stacks to overcommit on chasing an inferior stack of the enemy.
AI will no longer skip turns with heroes that are waiting for a delivery that takes more than one turn. Instead they will do something until their delivery is close enough to get it at the same turn.
Fixed an issue where a bunch of heroes all tried to do the same tasks:
Tasks that involve no fighting will now always be performed by the closest eligible hero while all other heroes look for something else to do.
The AI is now a lot more likely to buy a hero early on when that hero's army is worth more than half the cost of the hero, regardless of other circumstances.
Instead of skipping the defense of other towns entirely when hiring a hero was considered as a way of defending, now only hiring the same hero twice will be avoided.
Just killing stuff even if there is no apparent reason now also is considered for the mere purpose of gaining XP.
This also helps the non-cheating AI to keep attacking enemies when they can't see anything worth exploring behind them.
Fixed an issue that made AI consider unpurchased troops as reinforcements for their armies which caused AI to visit cities over and over without actually doing anything there.
Buying units is handled by BuyArmyBehavior.
AI will now also garrison a hero as defender if the town to be defended has troops as long as the hero can merge their own troops with the town.
AI will no longer just dismiss existing troops in a town if a hero trying to garrison there can merge with it.