diff --git a/AI/BattleAI/BattleExchangeVariant.cpp b/AI/BattleAI/BattleExchangeVariant.cpp index 33e1a9041..a6bd2758e 100644 --- a/AI/BattleAI/BattleExchangeVariant.cpp +++ b/AI/BattleAI/BattleExchangeVariant.cpp @@ -491,18 +491,15 @@ ReachabilityData BattleExchangeEvaluator::getExchangeUnits( vstd::concatenate(allReachableUnits, turn == 0 ? reachabilityMap.at(hex) : getOneTurnReachableUnits(turn, hex)); } - if(!ap.attack.attacker->isTurret()) + for(auto hex : ap.attack.attacker->getHexes()) { - for(auto hex : ap.attack.attacker->getHexes()) + auto unitsReachingAttacker = turn == 0 ? reachabilityMap.at(hex) : getOneTurnReachableUnits(turn, hex); + for(auto unit : unitsReachingAttacker) { - auto unitsReachingAttacker = turn == 0 ? reachabilityMap.at(hex) : getOneTurnReachableUnits(turn, hex); - for(auto unit : unitsReachingAttacker) + if(unit->unitSide() != ap.attack.attacker->unitSide()) { - if(unit->unitSide() != ap.attack.attacker->unitSide()) - { - allReachableUnits.push_back(unit); - result.enemyUnitsReachingAttacker.insert(unit->unitId()); - } + allReachableUnits.push_back(unit); + result.enemyUnitsReachingAttacker.insert(unit->unitId()); } } } diff --git a/AI/Nullkiller/Analyzers/HeroManager.cpp b/AI/Nullkiller/Analyzers/HeroManager.cpp index eb95e5ebc..e2406a023 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.cpp +++ b/AI/Nullkiller/Analyzers/HeroManager.cpp @@ -126,23 +126,20 @@ void HeroManager::update() } std::sort(myHeroes.begin(), myHeroes.end(), scoreSort); - - std::map newHeroRoles; + heroRoles.clear(); for(auto hero : myHeroes) { if(hero->patrol.patrolling) { - newHeroRoles[hero] = HeroRole::MAIN; + heroRoles[hero] = HeroRole::MAIN; } else { - newHeroRoles[hero] = (globalMainCount--) > 0 ? HeroRole::MAIN : HeroRole::SCOUT; + heroRoles[hero] = (globalMainCount--) > 0 ? HeroRole::MAIN : HeroRole::SCOUT; } } - heroRoles = std::move(newHeroRoles); - for(auto hero : myHeroes) { logAi->trace("Hero %s has role %s", hero->getNameTranslated(), heroRoles[hero] == HeroRole::MAIN ? "main" : "scout");