mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
Update PriorityEvaluator.cpp
AI is more careful when gathering stuff near enemies. The wasted movement-points are no longer considered when calculating which own city to fall back to when there's nothing better to do.
This commit is contained in:
parent
4a5ecdf25e
commit
f7a961793a
@ -909,18 +909,21 @@ public:
|
|||||||
class StayAtTownManaRecoveryEvaluator : public IEvaluationContextBuilder
|
class StayAtTownManaRecoveryEvaluator : public IEvaluationContextBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
|
void buildEvaluationContext(EvaluationContext& evaluationContext, Goals::TSubgoal task) const override
|
||||||
{
|
{
|
||||||
if(task->goalType != Goals::STAY_AT_TOWN)
|
if (task->goalType != Goals::STAY_AT_TOWN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Goals::StayAtTown & stayAtTown = dynamic_cast<Goals::StayAtTown &>(*task);
|
Goals::StayAtTown& stayAtTown = dynamic_cast<Goals::StayAtTown&>(*task);
|
||||||
|
|
||||||
evaluationContext.armyReward += evaluationContext.evaluator.getManaRecoveryArmyReward(stayAtTown.getHero());
|
evaluationContext.armyReward += evaluationContext.evaluator.getManaRecoveryArmyReward(stayAtTown.getHero());
|
||||||
if (evaluationContext.armyReward == 0)
|
if (evaluationContext.armyReward == 0)
|
||||||
evaluationContext.isDefend = true;
|
evaluationContext.isDefend = true;
|
||||||
evaluationContext.movementCostByRole[evaluationContext.heroRole] += stayAtTown.getMovementWasted();
|
else
|
||||||
evaluationContext.movementCost += stayAtTown.getMovementWasted();
|
{
|
||||||
|
evaluationContext.movementCost += stayAtTown.getMovementWasted();
|
||||||
|
evaluationContext.movementCostByRole[evaluationContext.heroRole] += stayAtTown.getMovementWasted();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1428,6 +1431,8 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
return 0;
|
return 0;
|
||||||
if (evaluationContext.isArmyUpgrade)
|
if (evaluationContext.isArmyUpgrade)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (evaluationContext.enemyHeroDangerRatio > 0 && arriveNextWeek)
|
||||||
|
return 0;
|
||||||
score += evaluationContext.strategicalValue * 1000;
|
score += evaluationContext.strategicalValue * 1000;
|
||||||
score += evaluationContext.goldReward;
|
score += evaluationContext.goldReward;
|
||||||
score += evaluationContext.skillReward * evaluationContext.armyInvolvement * (1 - evaluationContext.armyLossPersentage) * 0.05;
|
score += evaluationContext.skillReward * evaluationContext.armyInvolvement * (1 - evaluationContext.armyLossPersentage) * 0.05;
|
||||||
@ -1438,8 +1443,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
|||||||
if (score > 0)
|
if (score > 0)
|
||||||
{
|
{
|
||||||
score *= evaluationContext.closestWayRatio;
|
score *= evaluationContext.closestWayRatio;
|
||||||
if (evaluationContext.enemyHeroDangerRatio > 1)
|
score /= (1 + evaluationContext.enemyHeroDangerRatio);
|
||||||
score /= evaluationContext.enemyHeroDangerRatio;
|
|
||||||
if (evaluationContext.movementCost > 0)
|
if (evaluationContext.movementCost > 0)
|
||||||
score /= evaluationContext.movementCost;
|
score /= evaluationContext.movementCost;
|
||||||
score *= (maxWillingToLose - evaluationContext.armyLossPersentage);
|
score *= (maxWillingToLose - evaluationContext.armyLossPersentage);
|
||||||
|
Loading…
Reference in New Issue
Block a user