1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

AI-adjustments

AI no longer thinks it can recharge their mana at towns without a mage-guild.
AI no longer treats neutral monsters as if  they were their enemies.
Upgrading armies no longer has it's own priority-tier. It is now handled at the same-priority as hunter-gather.
This commit is contained in:
Xilmi 2025-01-17 17:14:27 +01:00 committed by Ivan Savenko
parent c9f669b41d
commit 8d3970c6d5
2 changed files with 5 additions and 19 deletions

View File

@ -890,7 +890,9 @@ public:
Goals::StayAtTown& stayAtTown = dynamic_cast<Goals::StayAtTown&>(*task); Goals::StayAtTown& stayAtTown = dynamic_cast<Goals::StayAtTown&>(*task);
if(stayAtTown.town->mageGuildLevel() > 0)
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;
else else
@ -1465,6 +1467,8 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
//FALL_THROUGH //FALL_THROUGH
case PriorityTier::FAR_KILL: case PriorityTier::FAR_KILL:
{ {
if (!evaluationContext.isEnemy)
return 0;
if (evaluationContext.turn > 0 && evaluationContext.isHero) if (evaluationContext.turn > 0 && evaluationContext.isHero)
return 0; return 0;
if (arriveNextWeek && evaluationContext.isEnemy) if (arriveNextWeek && evaluationContext.isEnemy)
@ -1480,21 +1484,6 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
score /= evaluationContext.movementCost; score /= evaluationContext.movementCost;
break; break;
} }
case PriorityTier::UPGRADE:
{
if (!evaluationContext.isArmyUpgrade)
return 0;
if (evaluationContext.enemyHeroDangerRatio > dangerThreshold)
return 0;
if (maxWillingToLose - evaluationContext.armyLossPersentage < 0)
return 0;
if (vstd::isAlmostZero(evaluationContext.armyLossPersentage) && evaluationContext.closestWayRatio < 1.0)
return 0;
score = 1000;
if (evaluationContext.movementCost > 0)
score /= evaluationContext.movementCost;
break;
}
case PriorityTier::HIGH_PRIO_EXPLORE: case PriorityTier::HIGH_PRIO_EXPLORE:
{ {
if (evaluationContext.enemyHeroDangerRatio > dangerThreshold) if (evaluationContext.enemyHeroDangerRatio > dangerThreshold)
@ -1522,8 +1511,6 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
return 0; return 0;
if (evaluationContext.explorePriority == 3) if (evaluationContext.explorePriority == 3)
return 0; return 0;
if (evaluationContext.isArmyUpgrade)
return 0;
if ((evaluationContext.enemyHeroDangerRatio > 0 && arriveNextWeek) || evaluationContext.enemyHeroDangerRatio > dangerThreshold) if ((evaluationContext.enemyHeroDangerRatio > 0 && arriveNextWeek) || evaluationContext.enemyHeroDangerRatio > dangerThreshold)
return 0; return 0;
if (maxWillingToLose - evaluationContext.armyLossPersentage < 0) if (maxWillingToLose - evaluationContext.armyLossPersentage < 0)

View File

@ -115,7 +115,6 @@ public:
INSTAKILL, INSTAKILL,
INSTADEFEND, INSTADEFEND,
KILL, KILL,
UPGRADE,
HIGH_PRIO_EXPLORE, HIGH_PRIO_EXPLORE,
HUNTER_GATHER, HUNTER_GATHER,
LOW_PRIO_EXPLORE, LOW_PRIO_EXPLORE,