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.58k stars 359 forks source link

Optimize the usage of "Dimension Door" spell by AI heroes #7330

Open Branikolog opened 1 year ago

Branikolog commented 1 year ago

Preliminary checks

Describe the problem requiring a solution

AI heroes sometimes make teleportations for a very short distance. Also they use DD way too often for such minor objects, like sawmill capture or picking up treasure chest.

https://github.com/ihhub/fheroes2/assets/55348946/7b4dbd34-3748-4ead-ac27-efd0af14447f

_Seven_Lakes_DD.zip

Describe the possible solution

I think AI should use DD more carefully. Only for the urgent cases, when we talk about resource gathering. Or for the cases, when there's an enemy nearby, so cast is a way to get an advantage over him.

Additional info

No response

ihhub commented 1 year ago

Hi @Branikolog , this is too broad requirement about cases when the AI should use and shouldn't. Please specify the conditions and explain why we should implement this way or another.

Branikolog commented 12 months ago

Hi, @ihhub

This spell is rather powerful and consumes lots of mana if used improperly.

Analyzing the case from the video I can suggest a few improvements in logic, that could optimize the spell usage. AI should use DD if the target is blocked or unreachable in the current circumstances. AI should preferably use DD when the controlled hero could save a reasonable amount of movement points. When AI hero creates a path on a screen and the amount of movement points to reach the target cell highly exceeds the number of movement points spent for spellcast - then DD brings the highest benefit. It's much more effective to cast DD and save 1500 pts, rather than jump to not so distant pile of wood, that requires wasting only 400pts. to reach it. On a video above you can see that AI simply jumps over a few artifacts, that seem to block his path to capture a sawmill. So if any object blocks hero path AI hero could pick them up instead of jumping over it.