diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index a8911d3b6..8be0aa310 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -867,6 +867,19 @@ void AIGateway::pickBestCreatures(const CArmedInstance * destinationArmy, const auto bestArmy = nullkiller->armyManager->getBestArmy(destinationArmy, destinationArmy, source); + for(auto army : armies) + { + // move first stack at first slot if empty to avoid can not take away last creature + if(!army->hasStackAtSlot(SlotID(0)) && army->stacksCount() > 0) + { + cb->mergeOrSwapStacks( + army, + army, + SlotID(0), + army->Slots().begin()->first); + } + } + //foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs for(SlotID i = SlotID(0); i.validSlot(); i.advance(1)) //i-th strongest creature type will go to i-th slot { diff --git a/AI/Nullkiller/Analyzers/HeroManager.cpp b/AI/Nullkiller/Analyzers/HeroManager.cpp index ac5fff683..b896ab728 100644 --- a/AI/Nullkiller/Analyzers/HeroManager.cpp +++ b/AI/Nullkiller/Analyzers/HeroManager.cpp @@ -236,7 +236,7 @@ const CGHeroInstance * HeroManager::findWeakHeroToDismiss(uint64_t armyLimit) co for(auto existingHero : myHeroes) { - if(ai->isHeroLocked(existingHero) && ai->getHeroLockedReason(existingHero) == HeroLockedReason::DEFENCE + if(ai->getHeroLockedReason(existingHero) == HeroLockedReason::DEFENCE || existingHero->getArmyStrength() >armyLimit || getHeroRole(existingHero) == HeroRole::MAIN || existingHero->movementPointsRemaining() diff --git a/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp b/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp index c626a36d2..f5eb28c79 100644 --- a/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp +++ b/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp @@ -119,10 +119,11 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const CGHeroInstance * her HeroExchange heroExchange(hero, path); - float armyValue = (float)heroExchange.getReinforcementArmyStrength() / hero->getArmyStrength(); + uint64_t armyValue = heroExchange.getReinforcementArmyStrength(); + float armyRatio = (float)armyValue / hero->getArmyStrength(); // avoid transferring very small amount of army - if(armyValue < 0.1f && armyValue < 20000) + if((armyRatio < 0.1f && armyValue < 20000) || armyValue < 500) { #if NKAI_TRACE_LEVEL >= 2 logAi->trace("Army value is too small.");