diff --git a/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp b/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp index aa85620f3..61b3afe73 100644 --- a/AI/Nullkiller/Behaviors/GatherArmyBehavior.cpp +++ b/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) diff --git a/AI/Nullkiller/Engine/PriorityEvaluator.cpp b/AI/Nullkiller/Engine/PriorityEvaluator.cpp index ca74906d3..187708bb1 100644 --- a/AI/Nullkiller/Engine/PriorityEvaluator.cpp +++ b/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, diff --git a/AI/Nullkiller/Goals/CompleteQuest.cpp b/AI/Nullkiller/Goals/CompleteQuest.cpp index e74f48240..9e4f93a43 100644 --- a/AI/Nullkiller/Goals/CompleteQuest.cpp +++ b/AI/Nullkiller/Goals/CompleteQuest.cpp @@ -120,19 +120,14 @@ std::string CompleteQuest::questToString() const TGoalVec CompleteQuest::tryCompleteQuest() const { - TGoalVec solutions; + auto paths = ai->nullkiller->pathfinder->getPathInfo(q.obj->visitablePos()); - auto tasks = CaptureObjectsBehavior(q.obj).decompose(); - - 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; diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.h b/AI/Nullkiller/Pathfinding/AINodeStorage.h index 44b693c7c..2db675faf 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.h +++ b/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"