Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The AI should preemptively kite creatures to avoid getting hit #7608

Closed
1 task done
zenseii opened this issue Aug 22, 2023 · 0 comments · Fixed by #7690
Closed
1 task done

The AI should preemptively kite creatures to avoid getting hit #7608

zenseii opened this issue Aug 22, 2023 · 0 comments · Fixed by #7690
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement
Milestone

Comments

@zenseii
Copy link
Collaborator

zenseii commented Aug 22, 2023

Preliminary checks

Describe the problem requiring a solution

Currently the battle AI will wait until it has been struck to decide to kite, instead of kiting beforehand to avoid getting hit.

I found it reproducible with 150 greater druids against 350 golems:

fheroes2.engine.version_.1.0.7.2023-08-22.17-29-20.mp4

Describe the possible solution

Make the AI kite before getting struck if it is within the range of the opposing creature.

Additional info

Here is the relevant part of the code:

else {
// Kiting enemy: Search for a safe spot unit can move to
target.cell = FindMoveToRetreat( arena.getAllAvailableMoves( currentUnit ), currentUnit, enemies );
if ( target.cell != -1 ) {
DEBUG_LOG( DBG_BATTLE, DBG_INFO, currentUnit.GetName() << " archer kiting enemy, target cell is " << target.cell )
// The target cell of the movement must be the cell that the unit's head will occupy
const int32_t moveTargetIdx = getUnitMovementTarget( currentUnit, target.cell );
DEBUG_LOG( DBG_BATTLE, DBG_INFO, currentUnit.GetName() << " moving to cell " << moveTargetIdx )
if ( currentUnit.GetHeadIndex() != moveTargetIdx ) {
actions.emplace_back( CommandType::MSG_BATTLE_MOVE, currentUnit.GetUID(), moveTargetIdx );
}
}

@zenseii zenseii added improvement New feature, request or improvement AI Artificial intelligence behaviour labels Aug 22, 2023
@zenseii zenseii added this to the 1.1.0 milestone Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant