fheroes2
fheroes2 copied to clipboard
Combat, AI behavior, AI should not be distracted by troops who inflict little damage and are therefore not a priority (0.9.13 5123)
Preliminary checks
- [X] I've checked that there aren't other open issues on the same topic.
- [X] I've checked that this issue is reproducible on the latest snapshot build.
Platform
Windows
Describe the bug
In fheroes2, AI should not be distracted by troops who inflict little damage and are therefore not a priority.
In fheroes2:
https://user-images.githubusercontent.com/43583994/159176403-a13b5ed0-d3fa-47a4-91ad-f8ace729ecbe.mp4
Save file
Here is the test scenario file: 0 9937.zip
Additional info
No response
@LeHerosInconnu I tested a fix for this issue. While it covered your particular scenario I'm still not quite satisfied with the solution. When I replaced slow archers with Grand Elves, Ogres chased them endlessly while being attacked by no-retaliation stings from Sprites.
We need a well-defined condition on when to attack the unit within reach versus prioritizing . Two ideas that came up so far:
- Check the speed of the stronger unit. If faster then avoid chasing.
- Check the distance between weak unit (Sprites) and the most dangerous one (Archers). If attacking weakling gets us further away from stronger target, don't do it.
Thoughts?
Hello @idshibanov,
@LeHerosInconnu I tested a fix for this issue. While it covered your particular scenario I'm still not quite satisfied with the solution. When I replaced slow archers with Grand Elves, Ogres chased them endlessly while being attacked by no-retaliation stings from Sprites.
We need a well-defined condition on when to attack the unit within reach versus prioritizing . Two ideas that came up so far:
- Check the speed of the stronger unit. If faster then avoid chasing.
- Check the distance between weak unit (Sprites) and the most dangerous one (Archers). If attacking weakling gets us further away from stronger target, don't do it.
Thoughts?
This is a good start. :) Morale should also be taken into account. Positive morale, or negative morale for the opponent, at the right time can be advantageous. Spells can also make a difference. For example, the AI can get rid of weak troops first and use the Blind spell at the right time to turn the situation to its advantage. Or a Haste, or a Slow spell, by approaching the shooters can keep them from moving away. But, I don't know if this can be worked out easily.
Hello, @idshibanov & @LeHerosInconnu . I'm sure, we cannot implement the most effective solution right now, as it is supposed to be rather complex... But I want to share my thoughts on the AI behaviour here. In my opinion, in the example above ogres should consider the distance Ogres->Archers and the amount of damage they receive, till the moment they can reach archers. If ogres will be eliminated before they reach archers they can take a few sprites to the underworld with them. ^_^ On the other hand, distance and speed are no the only values, AI should count, as the battlefield is limited and ogres can catch faster elves somewhere in corners with proper management. Returning to the particular example, I believe, that Ogres should ignore Sprites in a case they just stand in a few hexes nearby. But should attack them, if sprites are attacking ogres (considering the difference in potential damage between archers and sprites: if sprites make essential damage, ogres should retaliate). Also Ogres should attack with the angle, that makes them closer to archers (if possible) Also AI should sometimes count on morale bonus (in a case AI is chasing faster enemy): if AI troops have the probability to receive additional move, they should run closer to the enemy. The same to negative morale: if enemy has a chance to miss his turn, ogres should try to chase faster ranged troops as they can miss their turn and ogres can succeed in attacking them.