Sfoglia il codice sorgente

lowered aggression

Being less willing to rush across half the map to attack an enemy town only to find it too well defended when arriving there.
Xilmi 1 anno fa
parent
commit
8ad6d712c0

+ 9 - 1
AI/Nullkiller/Engine/PriorityEvaluator.cpp

@@ -62,7 +62,8 @@ EvaluationContext::EvaluationContext(const Nullkiller* ai)
 	threatTurns(INT_MAX),
 	involvesSailing(false),
 	isTradeBuilding(false),
-	isChain(false)
+	isChain(false),
+	isEnemy(false)
 {
 }
 
@@ -1068,6 +1069,8 @@ public:
 			evaluationContext.conquestValue += evaluationContext.evaluator.getConquestValue(target);
 			evaluationContext.goldCost += evaluationContext.evaluator.getGoldCost(target, hero, army);
 			evaluationContext.armyInvolvement += army->getArmyCost();
+			if (target->tempOwner != PlayerColor::NEUTRAL)
+				evaluationContext.isEnemy = true;
 		}
 
 		vstd::amax(evaluationContext.armyLossPersentage, path.getTotalArmyLoss() / (double)path.getHeroStrength());
@@ -1116,6 +1119,9 @@ public:
 			evaluationContext.movementCostByRole[role] += objInfo.second.movementCost / boost;
 			evaluationContext.movementCost += objInfo.second.movementCost / boost;
 
+			if (target->tempOwner != PlayerColor::NEUTRAL)
+				evaluationContext.isEnemy = true;
+
 			vstd::amax(evaluationContext.turn, objInfo.second.turn / boost);
 
 			boost <<= 1;
@@ -1385,6 +1391,8 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
 				//score += evaluationContext.conquestValue * 1000;
 				if(evaluationContext.conquestValue > 0 || (evaluationContext.defenseValue >= CGTownInstance::EFortLevel::CITADEL && evaluationContext.turn <= 1 && evaluationContext.threat > evaluationContext.armyInvolvement && evaluationContext.threatTurns == 0))
 					score = 1000;
+				if (evaluationContext.isEnemy && evaluationContext.turn > 0 && !ai->cb->getTownsInfo().empty())
+					return 0;
 				if (score == 0 || (evaluationContext.enemyHeroDangerRatio > 1 && evaluationContext.turn > 0 && !ai->cb->getTownsInfo().empty()))
 					return 0;
 				if (maxWillingToLose - evaluationContext.armyLossPersentage < 0)

+ 1 - 0
AI/Nullkiller/Engine/PriorityEvaluator.h

@@ -80,6 +80,7 @@ struct DLL_EXPORT EvaluationContext
 	bool involvesSailing;
 	bool isTradeBuilding;
 	bool isChain;
+	bool isEnemy;
 
 	EvaluationContext(const Nullkiller * ai);