1
0
mirror of https://github.com/vcmi/vcmi.git synced 2026-05-22 09:55:17 +02:00

BattleAI: fix shhoters waiting and reduce strength of our loss affecting decissions

This commit is contained in:
Andrii Danylchenko
2024-08-04 17:50:19 +03:00
parent 801e919e7e
commit 51b8bc9fc3
4 changed files with 11 additions and 3 deletions
+4 -2
View File
@@ -249,6 +249,7 @@ EvaluationResult BattleExchangeEvaluator::findBestTarget(
updateReachabilityMap(hb);
if(result.bestAttack.attack.shooting
&& !result.bestAttack.defenderDead
&& !activeStack->waited()
&& hb->battleHasShootingPenalty(activeStack, result.bestAttack.dest))
{
@@ -259,8 +260,9 @@ EvaluationResult BattleExchangeEvaluator::findBestTarget(
for(auto & ap : targets.possibleAttacks)
{
float score = evaluateExchange(ap, 0, targets, damageCache, hb);
bool sameScoreButWaited = vstd::isAlmostEqual(score, result.score) && result.wait;
if(score > result.score || (vstd::isAlmostEqual(score, result.score) && result.wait))
if(score > result.score || sameScoreButWaited)
{
result.score = score;
result.bestAttack = ap;
@@ -729,7 +731,7 @@ std::vector<const battle::Unit *> BattleExchangeEvaluator::getOneTurnReachableUn
{
std::vector<const battle::Unit *> result;
for(int i = 0; i < turnOrder.size(); i++, turn++)
for(int i = 0; i < turnOrder.size(); i++)
{
auto & turnQueue = turnOrder[i];
HypotheticBattle turnBattle(env.get(), cb);