Browse Source

NKAI: more fixes to defense and pandora

Andrii Danylchenko 2 years ago
parent
commit
88fb532d90

+ 1 - 1
AI/Nullkiller/Analyzers/DangerHitMapAnalyzer.cpp

@@ -70,7 +70,7 @@ void DangerHitMapAnalyzer::updateHitMap()
 				auto turn = path.turn();
 				auto & node = hitMap[pos.x][pos.y][pos.z];
 
-				if(tileDanger > node.maximumDanger.danger
+				if(tileDanger / (turn + 1) > node.maximumDanger.danger / (node.maximumDanger.turn + 1)
 					|| (tileDanger == node.maximumDanger.danger && node.maximumDanger.turn > turn))
 				{
 					node.maximumDanger.danger = tileDanger;

+ 2 - 2
AI/Nullkiller/Behaviors/DefenceBehavior.cpp

@@ -30,7 +30,7 @@ namespace NKAI
 extern boost::thread_specific_ptr<CCallback> cb;
 extern boost::thread_specific_ptr<AIGateway> ai;
 
-const double TREAT_IGNORE_RATIO = 0.5;
+const float TREAT_IGNORE_RATIO = 2;
 
 using namespace Goals;
 
@@ -133,7 +133,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
 				tasks.push_back(Goals::sptr(composition));
 			}
 
-			bool treatIsWeak = path.getHeroStrength() / treat.danger > TREAT_IGNORE_RATIO;
+			bool treatIsWeak = path.getHeroStrength() / (float)treat.danger > TREAT_IGNORE_RATIO;
 			bool needToSaveGrowth = treat.turn == 0 && dayOfWeek == 7;
 
 			if(treatIsWeak && !needToSaveGrowth)

+ 1 - 2
AI/Nullkiller/Engine/FuzzyHelper.cpp

@@ -130,8 +130,6 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
 
 		return danger;
 	}
-	case Obj::PANDORAS_BOX:
-		return 10000; //Who knows what awaits us there
 
 	case Obj::ARTIFACT:
 	case Obj::RESOURCE:
@@ -148,6 +146,7 @@ ui64 FuzzyHelper::evaluateDanger(const CGObjectInstance * obj)
 	case Obj::CREATURE_GENERATOR4:
 	case Obj::MINE:
 	case Obj::ABANDONED_MINE:
+	case Obj::PANDORAS_BOX:
 	{
 		const CArmedInstance * a = dynamic_cast<const CArmedInstance *>(obj);
 		return a->getArmyStrength();

+ 4 - 2
AI/Nullkiller/Engine/PriorityEvaluator.cpp

@@ -781,9 +781,11 @@ public:
 		if(garrisonHero && swapCommand.getLockingReason() == HeroLockedReason::DEFENCE)
 		{
 			auto defenderRole = evaluationContext.evaluator.ai->heroManager->getHeroRole(garrisonHero);
+			auto mpLeft = garrisonHero->movement / (float)garrisonHero->maxMovePoints(true);
 
-			evaluationContext.movementCost += garrisonHero->movement;
-			evaluationContext.movementCostByRole[defenderRole] += garrisonHero->movement;
+			evaluationContext.movementCost += mpLeft;
+			evaluationContext.movementCostByRole[defenderRole] += mpLeft;
+			evaluationContext.heroRole = defenderRole;
 		}
 	}
 };

+ 3 - 0
config/ai/object-priorities.txt

@@ -191,7 +191,10 @@ RuleBlock: gold reward
   rule: if armyReward is LOW and heroRole is MAIN and danger is NONE and mainTurnDistance is LOWEST then Value is HIGH
   rule: if skillReward is LOW and heroRole is MAIN and armyLoss is LOW then Value is BITHIGH
   rule: if skillReward is MEDIUM and heroRole is MAIN and armyLoss is LOW and fear is not HIGH then Value is BITHIGH
+  rule: if skillReward is MEDIUM and heroRole is MAIN and rewardType is MIXED and armyLoss is LOW and fear is not HIGH then Value is HIGH with 0.5
   rule: if skillReward is HIGH and heroRole is MAIN and armyLoss is LOW and fear is not HIGH then Value is HIGH
+  rule: if skillReward is MEDIUM and heroRole is SCOUT then Value is LOWEST
+  rule: if skillReward is HIGH and heroRole is SCOUT then Value is LOWEST
   rule: if strategicalValue is LOW and heroRole is MAIN and armyLoss is LOW then Value is BITHIGH
   rule: if strategicalValue is LOWEST and heroRole is MAIN and armyLoss is LOW then Value is LOW
   rule: if strategicalValue is LOW and heroRole is SCOUT and armyLoss is LOW and fear is not HIGH then Value is HIGH with 0.5