From 1a1ae5cd8bdd37599414155232effc10cb813cb8 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sun, 31 Dec 2023 17:29:05 +0200 Subject: [PATCH] BattleAI: fixes --- AI/BattleAI/BattleEvaluator.cpp | 2 +- AI/BattleAI/BattleExchangeVariant.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/AI/BattleAI/BattleEvaluator.cpp b/AI/BattleAI/BattleEvaluator.cpp index 5c447bf03..1e7234b37 100644 --- a/AI/BattleAI/BattleEvaluator.cpp +++ b/AI/BattleAI/BattleEvaluator.cpp @@ -609,7 +609,7 @@ bool BattleEvaluator::attemptCastingSpell(const CStack * activeStack) if(ourUnit * goodEffect == 1) { - if(ourUnit && goodEffect && (unit->isClone() || unit->isGhost() || !unit->unitSlot().validSlot())) + if(ourUnit && goodEffect && (unit->isClone() || unit->isGhost())) continue; ps.value += dpsReduce * scoreEvaluator.getPositiveEffectMultiplier(); diff --git a/AI/BattleAI/BattleExchangeVariant.cpp b/AI/BattleAI/BattleExchangeVariant.cpp index dc37412da..8e3d5764b 100644 --- a/AI/BattleAI/BattleExchangeVariant.cpp +++ b/AI/BattleAI/BattleExchangeVariant.cpp @@ -258,7 +258,9 @@ EvaluationResult BattleExchangeEvaluator::findBestTarget( updateReachabilityMap(hb); - if(result.bestAttack.attack.shooting && hb->battleHasShootingPenalty(activeStack, result.bestAttack.dest)) + if(result.bestAttack.attack.shooting + && !activeStack->waited() + && hb->battleHasShootingPenalty(activeStack, result.bestAttack.dest)) { if(!canBeHitThisTurn(result.bestAttack)) return result; // lets wait @@ -481,11 +483,6 @@ float BattleExchangeEvaluator::evaluateExchange( DamageCache & damageCache, std::shared_ptr hb) { - if(ap.from.hex == 127) - { - logAi->trace("x"); - } - BattleScore score = calculateExchange(ap, turn, targets, damageCache, hb); #if BATTLE_TRACE_LEVEL >= 1 @@ -887,7 +884,7 @@ bool BattleExchangeEvaluator::checkPositionBlocksOurStacks(HypotheticBattle & hb continue; auto blockedUnitDamage = unit->getMinDamage(hb.battleCanShoot(unit)) * unit->getCount(); - auto ratio = blockedUnitDamage / (blockedUnitDamage + activeUnitDamage); + float ratio = blockedUnitDamage / (float)(blockedUnitDamage + activeUnitDamage + 0.01); auto unitReachability = turnBattle.getReachability(unit); auto unitSpeed = unit->speed(turn); // Cached value, to avoid performance hit