fheroes2
fheroes2 copied to clipboard
AI sits in the castle despite treasure chests and an endless gold sack are nearbý.
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
Green ally sits in its last castle for many turns despite that it can collect treasure chests nearby and come back during the same turn(?).
Save file
Additional info
No response
despite that it can collect treasure chests nearby and come back during the same turn(?)
This functionality is not yet implemented (see #7346). So if AI hero has a priority task to defend a castle, he will sit inside until the threat to the castle disappears.
I think this and many similar issues of stragetic AI can be solved by classic chess-AI approach - enumeration of all possible actions/action chains during the same turn and selecting the chain giving the best target function(the 'score' of the strategic situation in the end of the chain) value. It will solve various "hero boards a boat ignoring a treasure chest it can grab before the boarding / hero runs towards a castle ignoring enemy hero it passes by" etc. It will hurt the computation time of AI moves of course. I think making manual patches directly programming logic in every specific situation can make the code very complicated and unmaintainable.
It will hurt the computation time of AI moves of course.
Suppose we have a large map (144x144 = 20736 tiles). Suppose that 1/50 of these tiles are tiles with objects, it's about 400 objects. The number of options with visits to them in different order (which the AI should calculate in planning mode, because it takes into account all available objects) is 400!, which is ~6*10^868. Even if there are only 100 objects on the map, the number of options for visiting them in different order will be about 10^158.
It will hurt the computation time of AI moves of course.
Suppose we have a large map (144x144 = 20736 tiles). Suppose that 1/50 of these tiles are tiles with objects, it's about 400 objects. The number of options with visits to them in different order (which the AI should calculate in planning mode, because it takes into account all available objects) is 400!, which is ~6*10^868. Even if there are only 100 objects on the map, the number of options for visiting them in different order will be about 10^158.
Hmm, yes, more than I thought relying on intuition) But what if we consider just 'all nearby objects for complete permutation+ all distant castles as the final object in the chain'. Then, say, there are around 5 nearby targets and 10 distant castles. Then we end up with (5! * 10) * number_of_heroes which sounds sane?