ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.66k stars 373 forks source link

The AI creates path through pyramid, attacks it and dies. #7503

Closed zenseii closed 1 year ago

zenseii commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

The AI green player avoids the blue player by creating path through the pyramid and attacks it, but it is obviously too weak and dies.

It has a decent enough army: image

https://github.com/ihhub/fheroes2/assets/12501091/c141cf27-1eca-430c-80aa-3ac373c2087a

There are several issues here, but the core one is that the AI's evaluation of the pyramid needs improvement.

Save file

ai suicide pyramid.zip

Additional info

No response

ihhub commented 1 year ago

Ah, yes. I have this in my TODO list. Sometimes AI heroes indeed move on objects which they shouldn't. We need to connect HeroesValidObject() function from ai_normal_hero.cpp to ai_normal.cpp file.

zenseii commented 1 year ago

I see! I believe it is OK for the AI to actually create the path through the pyramid (apart from the fact that it should actually go in the exact opposite direction to escape, really), the core issue described is that the AI shouldn't even make the choice to attack the pyramid, just ignore it and move along.

In fact I do wonder if the AI has attacked the pyramid many times during this map, thereby losing lots of heroes, but this I have not checked.

idshibanov commented 1 year ago

I don't see an issue for AI to pass through objects like Pyramids, especially here when it was trying to avoid another hero blocking the way. Better fix is to add a check during the visit for AI to decline the battle.