AI Improvement

AFAIK there is no goal switching at all. Each turn goals being evaluated and only one per hero selected to achieve. After that only “wandering”.

I thought a lot I do not want to develop current AI. I do not like GOAP because I do not see for now how it will help. I do not want hierarchical goal decomposition at all but I want goals to affect prioritizing engine instead. Fuzzy Logic looks like a great instrument for prioritization, so I will use it definitely. So I will continue development in my own branch nullkiller/vcmi/ai-rework.
For now I want 4 stages

  • Analysis - get data from game state and represent it in more convenient way
  • Task generation - generate all possible tasks. Here might be some logic to avoid tasks which can not be executed at all. Tasks can consist from other tasks and each such composite task should be executed only as an atomic thing.
  • Task prioritization - use data from analysis stage to properly prioritize tasks.
  • Task execution - get top priority task and execute it.

The branch with exploration improvement can be merged to develop if there is no objections. I will merge it to my branch anyway.

My decision is mostly driven by a desire to build a bicycle so no offence. I will do what I like quietly in my branch and come back if I will see the result. Still I am open to any ideas.

It’s true that the AI needs major improvements because it’s sad to play with an AI that is controlling heroes without armies. Every time I want to capture a town, I just end up cleaning every CPU’s armies just to see them buying ~3 heroes without any troops or taking the castle with too few creatures. Also, they’re just spending their times with those troopless heroes and taking mines and stuff without any “challenge” nor fun at all. That AI simply have an annoying behavior.

Also, I don’t know if it’s a bug or something but CPU without castle wander until their banishment instead of attacking the nearby castle as original H3 CPU used to. They sometimes visit the same map objects several times in the same turn. Sometimes their turns are abnormally long and/or they’re doing pause between each steps.

PS: I know the last reply was 1-year ago but since there isn’t that much activity on this forum, this can only be beneficial. Thanks for reading.

I work on AI in a separate branch unofficially. The progress is quite slow so. Regarding AI without towns left to tell the truth it is already the end. It hardly can win if you took his last town. There are much more important problems.

Well, if the AI was building armies instead of buying troopless heroes, it might have a chance of recapturing a town. Sometimes, they don’t do anything because of AI Value while they technically should win the fight if they engage it.

What kind of tools are used in the H3AI creation process? I didn’t find any documentation about that and I’m curious to know more about.

Actually I am not sure that H3 original AI has a rule to capture town if has none. I remember that I wanted a few times to force AI recapture its town back so that I do not win and have some time to explore map and it failed to do this.

Regarding the tools I do not know anything about original AI tools.

It’s funny 'cause I remember the opposite: having good garrisons in town and getting attacked while the enemy was going to be banished. Though, I might’ve made a mistake if it was on WoG. I might do few tests someday and give you the results.

Maybe you are right. I also remember such behavior when AI attacks the last lost town and dies. I might mistake it with VCMI. VCAI definitely does not have such rule and will continue wandering even without towns. And yes it loves to buy heroes. And it has no fear and defense. My AI at least has some logic around defense and will behave a bit better. But it also has no rule regarding no towns. If you want to try out my AI I can provide you a build at weekends. But it will definitely be less stable and much slower.

1 Like

Yes, I’d like to try it !

https://builds.vcmi.download/branch/nullkiller_ai/Windows/?C=N&O=A
Builds from my branch. Finally it sucseeded.
Also latest build from app veyor https://ci.appveyor.com/project/vcmi/vcmi/builds/28345470/job/rsbq7ydj980dd0jy/artifacts
Not sure if appveyor build works but if it does it is usually faster on windows

Map - Ascesion. AI durn. Day - 1.

Yeah. A lot of bugs. Needs stabilization. It can take months to acquire more or less stable build for beta testing. And I became lazy.

Some fixes on Ascension map have been done but there is still a lot of work

Just in case anyone is interested in testing: I built a large map with some factions based on random towns, so it is possible to test the new towns. The map is still work in progress (about 40% of the pure map done, let aside other issues like balancing). But it is playable so far.
I observed a very funny AI behavior. The blue player is meant to be played as Cove. It is a swamp/water based faction, so Fortress might be possible too. I tested it with Cove though. And although blue has soon the option to see most of the other Cove towns (via hut of the magi), it still ignores them. Instead it rushes north to capture a Necro town. I already blocked access to that town with a few water elementals, but it does not seem to help.
A general hint for AI developers: A fixed reward system or fixed priority is not really intelligent. Priorities should vary with map size. For small maps top priority is to get some army and rush. For large maps like this one top priority is to get your economy up and running. Money will make the difference here. The priorities here are very different from those of a small map. The priority or reward should be a function of the map size. And the faction should have some impact on priorities too. Basically, this means increase the priority of those resources which the resource silo gives and/or the resource needed for tier 7 stacks. Additionally priority for resources should be lowered each time such a resource goal is fulfilled. That is, f.ex, at the start you have a quite high priority for getting ore, and which each ore mine you get the priority for ore should be lowered a little.

The map: Player blue is a swamp/water faction and benefits much from navigation. Ideal for Cove. Tan is a desert faction, I tried Pavillon here. Green is a grass/wood faction with 3 castle towns. Would fit well for Rampart, Evergreen and Preserve or the like. Green is meant to be played by human. Tan is currently playable by human too for test purposes only.
C012.h3m (141.2 KB)

2 Likes

I thought about it, makes sense. From the other side army allows to reveal new blocked area and get some gold from there. Regarding to town faction it definitely makes sense to capture towns of the same faction. The only question is to understand which faction you are. You might have different towns and different army.

Merged latest develop + a few fixes.

2 Likes

Unfortunatelly, with few mods enables - still AI turns last soooo looong :frowning:

EDIT: Funny (?) when I change value “MAX_HEROES_ON_MAP_PER_PLAYER” : 8, to “MAX_HEROES_ON_MAP_PER_PLAYER” : 6 in defaultMods.json, AI turn becomes infinite. Not only in your build, but also in 'official; :slight_smile:

I plan to apply some async processing. Some parts of code still hardcode hero count per player to 8… How strong mods affect AI? In %?

It depends. Some parts of the game - about 5%, some parts of the game - 20%.
And, as I wrote before - AI turns are shorter when I type vcmieagles to observe ai movements. With Fog of war enabled - are longer :wink:

But… keep up your work, now game is significally better!!!

“S” maps works very good.
But some XL is just terrible.

I played some games, and my opinion is S size preferable now. May be it’s not very fun, but it’s fast.

//Maps you can take from here https://www.maps4heroes.com/heroes3/maps.php?keywords=&type=The+Shadow+of+Death&size=Small&difficulty=&humans=0&teams=0&players=0&sort=5