AI Battle Bugs and improvements (v914)

Improving the tactical AI battle competency

These are some of the AI bugs I've noticed in the maybe 6 games I've played now. The AI in tactical combat for 4x games it typically pretty bad. Most of these bugs are by no means unique to FE, and I've seen them in a lot of games I've played. Purely tactical games tend to do better, if you have played Battle for Wesnoth it 'feels' like the AI tries to take a number of these into account- particularly killing units whenever possible point. 


* I’ve never seen the computer cast an overland combat spell.

I really hope this is coming.  There aren't that many overland combat spells, I think there are probably a cases that could be generated where the AI always wants to cast spell x if it has it.

 

* AI gets its heroes killed way too often

I've seen it attacking monsters with forces it can’t possibly hope to win with, it should be a much better judge about if it can win a certain battle with monsters, as it doesn’t have to contend with human intelligence, hell even letting it sun x number of battle simulations and only proceed with the battle if the expected losses are acceptable would be an improvement. Leveling up is a huge part of gaining power. All those turns it sits immobilized recovering are turns its not gaining xp and loot.

- Actually this would be useful for noob players as well. I have a decent sense after playing a couple games of what I can take w/o losses, and it make a huge difference in my play, obviously experienced players would be able to beat the expected outcomes, as they are better tacticians than the computer

reportedly fixed v915 changelist: https://forums.elementalgame.com/425056 hat tip joasoze

 

AI never waits for me to come to them

This almost always lets me get the 1st wave of attacks in which is a huge advantage. This happens even when I’m attacking them, and have no mages or arches in my attacking army. I understand it may not be as fun for players for the computer to sit there and wait… but at least when the player is attacking the computer should be smart, and when it decides it is a major battle it needs to win… it needs all the help it can get :D

 

* AI initial ranged attacks should all be targeting the same unit

There really is no excuse for these to be spread over 2 units neither of which get killed, I see the air/fire shrills do this a lot. (well technically if a melee attack it had lined up would on avg kill one unit it could target a second with a ranged attack so-as not to ‘waste’ damage. But I think the AI has a long way to go before it gets to the point of worrying about ordering its attacks so it doesn’t waste a few points of damage.

 

* AI get stuck once it is next to one of my units

once the AI is next to one of my units it won’t join the rest of its army to concentrate its forces on killing one unit at a time, it just sits there.  I could understand if it couldn’t get to the other (majority targeted unit) in one turn and thus waste an opportunity to attack, but it does this even when there is zero turn cost associated with switching targets.

 

* AI doesn’t withdraw forces which will die  if they stay in melee

This is a bug bc there is at least a subset where victory w/o loss is assured even w/o the weakened unit such that the computer pointlessly gets units killed in auto combat.

A generic way to calculate this would be to have the computer simulate the rest of the battle with the weak/wounded unit and w/o it.

if (it wins w/o losing any units when simulating its withdraw, but losses the unit if it stays in the battle )  then {withdraw unit}

A slightly dumber version:

if (my attack won’t kill unit && counter attack will kill me) then {consider next unit}

This (and similar dumb rules) might end up with suboptimal decision making in some cases, but would probably make things better over-all. In order for it to be smart it would have to know that its damage to that unit and thus sacrifice was necessary/likely to prevent the loss of a more important unit.

 

 

* AI doesn't target the right units

How the AI targets units seems pretty random to me.

- All other things being equal  it should be targeting the unit it can surround the most and thus deal the most damage to and kill the quickest.

- among unequal units it should be targeting the units to remove as much dpt(damage per turn, their unit’s turn) as possible e.g. (unitDamage *  numTurnsTargetUnitGetsBeforeItDies / turns it takes AI to kill it), yeah calculating those isn’t perfect, esp w/magic or multiple casters but at least among non-mages this should be trivial to calculate and there could be a special hatred and targeting built in for squishy mages, which mess up its damage calculations, or maybe something actually smart- hey you are the AI guys right?

- so the AI is still effective when it is losing ( it’s a game, the AI is expected to lose :D ) it needs to take into account if it actually *can* kill this unit and prioritize something squishier if can’t so it at least kills something, or targets the something it has the best chance of killing, if it is so overmatched to not be likely to kill anything.

 

* Path finding doesn't make proper use of roads (on map)

If you are on a road and you click further down the road sure it works. But if you are off the road and click to go somewhere that would be quicker if you took the less direct road route you'll take the more direct slower route.  This maybe the result of multiple bugs… I’ve established pretty well that the path-finding algo every time incorrectly prefers

road -> shard -> road VS

road -> road -> road

maybe not technically AI, but proper path finding is very important for the AI, heck truly proper AI path finding would include a danger cost in the path as well as the movement cost so that it avoids ending next to dangerous monsters, and generally avoids hostile stack threat ranges it can’t win against.

 

 * I've always thought it would be cool if...

some game had a backend master server AI which used (opt-in) player game logs as training data to improve its game for the next patch.

It could probably learn a thing or two from the most successful players about

- city build order

- opening moves (split heroes up or join up in an army)

- combat spell: openings, frequency at level x vs monster y

- desirable hero traits

- effective unit designs

- ect

 

 

Background: this is broken out of a super long post I did on my 1st impressions of the game, more will come to your delight or horror :p

https://forums.elementalgame.com/425000

7,773 views 6 replies
Reply #1 Top

 AI is a gets its heroes killed way too often


The frog said that there was a bug that the AI treated the monster lairs like goodiehuts and got repeatedly killed by the same monsters. Should be fixed in .915 and it should make the life of the AI a lot easier

Reply #2 Top

* AI doesn't target the right units

The AI is pretty consistent in the fact that it targets the wounded units and kill them off. That is at least a good thing (for the AI, not for you :) )

Reply #3 Top

AI never waits for me to come to them


Not true. I have seen armies stand off (especially when it has many units and quite a few ranged ones). 

Reply #4 Top

You should add that the AI uses the wrong spells like protection from fire when one does not have fire damage.

Reply #5 Top

Fantastic post, if the devs need any help boosting the AI they should ask :)

Sincerely
~ Kongdej

Reply #6 Top

nice to know about the fix to heroes treating lairs as goody huts, that should make a noticeable different in AI power progression.


ranged unit stand-offs.

Hrm looking around I see a few other reports of that which I guess is supposed to happen if they have a sufficient number of ranged units. Personally I've never seen it, but kinda new so maybe I wouldn't have. There are still way too many instances when it unnecessarily charges, for instance when both sides only have melee units.

 

targeting wounded units:

Hrm it isn't clear to me why a wounded target should be preferred e.g. you are fighting 2 dragons. One is at 50% health, the other at 100%. Otherwise the dragons have the same stats. The 50% health dragon normally has 200hp which the 100% dragon has 90hp. clearly the 90hp dragon should be targeted 1st you will kill it first and reduce the over-all expected damage you are going to take in the encounter by killing it first. I think what makes the difference wrt hit-points is how quickly you can kill it, and how much damage it does to you. Obviously there are edge cases e.g. if you 1st attack does 100 avg damage say crushing blow. and subsequent attacks to less. In this case you are killing both equally as fast and so the consideration of how fast you'll kill the next monster comes into play, the 90hp monster is easier to kill, optimizing for speed of kill (which coincidentally minimizes encounter damage). Especially if you bring armor into the picture you could have a slightly wounded but heavily armored unit and a quick high damage undamaged unit. It should target the unarmored high dps unit 1st and then turn its attention to the slow turtle unit.