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.74k stars 378 forks source link

Adventure map, AI hero is running in front of the castle #7557

Open Branikolog opened 1 year ago

Branikolog commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

AI hero starts running in front of the castle without any visible reason.

https://github.com/ihhub/fheroes2/assets/55348946/2dc5465e-d764-414e-bdf2-59dafa618568

Save file

Boarding near mine.zip

The issue happens not each time we skip the turn.

Additional info

No response

oleg-derevenetz commented 1 year ago

Hi @Branikolog could you please provide a save file? To be honest, it's very similar to AI's "block prevention mechanics". When AI heroes have nothing to do, AI may think that's because some of its heroes is blocking the way for others, so it can start moving heroes who can potentially block the path back and forth in the hope that some new targets will appear because of this. But it seems that there is simply nothing to do on this small island.

Branikolog commented 1 year ago

@oleg-derevenetz Sorry, attached the wrong file. Strange thing is that this hero sometimes walks away and sometimes not. Even at this video you can notice that he changed walking area after a while.

oleg-derevenetz commented 1 year ago

Strange thing is that this hero sometimes walks away and sometimes not. Even at this video you can notice that he changed walking area after a while.

These movements are random. Heroes just randomly move to adjacent tiles. It is not related to the castle itself, hero is just moved back and forth by AI hoping that it may give an access to some new targets eventually.

Branikolog commented 1 year ago

@oleg-derevenetz Anyway, it's a strange-looking behaviour for this particular hero. Especially comparing to another hero standing nearby without any move.

oleg-derevenetz commented 1 year ago

OK, I just took a look on this save file, and this is really AI "blocking prevention" at work:

13.08.2023 19:37:48: [DBG_AI]   `anonymous-namespace'::AIToBoat:  Mandigal
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6683
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6683
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6683
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:37:48: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:13: [DBG_AI]   AI::Normal::HeroesTurn:  Wilfrey may be blocking the way. Moving to 6684
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6684
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6684
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Ector at current position 6791
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Ector can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Find Adventure Map target for hero Wilfrey at current position 6684
13.08.2023 19:38:14: [DBG_AI]   AI::Normal::getPriorityTarget:  Wilfrey can't find an object. Scouting the fog of war at -1
13.08.2023 19:38:16: [DBG_AI]   AI::Normal::HeroesTurn:  Wilfrey may be blocking the way. Moving to 6683
[... etc etc ...]

This is not a bug of any kind.

Anyway, it's a strange-looking behaviour for this particular hero. Especially comparing to another hero standing nearby without any move.

Position of that another hero is not considered as "potentially blocking". There are special rules regarding whether the hero's position is considered as "potentially blocking" or not.