Pārlūkot izejas kodu

Nullkiller: stabilization

Andrii Danylchenko 4 gadi atpakaļ
vecāks
revīzija
cf4484e071

+ 1 - 1
AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp

@@ -78,7 +78,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const CGHeroInstance * her
 	auto paths = ai->nullkiller->pathfinder->getPathInfo(pos);
 
 #if AI_TRACE_LEVEL >= 1
-	logAi->trace("Found %d paths", paths.size());
+	logAi->trace("Gather army found %d paths", paths.size());
 #endif
 
 	for(const AIPath & path : paths)

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

@@ -712,7 +712,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task)
 		logAi->error("evaluate VisitTile: %s", fe.getWhat());
 	}
 
-#ifdef AI_TRACE_LEVEL >= 1
+#ifdef AI_TRACE_LEVEL >= 2
 	logAi->trace("Evaluated %s, loss: %f, turn: %d, turns main: %f, scout: %f, gold: %d, cost: %d, army gain: %d, danger: %d, role: %s, strategical value: %f, cwr: %f, fear: %f, result %f",
 		task->toString(),
 		evaluationContext.armyLossPersentage,

+ 7 - 12
AI/Nullkiller/Goals/CompleteQuest.cpp

@@ -120,19 +120,14 @@ std::string CompleteQuest::questToString() const
 
 TGoalVec CompleteQuest::tryCompleteQuest() const
 {
-	TGoalVec solutions;
-
-	auto tasks = CaptureObjectsBehavior(q.obj).decompose();
+	auto paths = ai->nullkiller->pathfinder->getPathInfo(q.obj->visitablePos());
 
-	for(auto task : tasks)
+	vstd::erase_if(paths, [&](const AIPath & path) -> bool
 	{
-		if(task->hero && q.quest->checkQuest(task->hero.get()))
-		{
-			solutions.push_back(task);
-		}
-	}
-
-	return solutions;
+		return !q.quest->checkQuest(path.targetHero);
+	});
+	
+	return CaptureObjectsBehavior::getVisitGoals(paths, q.obj);
 }
 
 TGoalVec CompleteQuest::missionArt() const
@@ -159,7 +154,7 @@ TGoalVec CompleteQuest::missionHero() const
 	if(solutions.empty())
 	{
 		//rule of a thumb - quest heroes usually are locked in prisons
-		return CaptureObjectsBehavior().ofType(Obj::PRISON).decompose();
+		solutions.push_back(sptr(CaptureObjectsBehavior().ofType(Obj::PRISON)));
 	}
 
 	return solutions;

+ 1 - 1
AI/Nullkiller/Pathfinding/AINodeStorage.h

@@ -11,7 +11,7 @@
 #pragma once
 
 #define PATHFINDER_TRACE_LEVEL 0
-#define AI_TRACE_LEVEL 1
+#define AI_TRACE_LEVEL 0
 #define SCOUT_TURN_DISTANCE_LIMIT 3
 
 #include "../../../lib/CPathfinder.h"