mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Fix for defense-evaluation.
Defense-evaluation didn't fill armyInvolvement but it was what created the score for it. So there was only score if it also included a HeroExchange.
This commit is contained in:
parent
b8dacfc0be
commit
dcec5637cd
@ -1141,6 +1141,14 @@ public:
|
|||||||
Goals::ExchangeSwapTownHeroes & swapCommand = dynamic_cast<Goals::ExchangeSwapTownHeroes &>(*task);
|
Goals::ExchangeSwapTownHeroes & swapCommand = dynamic_cast<Goals::ExchangeSwapTownHeroes &>(*task);
|
||||||
const CGHeroInstance * garrisonHero = swapCommand.getGarrisonHero();
|
const CGHeroInstance * garrisonHero = swapCommand.getGarrisonHero();
|
||||||
|
|
||||||
|
logAi->trace("buildEvaluationContext ExchangeSwapTownHeroesContextBuilder %s affected objects: %d", swapCommand.toString(), swapCommand.getAffectedObjects().size());
|
||||||
|
for (auto obj : swapCommand.getAffectedObjects())
|
||||||
|
{
|
||||||
|
logAi->trace("affected object: %s", evaluationContext.evaluator.ai->cb->getObj(obj)->getObjectName());
|
||||||
|
}
|
||||||
|
if (garrisonHero)
|
||||||
|
logAi->debug("with %s and %d", garrisonHero->getNameTranslated(), int(swapCommand.getLockingReason()));
|
||||||
|
|
||||||
if(garrisonHero && swapCommand.getLockingReason() == HeroLockedReason::DEFENCE)
|
if(garrisonHero && swapCommand.getLockingReason() == HeroLockedReason::DEFENCE)
|
||||||
{
|
{
|
||||||
auto defenderRole = evaluationContext.evaluator.ai->heroManager->getHeroRole(garrisonHero);
|
auto defenderRole = evaluationContext.evaluator.ai->heroManager->getHeroRole(garrisonHero);
|
||||||
@ -1149,6 +1157,9 @@ public:
|
|||||||
evaluationContext.movementCost += mpLeft;
|
evaluationContext.movementCost += mpLeft;
|
||||||
evaluationContext.movementCostByRole[defenderRole] += mpLeft;
|
evaluationContext.movementCostByRole[defenderRole] += mpLeft;
|
||||||
evaluationContext.heroRole = defenderRole;
|
evaluationContext.heroRole = defenderRole;
|
||||||
|
evaluationContext.isDefend = true;
|
||||||
|
evaluationContext.armyInvolvement = garrisonHero->getArmyStrength();
|
||||||
|
logAi->debug("evaluationContext.isDefend: %d", evaluationContext.isDefend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1360,7 +1371,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
float score = 0;
|
float score = 0;
|
||||||
float maxWillingToLose = ai->cb->getTownsInfo().empty() ? 1 : 0.25;
|
float maxWillingToLose = ai->cb->getTownsInfo().empty() ? 1 : 0.25;
|
||||||
|
|
||||||
logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, turn: %d, turns main: %f, scout: %f, gold: %f, cost: %d, army gain: %f, army growth: %f skill: %f danger: %d, threatTurns: %d, threat: %d, role: %s, strategical value: %f, conquest value: %f cwr: %f, fear: %f, fuzzy: %f",
|
logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, turn: %d, turns main: %f, scout: %f, gold: %f, cost: %d, army gain: %f, army growth: %f skill: %f danger: %d, threatTurns: %d, threat: %d, role: %s, strategical value: %f, conquest value: %f cwr: %f, fear: %f, isDefend: %d, fuzzy: %f",
|
||||||
priorityTier,
|
priorityTier,
|
||||||
task->toString(),
|
task->toString(),
|
||||||
evaluationContext.armyLossPersentage,
|
evaluationContext.armyLossPersentage,
|
||||||
@ -1380,6 +1391,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
evaluationContext.conquestValue,
|
evaluationContext.conquestValue,
|
||||||
evaluationContext.closestWayRatio,
|
evaluationContext.closestWayRatio,
|
||||||
evaluationContext.enemyHeroDangerRatio,
|
evaluationContext.enemyHeroDangerRatio,
|
||||||
|
evaluationContext.isDefend,
|
||||||
fuzzyResult);
|
fuzzyResult);
|
||||||
|
|
||||||
switch (priorityTier)
|
switch (priorityTier)
|
||||||
@ -1389,8 +1401,6 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
if (evaluationContext.isDefend && evaluationContext.threatTurns == 0 && evaluationContext.turn == 0)
|
if (evaluationContext.isDefend && evaluationContext.threatTurns == 0 && evaluationContext.turn == 0)
|
||||||
score = evaluationContext.armyInvolvement;
|
score = evaluationContext.armyInvolvement;
|
||||||
score *= evaluationContext.closestWayRatio;
|
score *= evaluationContext.closestWayRatio;
|
||||||
if (evaluationContext.movementCost > 0)
|
|
||||||
score /= evaluationContext.movementCost;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: //Take towns
|
case 2: //Take towns
|
||||||
@ -1468,8 +1478,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
if (evaluationContext.isDefend)
|
if (evaluationContext.isDefend)
|
||||||
score = evaluationContext.armyInvolvement;
|
score = evaluationContext.armyInvolvement;
|
||||||
score *= evaluationContext.closestWayRatio;
|
score *= evaluationContext.closestWayRatio;
|
||||||
if (evaluationContext.movementCost > 0)
|
score /= (evaluationContext.turn + 1);
|
||||||
score /= evaluationContext.movementCost;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0: //For buildings and buying army
|
case 0: //For buildings and buying army
|
||||||
|
Loading…
x
Reference in New Issue
Block a user