However, with advanced map editor, community mapmakers managed to "aid" AI, to make game more challenging. Mostly it is done by supplying AI with additional resourses and creatures. Being better than nothing, it’s still very far from desirable. In this aproach, I would mark out two drawbacks. One is that AI is still very bad at making "logical" adventure map decisions. Therefore, such a game is interesting mostly because of the "fighting" part, at which AI is good. Second is that, it’s hard to forecast AI behavior with given bonuses. For example, sometimes AI could spend all given creatures on fighting neutrals, and sometimes it managed to collect them in one army and crush player's weaker forces.
Not so long ago, here, on Celestial Heavens, I've found a good article by Charles Watkins titled "Wrangling the AI" It was nice to find a deeper look into the problem and ways of solving it. There were some fine solutions, but also there were some arguable ones. Sometime later, I started doing my own observations in this area, and today I want to show one of my results.
I am not saying that it will make Heroes 4 adventure AI good or at least "acceptable", I am afraid that it is impossible without the source code. However, it will definitely make AI better. Also, I don’t want just to tell "what to do", I want to show you why it works, and actually, the way how I came across this.
This solution is about making adventure AI better at planning its actions. I believe many of Heroes4 players think that adventure AI is not able to do anything sane at all. Well, as for me, I thought so, sometime ago. I thought that adventure AI is more about random travels with hitting the best achievable target in this turn. But it’s not exactly as this, and that’s really good.
So, below, there are several so called tests, that show how AI acts on adventure map in different situations. I’ll attach all test maps to this article, so that you could test it yourselves. Some notes if you want to do it:
- Maps created in the latest version of the editor (that comes with WoW addon), and results are tested only in the latest Heroes4 version (that is accordingly WoW) and Equilibris 3.51;
- The routes that you can see on the accompanying pictures were made in the original WoW game. (in Equilibris, AI explores using a different algorithm somehow);
- use nwcprometheus cheatcode to see the whole map;
- enable "quick combat", so battles won't distract you;
- all maps were tested on "hard" difficulty, because this is the first difficulty where AI doesn't have limitations (yeah, that funny, I know);
- I’m 99% sure that these maps will work with other language versions of the editor, but I cannot guaranty that. I have the Russian version of it.
Let me know if some maps will not work, maybe I will be able to do something about it.
Ok, let’s start.
AI town is in the upper-left corner, player town is in the middle of the opposite side. AI can’t hire new creatures or heroes here. Near AI town there is a hero with a few titans. Player town has a single 1st lvl creature in the garrison.In the lower-left corner, there are some treasures, and further to the right side, there is a gold mine.
Well, here we have the usual scenario of AI actions. It’s starting to explore, ignoring the town & the gold mine.
My first thought was "this really sucks", because I was sure that AI sees the whole map. However, it does not. Let’s look at the next test.
Same as ai0.h4c with the following changes: there are imps that belong to AI, near the player's town, near the mine and near the treasures. They disappear before the first turn, but that’s enough for AI to see where the town, mine and treasures are located. In addition, we have a new hero for the player and enough money to hide it in a monastery for long, so when AI will take the player's town, it will not lose the game.
Now, that’s a lot better. AI runs directly to the town and captures it, then explores a bit and goes to capture the mine and collects the treasures.
My first thought was "that’s just awesome". However, it is not, yet. Next test shows why.
Same as ai1.h4c but the red (player's) town has a script that adds 10 angels on day 4.
Ok, same as earlier: AI starts to run directly to the red town. However, when half of the way is done, angels appear in the garrison, and AI, of course, cancels its capture plan. That’s correct. However, after that AI doesn’t return to the second obvious target - gold mine or treasures. It decides to explore the map collecting the treasures and capturing the mine only when they are near. That’s pretty weird and inefficient.
But what if we unveil the whole map for AI?
Same as ai2.h4c but imps are everywhere :). Of course, all of them will disappear before the first turn, but now AI will have the whole map explored.
AI starts to run directly to the red town again. When half of the way is done, angels appear in the garrison, and AI cancels its capture plan. But now, when it sees the whole map and doesn’t need to explore, it runs directly to other "points of interest". First, it decides to collect the treasures, and then captures the mine. Now it’s fine.
If you are still unconvinced about the need of "exploring the whole map", check the following tests.
Same as ai1.h4c but there are two red towns and two blue heroes to capture them. Imps open only the mine and both towns. Treasures are removed.
One of the AI heroes starts to run directly to the nearest town, but the other starts to explore, and captures the second town only because it’s in the way.
Also if one of the heroes has more titans then the other, then he is going to capture the nearest town, and the second hero goes exploring.
Same as ai4_1.h4c but imps open the whole map.
Both of AI heroes run directly to the towns and capture them at the same turn.
Let’s see how good AI is at swimming. Well, actually we already know that it’s horrible at that, so let’s place one imp near the player’s town. That might help.
Similar to ai1.h4c, but in order to get to the red town AI has to make complex water navigation.
Well... it didn’t do anything good. As always AI jumps out on some near shore, at the next turn jumps back aboard, then swims a little, and it all starts over.
Ok, now let’s take a similar map but with imp-scouts all over it. It’s not exactly the same map, because for me it was easier to take the map from ai3.h4c example and add water. But as a swimming test, it is as complex.
AI jumps on the ship and takes the best route to the red town and captures it. Excellent.
I guess some of you thought that AI failed to take the right course on ai5_1.h4c because it didn’t see it. Let’s check this.
Same as ai5_2.h4c, but on the most of the land imps are removed, so for AI only water is fully visible.
I’ve got a pretty strange result. AI just stuck. All it was doing was boarding on/off the ship.
And the final test for today that shows that AI can see through unexplored territory if it needs to put the route.
Same as ai1.h4c (imp shows only the red town), but no mine & treasures and the red town is surrounded by a stonewall with a little opening, so the shortest route will not work.
AI hero managed to use the best route as if it knew where the opening was.
1) AI doesn’t see the map. Which is pretty unfair, because most of the time when the player starts playing on some map, he already knows where the towns or some mines are, while AI must explore the map every time it plays on it.
2) AI puts too much priorty into exploring. It wants to explore the map even when there are more crucial things to do.
So, it will help AI a lot if a mapmaker opens the map for every comp. player on it.
- Build the whole map before adding "scouts".
- Always keep a "scout-less" copy of the map.
- You can create one scout and use it as 3-4% brush on the whole map, to make things easier.
- Check how exploring works, there should be no unexplored spots.
To create a scout: Put one creature army and add this script to its "continuous" scripts section:
give to player 2
give to no one
this army fights Angels
Where “player 1/2/x” are computer players.
"give to no one" is important. So when you will test it, you will not get 200 fights at start :)
As you can see, H4 AI is able to do few things about move planning on the adventure map, after all. It just needs a little help with that.
I hope somebody will find this useful. Even if you are not a mapmaker, you still can use this to improve other, older maps, like I do. Really, this and few other improvements (which you can find below) can make H4 AI play differently.
Some more advices... while doing maps remember that:
- AI can't:
Use shops & potions
And in the end, here are some well-known advices on other AI weaknesses, keep in mind them as well.
- No building plan.
Solutuion: Forbid to build buildings that you wouldn't build yourself on this map.
- Ignoring the rest of movepoints after picking up an artifact or treasures (not always).
Solutuion: Do not place much of that on the part of the map where AI starts, better give the same amount via scripts.
- Bad hero skill selection.
Solutuion: Give skills that you would take to AI heroes via scripts. (ex: "Combat" is obligatory for everyone)
- Bad allocation of heroes to armies. For example, AI may have an army with 3 heroes in it, and not a single one of them will have "Tactics".
Solution: Give several "Tactics" skills to every AI hero. And if this is a magic-type hero, add few to its primary magic skill. Of course, some heroes will lose one skill cell, but at least all armies that have heroes will take advantage of "Tactics", which is more important.
- Bad armies allocation. The worst situation is army without heroes. It cannot capture, it does not have hero's advantages, heroes don’t get XP.
Solution: There is no simple solution to this problem. But there is a complex one. I have some good results in this area, and most likely will share it in the second part of "Improving HoMM4 AI" sometime in the future.
Archive with test maps can be taken here.