Battle AI Part 1 - BATTLE PREPARATION

[size=150]INTRO[/size]
This summer I started writing down several ideas on how the battle AI could be improved on the short and long term, as some of the current behaviors (like skipping battle turns just because the access to some enemy creature is blocked, when 6 others are vulnerable) would be better replaced even with something as basic as “attack nearest enemy creature”. However I didn’t get as far as I wanted with my analysis due to time restraints.

Recently though I noticed on Wiki that currently notable efforts are being put into developing the AI, confirmed today by Tow dragon as well. While this is wonderful news, for me this poses the “risk” that the battle AI will be done before I finish my document (on which I was planning to work again only after Christmas, when I will have some time to spare). :slight_smile:

So I thought to better share with you what I already have, unfinished as it is, just in case there’s anything in there that might be of some use.

And because battle AI is a huge subject, probably hard to follow within a single thread, I’m going to split it as follows:
I. BATTLE PREPARATION: to be discussed in this thread.
II. ARROW TOWERS & WAR MACHINES: link
III. CREATURE ATTACKS: link
IV. SPELL CASTING: link


[size=150]Battle AI Part 1 - BATTLE PREPARATION[/size]

This includes two major aspects:
1.A. Pre-battle preparations

This is not battle AI per-se, but actually the meeting point of Adventure AI, Town management AI and Hero management AI, but from the perspective of the battle(s) to come. And it should probably range from short term planning (depending on the imminent attack to follow) to long term planning (depending on the chance of meeting certain enemies in future battles, according with the info AI gets from Taverns and discovered territory). This should include:
o How to Build Armies: purchase/upgrade decisions, caravan exchange
o How to Arrange Army: before each battle, depending on how the enemy arrange its creatures (if attack is expected), battle formation, splits
o Select Artifacts to have equipped during battle
o Planning coordinated attacks with more than 1 hero (e.g.: kamikaze heroes to drain enemy spells and produce minimal damage)
o Fortification choices

(to be however seen if this is a place to discuss the above, or better in dedicated Adv/Town/Hero AI threads)

1.B. Tactics phase

This is battle AI, though I haven’t started to draft the rules for this one yet (to follow).


As you can see above, for this I only managed to list what it should be about. Any rules that AI should actually follow are still to come. But that will not be in the near future from my part, but if anyone is willing to share any information on this, you are more than welcome to do so below. And that can be information of any kind, e.g.:

  • Personal thoughts/experiences/suggestions
  • Ready-made analysis by others that you know of (e.g.: item X already detailed in Strategija from page Y to Z)
  • Known H3 AI flaws that we should handle better

[size=75]PS: If you like the idea of these threads and/or if they catch, I will probably sticky them at a later date (I won’t do it just yet, because I realize there’s a certain chance this effort is actually not necessary at all, given either the coding approach, or very good analysis already presented elsewhere that I don’t know of (in which case though any links shared would be most welcome)[/size] :slight_smile:

But this is just complex as hell, unlikely to resolve with simple algorithm. Real player takes a thousand of factors into calculation. General army development and objective completion is already a part of Trevor’s framework, he proposed to use Neural Network to handle micromanagement and general economy - I believe he’s perfectly right at this point. But when it comes to tactic arrangement, Bonuses are essential. To prepare complex strategy, it is unavoidable to take into consideration all creature and art abilities, as well as hero special. Here Bonus Expert System kicks in.

I probably shouldn’t throw around random AI concepts, so let me just explain what it is. Expert system bases on facts know to player. As major part of game mechanics (creatures, artifacts, heroes, partially towns) is now handled by Bonuses, it is easy to determine tacticla potential of our army. Then, basing on knowledge given by skilled players in form of logic forumlas, Expert System processes the bonuses, changing their values and priorities in the meantime and producing some decision (just as “use Ring of Vitality when average hp of your army is low” or “don’t take Resurrection scroll when your army is undead” etc.

Either way, you need to list a large number of such simple rules (“knowledge”) in this thread so it can be expressed in terms of bonuses (a lot can be) and simple logic. Later it can be stored in configuration files and I’ll prepare parser.

At that point I think the priority is (apart from enebaling adventure AI, that is) investigate HypotheticalGameState and Objective classes and see whether they can server al the purposes mentioned. I may post something on the Wiki soon.