1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

AINodeStorage.h NKAI #define to NK2AI

This commit is contained in:
Mircea TheHonestCTO
2025-08-24 21:15:34 +02:00
parent 22b2a425c4
commit 54b3d17bcf
21 changed files with 133 additions and 133 deletions

View File

@@ -11,7 +11,7 @@
#pragma once #pragma once
#define NKAI_PATHFINDER_TRACE_LEVEL 0 #define NKAI_PATHFINDER_TRACE_LEVEL 0
constexpr int NKAI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat constexpr int NK2AI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat
#define NKAI_TRACE_LEVEL 0 #define NKAI_TRACE_LEVEL 0
#include "../../../lib/pathfinder/CGPathNode.h" #include "../../../lib/pathfinder/CGPathNode.h"

View File

@@ -173,7 +173,7 @@ void AIPathfinder::updateGraphs(
} }
}); });
if(NKAI_GRAPH_TRACE_LEVEL >= 1) if(NK2AI_GRAPH_TRACE_LEVEL >= 1)
{ {
for(auto hero : heroes) for(auto hero : heroes)
{ {

View File

@@ -49,7 +49,7 @@ void BuildAnalyzer::update()
if(town->built >= ccTl->getSettings().getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP)) if(town->built >= ccTl->getSettings().getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP))
continue; // Not much point in trying anything - can't built in this town anymore today continue; // Not much point in trying anything - can't built in this town anymore today
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Checking town %s", town->getNameTranslated()); logAi->trace("Checking town %s", town->getNameTranslated());
#endif #endif
@@ -69,7 +69,7 @@ void BuildAnalyzer::update()
armyCost += tdi.armyCost; armyCost += tdi.armyCost;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
for(const auto & biToBuild : tdi.toBuild) for(const auto & biToBuild : tdi.toBuild)
logAi->trace("Building preferences %s", biToBuild.toString()); logAi->trace("Building preferences %s", biToBuild.toString());
#endif #endif
@@ -192,7 +192,7 @@ float BuildAnalyzer::calculateGoldPressure(TResource lockedGold, float armyCostG
{ {
auto pressure = (lockedGold + armyCostGold + economyDevelopmentCost) / (1 + 2 * freeGold + dailyIncomeGold * 7.0f); auto pressure = (lockedGold + armyCostGold + economyDevelopmentCost) / (1 + 2 * freeGold + dailyIncomeGold * 7.0f);
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Gold pressure: %f", pressure); logAi->trace("Gold pressure: %f", pressure);
#endif #endif
@@ -221,7 +221,7 @@ void BuildAnalyzer::updateDwellings(TownDevelopmentInfo & developmentInfo, std::
{ {
for(int level = 0; level < developmentInfo.town->getTown()->creatures.size(); level++) for(int level = 0; level < developmentInfo.town->getTown()->creatures.size(); level++)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Checking dwelling level %d", level); logAi->trace("Checking dwelling level %d", level);
#endif #endif
std::vector<BuildingID> dwellingsInTown; std::vector<BuildingID> dwellingsInTown;
@@ -372,13 +372,13 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
if(vstd::contains_if(missingBuildings, otherDwelling)) if(vstd::contains_if(missingBuildings, otherDwelling))
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can't build %d. Needs other dwelling %d", b.getNum(), missingBuildings.front().getNum()); logAi->trace("Can't build %d. Needs other dwelling %d", b.getNum(), missingBuildings.front().getNum());
#endif #endif
} }
else if(missingBuildings[0] != b) else if(missingBuildings[0] != b)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can't build %d. Needs %d", b.getNum(), missingBuildings[0].num); logAi->trace("Can't build %d. Needs %d", b.getNum(), missingBuildings[0].num);
#endif #endif
BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], armyManager, cc, excludeDwellingDependencies); BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], armyManager, cc, excludeDwellingDependencies);
@@ -407,7 +407,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
} }
else else
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can't build. The building requires itself as prerequisite"); logAi->trace("Can't build. The building requires itself as prerequisite");
#endif #endif
return info; return info;
@@ -415,14 +415,14 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
} }
else else
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can't build. Reason: %d", static_cast<int>(canBuild)); logAi->trace("Can't build. Reason: %d", static_cast<int>(canBuild));
#endif #endif
} }
} }
else else
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Dwelling %d exists", b.getNum()); logAi->trace("Dwelling %d exists", b.getNum());
#endif #endif
info.isBuilt = true; info.isBuilt = true;

View File

@@ -27,7 +27,7 @@ double HitMapInfo::value() const
void logHitmap(PlayerColor playerID, DangerHitMapAnalyzer & data) void logHitmap(PlayerColor playerID, DangerHitMapAnalyzer & data)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logVisual->updateWithLock(playerID.toString() + ".danger.max", [&data](IVisualLogBuilder & b) logVisual->updateWithLock(playerID.toString() + ".danger.max", [&data](IVisualLogBuilder & b)
{ {
foreach_tile_pos([&b, &data](const int3 & pos) foreach_tile_pos([&b, &data](const int3 & pos)

View File

@@ -332,7 +332,7 @@ void ObjectClusterizer::clusterize()
aiNk->memory->visitableObjs.end()); aiNk->memory->visitableObjs.end());
} }
#if NKAI_TRACE_LEVEL == 0 #if NK2AI_TRACE_LEVEL == 0
tbb::parallel_for(tbb::blocked_range<size_t>(0, objs.size()), [&](const tbb::blocked_range<size_t> & r) { tbb::parallel_for(tbb::blocked_range<size_t>(0, objs.size()), [&](const tbb::blocked_range<size_t> & r) {
#else #else
tbb::blocked_range<size_t> r(0, objs.size()); tbb::blocked_range<size_t> r(0, objs.size());
@@ -345,7 +345,7 @@ void ObjectClusterizer::clusterize()
{ {
clusterizeObject(objs[i], priorityEvaluator.get(), pathCache, heroes); clusterizeObject(objs[i], priorityEvaluator.get(), pathCache, heroes);
} }
#if NKAI_TRACE_LEVEL == 0 #if NK2AI_TRACE_LEVEL == 0
}); });
#endif #endif
@@ -358,7 +358,7 @@ void ObjectClusterizer::clusterize()
logAi->trace("Cluster %s %s count: %i", blocker->getObjectName(), blocker->visitablePos().toString(), pair.second->objects.size()); logAi->trace("Cluster %s %s count: %i", blocker->getObjectName(), blocker->visitablePos().toString(), pair.second->objects.size());
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
for(auto obj : pair.second->getObjects(aiNk->cc.get())) for(auto obj : pair.second->getObjects(aiNk->cc.get()))
{ {
logAi->trace("Object %s %s", obj->getObjectName(), obj->visitablePos().toString()); logAi->trace("Object %s %s", obj->getObjectName(), obj->visitablePos().toString());
@@ -379,13 +379,13 @@ void ObjectClusterizer::clusterizeObject(
{ {
if(!shouldVisitObject(obj)) if(!shouldVisitObject(obj))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Skip object %s%s.", obj->getObjectName(), obj->visitablePos().toString()); logAi->trace("Skip object %s%s.", obj->getObjectName(), obj->visitablePos().toString());
#endif #endif
return; return;
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Check object %s%s.", obj->getObjectName(), obj->visitablePos().toString()); logAi->trace("Check object %s%s.", obj->getObjectName(), obj->visitablePos().toString());
#endif #endif
@@ -398,7 +398,7 @@ void ObjectClusterizer::clusterizeObject(
if(pathCache.empty()) if(pathCache.empty())
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("No paths found."); logAi->trace("No paths found.");
#endif #endif
return; return;
@@ -413,7 +413,7 @@ void ObjectClusterizer::clusterizeObject(
{ {
farObjects.addObject(obj, pathCache.front(), 0); farObjects.addObject(obj, pathCache.front(), 0);
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Object ignored. Moved to far objects with path %s", pathCache.front().toString()); logAi->trace("Object ignored. Moved to far objects with path %s", pathCache.front().toString());
#endif #endif
@@ -424,7 +424,7 @@ void ObjectClusterizer::clusterizeObject(
for(auto & path : pathCache) for(auto & path : pathCache)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("ObjectClusterizer Checking path %s", path.toString()); logAi->trace("ObjectClusterizer Checking path %s", path.toString());
#endif #endif
@@ -435,7 +435,7 @@ void ObjectClusterizer::clusterizeObject(
// if(path.movementCost() > 2.0f) // if(path.movementCost() > 2.0f)
if(path.movementCost() > aiNk->settings->getScoutHeroTurnDistanceLimit()) if(path.movementCost() > aiNk->settings->getScoutHeroTurnDistanceLimit())
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path is too far %f", path.movementCost()); logAi->trace("Path is too far %f", path.movementCost());
#endif #endif
continue; continue;
@@ -448,7 +448,7 @@ void ObjectClusterizer::clusterizeObject(
if(strategicalValue < MINIMUM_STRATEGICAL_VALUE_NON_TOWN) if(strategicalValue < MINIMUM_STRATEGICAL_VALUE_NON_TOWN)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Object value is too low %f", strategicalValue); logAi->trace("Object value is too low %f", strategicalValue);
#endif #endif
continue; continue;
@@ -457,7 +457,7 @@ void ObjectClusterizer::clusterizeObject(
if(!shouldVisit(aiNk, path.targetHero, obj)) if(!shouldVisit(aiNk, path.targetHero, obj))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Hero %s shouldn't visit %s", path.targetHero->getObjectName(), obj->getObjectName()); logAi->trace("Hero %s shouldn't visit %s", path.targetHero->getObjectName(), obj->getObjectName());
#endif #endif
continue; continue;
@@ -473,7 +473,7 @@ void ObjectClusterizer::clusterizeObject(
{ {
if(vstd::contains(heroesProcessed, path.targetHero)) if(vstd::contains(heroesProcessed, path.targetHero))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Hero %s is already processed.", path.targetHero->getObjectName()); logAi->trace("Hero %s is already processed.", path.targetHero->getObjectName());
#endif #endif
continue; continue;
@@ -498,7 +498,7 @@ void ObjectClusterizer::clusterizeObject(
cluster->second->addObject(obj, path, priority); cluster->second->addObject(obj, path, priority);
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path added to cluster %s%s", blocker->getObjectName(), blocker->visitablePos().toString()); logAi->trace("Path added to cluster %s%s", blocker->getObjectName(), blocker->visitablePos().toString());
#endif #endif
continue; continue;
@@ -529,7 +529,7 @@ void ObjectClusterizer::clusterizeObject(
farObjects.addObject(obj, path, priority); farObjects.addObject(obj, path, priority);
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path %s added to %s objects. Turn: %d, priority: %f", logAi->trace("Path %s added to %s objects. Turn: %d, priority: %f",
path.toString(), path.toString(),
interestingObject ? "near" : "far", interestingObject ? "near" : "far",

View File

@@ -64,13 +64,13 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
{ {
tasks.push_back(sptr(Goals::Invalid())); tasks.push_back(sptr(Goals::Invalid()));
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path found %s", path.toString()); logAi->trace("Path found %s", path.toString());
#endif #endif
if(objToVisit && !force && !shouldVisit(nullkiller, path.targetHero, objToVisit)) if(objToVisit && !force && !shouldVisit(nullkiller, path.targetHero, objToVisit))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Hero %s should not visit obj %s", path.targetHero->getNameTranslated(), objToVisit->getObjectName()); logAi->trace("Ignore path. Hero %s should not visit obj %s", path.targetHero->getNameTranslated(), objToVisit->getObjectName());
#endif #endif
continue; continue;
@@ -86,7 +86,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
&& (path.getTotalDanger() == 0 || path.turn() > 0) && (path.getTotalDanger() == 0 || path.turn() > 0)
&& path.exchangeCount > 1) && path.exchangeCount > 1)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Hero %s is SCOUT, chain used and no danger", path.targetHero->getNameTranslated()); logAi->trace("Ignore path. Hero %s is SCOUT, chain used and no danger", path.targetHero->getNameTranslated());
#endif #endif
continue; continue;
@@ -97,7 +97,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
{ {
auto subGoal = firstBlockedAction->decompose(nullkiller, path.targetHero); auto subGoal = firstBlockedAction->decompose(nullkiller, path.targetHero);
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Decomposing special action %s returns %s", firstBlockedAction->toString(), subGoal->toString()); logAi->trace("Decomposing special action %s returns %s", firstBlockedAction->toString(), subGoal->toString());
#endif #endif
@@ -116,7 +116,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, nullkiller->settings->getSafeAttackRatio()); auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, nullkiller->settings->getSafeAttackRatio());
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld", "It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
isSafe ? "safe" : "not safe", isSafe ? "safe" : "not safe",
@@ -195,13 +195,13 @@ void CaptureObjectsBehavior::decomposeObjects(
if(!objectMatchesFilter(objToVisit)) if(!objectMatchesFilter(objToVisit))
continue; continue;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Checking object %s, %s", objToVisit->getObjectName(), objToVisit->visitablePos().toString()); logAi->trace("Checking object %s, %s", objToVisit->getObjectName(), objToVisit->visitablePos().toString());
#endif #endif
nullkiller->pathfinder->calculatePathInfo(paths, objToVisit->visitablePos(), nullkiller->isObjectGraphAllowed()); nullkiller->pathfinder->calculatePathInfo(paths, objToVisit->visitablePos(), nullkiller->isObjectGraphAllowed());
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Found %d paths", paths.size()); logAi->trace("Found %d paths", paths.size());
#endif #endif
vstd::concatenate(tasksLocal, getVisitGoals(paths, nullkiller, objToVisit, specificObjects)); vstd::concatenate(tasksLocal, getVisitGoals(paths, nullkiller, objToVisit, specificObjects));

View File

@@ -51,7 +51,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
TGoalVec goals; TGoalVec goals;
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Checking cluster %s %s, found %d paths", "Checking cluster %s %s, found %d paths",
cluster->blocker->getObjectName(), cluster->blocker->getObjectName(),
@@ -61,7 +61,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
for(auto path = paths.begin(); path != paths.end();) for(auto path = paths.begin(); path != paths.end();)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("ClusterBehavior Checking path %s", path->toString()); logAi->trace("ClusterBehavior Checking path %s", path->toString());
#endif #endif
@@ -90,13 +90,13 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
for(auto & node : clonedPath.nodes) for(auto & node : clonedPath.nodes)
node.parentIndex -= path->nodes.size() - clonedPath.nodes.size(); node.parentIndex -= path->nodes.size() - clonedPath.nodes.size();
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Unlock path found %s", blockerPaths.back().toString()); logAi->trace("Unlock path found %s", blockerPaths.back().toString());
#endif #endif
path++; path++;
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Decompose unlock paths"); logAi->trace("Decompose unlock paths");
#endif #endif

View File

@@ -61,7 +61,7 @@ bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat
|| path.turn() < threat.turn - 1 || path.turn() < threat.turn - 1
|| (path.turn() < threat.turn && threat.turn >= 2)) || (path.turn() < threat.turn && threat.turn >= 2))
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Hero %s can eliminate danger for town %s using path %s.", "Hero %s can eliminate danger for town %s using path %s.",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
@@ -151,7 +151,7 @@ bool handleGarrisonHeroFromPreviousTurn(const CGTownInstance * town, Goals::TGoa
void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * aiNk) const void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * aiNk) const
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Evaluating defence for %s", town->getNameTranslated()); logAi->trace("Evaluating defence for %s", town->getNameTranslated());
#endif #endif
@@ -166,7 +166,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
} }
if(!threatNode.fastestDanger.hero) if(!threatNode.fastestDanger.hero)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("No threat found for town %s", town->getNameTranslated()); logAi->trace("No threat found for town %s", town->getNameTranslated());
#endif #endif
return; return;
@@ -176,7 +176,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if(reinforcement) if(reinforcement)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Town %s can buy defence army %lld", town->getNameTranslated(), reinforcement); logAi->trace("Town %s can buy defence army %lld", town->getNameTranslated(), reinforcement);
#endif #endif
tasks.push_back(Goals::sptr(Goals::BuyArmy(town, reinforcement).setpriority(0.5f))); tasks.push_back(Goals::sptr(Goals::BuyArmy(town, reinforcement).setpriority(0.5f)));
@@ -186,7 +186,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
for(auto & threat : threats) for(auto & threat : threats)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Town %s has threat %lld in %s turns, hero: %s", "Town %s has threat %lld in %s turns, hero: %s",
town->getNameTranslated(), town->getNameTranslated(),
@@ -205,7 +205,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if(paths.empty()) if(paths.empty())
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("No ways to defend town %s", town->getNameTranslated()); logAi->trace("No ways to defend town %s", town->getNameTranslated());
#endif #endif
@@ -223,7 +223,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if (!closestWay || path.movementCost() < closestWay->movementCost()) if (!closestWay || path.movementCost() < closestWay->movementCost())
closestWay = &path; closestWay = &path;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Hero %s can defend town with force %lld in %s turns, cost: %f, path: %s", "Hero %s can defend town with force %lld in %s turns, cost: %f, path: %s",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
@@ -250,7 +250,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if(path.turn() <= threat.turn - 2) if(path.turn() <= threat.turn - 2)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Defer defence of %s by %s because he has enough time to reach the town next turn", logAi->trace("Defer defence of %s by %s because he has enough time to reach the town next turn",
town->getObjectName(), town->getObjectName(),
path.targetHero->getObjectName()); path.targetHero->getObjectName());
@@ -263,7 +263,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if (!path.targetHero->canBeMergedWith(*town)) if (!path.targetHero->canBeMergedWith(*town))
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can't merge armies of hero %s and town %s", logAi->trace("Can't merge armies of hero %s and town %s",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -273,7 +273,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
if(path.targetHero == town->getVisitingHero() && path.exchangeCount == 1) if(path.targetHero == town->getVisitingHero() && path.exchangeCount == 1)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Put %s to garrison of town %s", logAi->trace("Put %s to garrison of town %s",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -318,7 +318,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
{ {
if(aiNk->arePathHeroesLocked(path)) if(aiNk->arePathHeroesLocked(path))
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Can not move %s to defend town %s. Path is locked.", logAi->trace("Can not move %s to defend town %s. Path is locked.",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -355,7 +355,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
composition.addNext(ExchangeSwapTownHeroes(town, town->getGarrisonHero(), HeroLockedReason::DEFENCE)); composition.addNext(ExchangeSwapTownHeroes(town, town->getGarrisonHero(), HeroLockedReason::DEFENCE));
tasks.push_back(Goals::sptr(composition)); tasks.push_back(Goals::sptr(composition));
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Locking hero %s in garrison of %s", logAi->trace("Locking hero %s in garrison of %s",
town->getGarrisonHero()->getObjectName(), town->getGarrisonHero()->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -367,7 +367,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
{ {
if(town->getGarrisonHero() && town->getGarrisonHero() != path.targetHero) if(town->getGarrisonHero() && town->getGarrisonHero() != path.targetHero)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Cancel moving %s to defend town %s as the town has garrison hero", logAi->trace("Cancel moving %s to defend town %s as the town has garrison hero",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -380,7 +380,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
} }
} }
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Move %s to defend town %s", logAi->trace("Move %s to defend town %s",
path.targetHero->getObjectName(), path.targetHero->getObjectName(),
town->getObjectName()); town->getObjectName());
@@ -401,13 +401,13 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
{ {
auto subGoal = firstBlockedAction->decompose(aiNk, path.targetHero); auto subGoal = firstBlockedAction->decompose(aiNk, path.targetHero);
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Decomposing special action %s returns %s", firstBlockedAction->toString(), subGoal->toString()); logAi->trace("Decomposing special action %s returns %s", firstBlockedAction->toString(), subGoal->toString());
#endif #endif
if(subGoal->invalid()) if(subGoal->invalid())
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Path is invalid. Skipping"); logAi->trace("Path is invalid. Skipping");
#endif #endif
continue; continue;
@@ -458,7 +458,7 @@ void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitM
auto myHeroes = aiNk->cc->getHeroesInfo(); auto myHeroes = aiNk->cc->getHeroesInfo();
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Hero %s can be recruited to defend %s", hero->getObjectName(), town->getObjectName()); logAi->trace("Hero %s can be recruited to defend %s", hero->getObjectName(), town->getObjectName());
#endif #endif
bool needSwap = false; bool needSwap = false;

View File

@@ -65,19 +65,19 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
const int3 pos = hero->visitablePos(); const int3 pos = hero->visitablePos();
auto targetHeroScore = aiNk->heroManager->evaluateHero(hero); auto targetHeroScore = aiNk->heroManager->evaluateHero(hero);
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Checking ways to gaher army for hero %s, %s", hero->getObjectName(), pos.toString()); logAi->trace("Checking ways to gaher army for hero %s, %s", hero->getObjectName(), pos.toString());
#endif #endif
auto paths = aiNk->pathfinder->getPathInfo(pos, aiNk->isObjectGraphAllowed()); auto paths = aiNk->pathfinder->getPathInfo(pos, aiNk->isObjectGraphAllowed());
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Gather army found %d paths", paths.size()); logAi->trace("Gather army found %d paths", paths.size());
#endif #endif
for(const AIPath & path : paths) for(const AIPath & path : paths)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path found %s, %s, %lld", path.toString(), path.targetHero->getObjectName(), path.heroArmy->getArmyStrength()); logAi->trace("Path found %s, %s, %lld", path.toString(), path.targetHero->getObjectName(), path.heroArmy->getArmyStrength());
#endif #endif
@@ -86,7 +86,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
if(path.containsHero(hero)) if(path.containsHero(hero))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Selfcontaining path. Ignore"); logAi->trace("Selfcontaining path. Ignore");
#endif #endif
continue; continue;
@@ -94,7 +94,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
if(aiNk->arePathHeroesLocked(path)) if(aiNk->arePathHeroesLocked(path))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path because of locked hero"); logAi->trace("Ignore path because of locked hero");
#endif #endif
continue; continue;
@@ -108,7 +108,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
// avoid transferring very small amount of army // avoid transferring very small amount of army
if((armyRatio < 0.1f && armyValue < 20000) || armyValue < 500) if((armyRatio < 0.1f && armyValue < 20000) || armyValue < 500)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Army value is too small."); logAi->trace("Army value is too small.");
#endif #endif
continue; continue;
@@ -138,7 +138,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
if(hasOtherMainInPath) if(hasOtherMainInPath)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Army value is too large."); logAi->trace("Army value is too large.");
#endif #endif
continue; continue;
@@ -147,7 +147,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
auto danger = path.getTotalDanger(); auto danger = path.getTotalDanger();
auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio()); auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio());
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld", "It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
isSafe ? "safe" : "not safe", isSafe ? "safe" : "not safe",
@@ -193,14 +193,14 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
if(blockedAction) if(blockedAction)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Action is blocked. Considering decomposition."); logAi->trace("Action is blocked. Considering decomposition.");
#endif #endif
auto subGoal = blockedAction->decompose(aiNk, path.targetHero); auto subGoal = blockedAction->decompose(aiNk, path.targetHero);
if(subGoal->invalid()) if(subGoal->invalid())
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Path is invalid. Skipping"); logAi->trace("Path is invalid. Skipping");
#endif #endif
continue; continue;
@@ -222,7 +222,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
const int3 pos = upgrader->visitablePos(); const int3 pos = upgrader->visitablePos();
TResources availableResources = aiNk->getFreeResources(); TResources availableResources = aiNk->getFreeResources();
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Checking ways to upgrade army in town %s, %s", upgrader->getObjectName(), pos.toString()); logAi->trace("Checking ways to upgrade army in town %s, %s", upgrader->getObjectName(), pos.toString());
#endif #endif
@@ -231,7 +231,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
std::vector<std::shared_ptr<ExecuteHeroChain>> waysToVisitObj; std::vector<std::shared_ptr<ExecuteHeroChain>> waysToVisitObj;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Found %d paths", paths.size()); logAi->trace("Found %d paths", paths.size());
#endif #endif
@@ -250,13 +250,13 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
auto & path = paths[i]; auto & path = paths[i];
auto visitGoal = goals[i]; auto visitGoal = goals[i];
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Path found %s, %s, %lld", path.toString(), path.targetHero->getObjectName(), path.heroArmy->getArmyStrength()); logAi->trace("Path found %s, %s, %lld", path.toString(), path.targetHero->getObjectName(), path.heroArmy->getArmyStrength());
#endif #endif
if(visitGoal->invalid()) if(visitGoal->invalid())
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Not valid way."); logAi->trace("Ignore path. Not valid way.");
#endif #endif
continue; continue;
@@ -264,7 +264,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
if(upgrader->getVisitingHero() && (upgrader->getVisitingHero() != path.targetHero || path.exchangeCount == 1)) if(upgrader->getVisitingHero() && (upgrader->getVisitingHero() != path.targetHero || path.exchangeCount == 1))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Town has visiting hero."); logAi->trace("Ignore path. Town has visiting hero.");
#endif #endif
continue; continue;
@@ -272,7 +272,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
if(aiNk->arePathHeroesLocked(path)) if(aiNk->arePathHeroesLocked(path))
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path because of locked hero"); logAi->trace("Ignore path because of locked hero");
#endif #endif
continue; continue;
@@ -280,7 +280,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
if(path.getFirstBlockedAction()) if(path.getFirstBlockedAction())
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
// TODO: decomposition? // TODO: decomposition?
logAi->trace("Ignore path. Action is blocked."); logAi->trace("Ignore path. Action is blocked.");
#endif #endif
@@ -332,7 +332,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
// TODO: Mircea: Move to constant // TODO: Mircea: Move to constant
if((armyValue < 0.25f && upgrade.upgradeValue < 40000) || upgrade.upgradeValue < 2000) // avoid small upgrades if((armyValue < 0.25f && upgrade.upgradeValue < 40000) || upgrade.upgradeValue < 2000) // avoid small upgrades
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Army value is too small (%f)", armyValue); logAi->trace("Ignore path. Army value is too small (%f)", armyValue);
#endif #endif
continue; continue;
@@ -341,7 +341,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
auto danger = path.getTotalDanger(); auto danger = path.getTotalDanger();
auto isSafe = isSafeToVisit(path.targetHero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio()); auto isSafe = isSafeToVisit(path.targetHero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio());
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld", "It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
isSafe ? "safe" : "not safe", isSafe ? "safe" : "not safe",

View File

@@ -52,7 +52,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
TSubgoal current = goals[depth].back(); TSubgoal current = goals[depth].back();
TGoalVec subgoals = decomposeCached(unwrapComposition(current), fromCache); TGoalVec subgoals = decomposeCached(unwrapComposition(current), fromCache);
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Decomposition level %d returned %d goals", depth, subgoals.size()); logAi->trace("Decomposition level %d returned %d goals", depth, subgoals.size());
#endif #endif
@@ -74,7 +74,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
// TODO: Mircea: Issue with CGameHandler::spawnWanderingMonsters, see getFreeTiles(tiles, true); // TODO: Mircea: Issue with CGameHandler::spawnWanderingMonsters, see getFreeTiles(tiles, true);
// danger not linked GraphPaths::addChainInfo, so spawning only with nearby unblocked // danger not linked GraphPaths::addChainInfo, so spawning only with nearby unblocked
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Found task %s", task->toString()); logAi->trace("Found task %s", task->toString());
#endif #endif
if(!isCompositionLoop(subgoal)) if(!isCompositionLoop(subgoal))
@@ -89,7 +89,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
} }
else if(depth < depthLimit - 1) else if(depth < depthLimit - 1)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Found abstract goal %s", subgoal->toString()); logAi->trace("Found abstract goal %s", subgoal->toString());
#endif #endif
if(!isCompositionLoop(subgoal)) if(!isCompositionLoop(subgoal))
@@ -179,7 +179,7 @@ bool DeepDecomposer::isCompositionLoop(TSubgoal goal)
TGoalVec DeepDecomposer::decomposeCached(TSubgoal goal, bool & fromCache) TGoalVec DeepDecomposer::decomposeCached(TSubgoal goal, bool & fromCache)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Decomposing %s, level %s", goal->toString(), depth); logAi->trace("Decomposing %s, level %s", goal->toString(), depth);
#endif #endif
@@ -191,7 +191,7 @@ TGoalVec DeepDecomposer::decomposeCached(TSubgoal goal, bool & fromCache)
if(cached != decompositionCache[i].end()) if(cached != decompositionCache[i].end())
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Use decomposition cache for %s, level: %d", goal->toString(), depth); logAi->trace("Use decomposition cache for %s, level: %d", goal->toString(), depth);
#endif #endif
fromCache = true; fromCache = true;
@@ -203,7 +203,7 @@ TGoalVec DeepDecomposer::decomposeCached(TSubgoal goal, bool & fromCache)
decompositionCache[depth][goal] = {}; // if goal decomposition yields no goals we still need it in cache to not decompose again decompositionCache[depth][goal] = {}; // if goal decomposition yields no goals we still need it in cache to not decompose again
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Calling decompose on %s, level %s", goal->toString(), depth); logAi->trace("Calling decompose on %s, level %s", goal->toString(), depth);
#endif #endif
@@ -224,7 +224,7 @@ void DeepDecomposer::addToCache(TSubgoal goal)
{ {
auto solution = parentDepth < depth ? aggregateGoals(parentDepth + 1, goal) : goal; auto solution = parentDepth < depth ? aggregateGoals(parentDepth + 1, goal) : goal;
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Adding %s to decomosition cache of %s at level %d", solution->toString(), parent->toString(), parentDepth); logAi->trace("Adding %s to decomosition cache of %s at level %d", solution->toString(), parent->toString(), parentDepth);
#endif #endif

View File

@@ -330,7 +330,7 @@ bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
{ {
if(getHeroLockedReason(path.targetHero) == HeroLockedReason::STARTUP) if(getHeroLockedReason(path.targetHero) == HeroLockedReason::STARTUP)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Hero %s is locked by STARTUP. Discarding %s", path.targetHero->getObjectName(), path.toString()); logAi->trace("Hero %s is locked by STARTUP. Discarding %s", path.targetHero->getObjectName(), path.toString());
#endif #endif
return true; return true;
@@ -342,7 +342,7 @@ bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
if(lockReason != HeroLockedReason::NOT_LOCKED) if(lockReason != HeroLockedReason::NOT_LOCKED)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Hero %s is locked by %d. Discarding %s", path.targetHero->getObjectName(), (int)lockReason, path.toString()); logAi->trace("Hero %s is locked by %d. Discarding %s", path.targetHero->getObjectName(), (int)lockReason, path.toString());
#endif #endif
return true; return true;
@@ -384,12 +384,12 @@ void Nullkiller::makeTurn()
decompose(tasks, sptr(ExplorationBehavior()), MAX_DEPTH); decompose(tasks, sptr(ExplorationBehavior()), MAX_DEPTH);
TTaskVec selectedTasks; TTaskVec selectedTasks;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
int prioOfTask = 0; int prioOfTask = 0;
#endif #endif
for (int prio = PriorityEvaluator::PriorityTier::INSTAKILL; prio <= PriorityEvaluator::PriorityTier::MAX_PRIORITY_TIER; ++prio) for (int prio = PriorityEvaluator::PriorityTier::INSTAKILL; prio <= PriorityEvaluator::PriorityTier::MAX_PRIORITY_TIER; ++prio)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
prioOfTask = prio; prioOfTask = prio;
#endif #endif
selectedTasks = buildPlan(tasks, prio); selectedTasks = buildPlan(tasks, prio);
@@ -463,7 +463,7 @@ void Nullkiller::makeTurn()
continue; continue;
} }
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->info("Pass %d: Performing prio %d task %s with prio: %d", i, prioOfTask, selectedTask->toString(), selectedTask->priority); logAi->info("Pass %d: Performing prio %d task %s with prio: %d", i, prioOfTask, selectedTask->toString(), selectedTask->priority);
#endif #endif
@@ -511,7 +511,7 @@ bool Nullkiller::makeTurnHelperPriorityPass(Goals::TGoalVec & tempResults, int p
bestPrioPassTask = choseBestTask(tempResults); bestPrioPassTask = choseBestTask(tempResults);
if(bestPrioPassTask->priority > 0) if(bestPrioPassTask->priority > 0)
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->info("Pass %d: Performing priorityPass %d task %s with prio: %d", passIndex, i, bestPrioPassTask->toString(), bestPrioPassTask->priority); logAi->info("Pass %d: Performing priorityPass %d task %s with prio: %d", passIndex, i, bestPrioPassTask->toString(), bestPrioPassTask->priority);
#endif #endif
@@ -623,7 +623,7 @@ bool Nullkiller::handleTrading()
TResources required = buildAnalyzer->getTotalResourcesRequired(); TResources required = buildAnalyzer->getTotalResourcesRequired();
TResources income = buildAnalyzer->getDailyIncome(); TResources income = buildAnalyzer->getDailyIncome();
TResources available = cc->getResourceAmount(); TResources available = cc->getResourceAmount();
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->debug("Available %s", available.toString()); logAi->debug("Available %s", available.toString());
logAi->debug("Required %s", required.toString()); logAi->debug("Required %s", required.toString());
#endif #endif
@@ -670,7 +670,7 @@ bool Nullkiller::handleTrading()
mostExpendable = i; mostExpendable = i;
} }
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->debug("mostExpendable: %d mostWanted: %d", mostExpendable, mostWanted); logAi->debug("mostExpendable: %d mostWanted: %d", mostExpendable, mostWanted);
#endif #endif
if (mostExpendable == mostWanted || mostWanted == -1 || mostExpendable == -1) if (mostExpendable == mostWanted || mostWanted == -1 || mostExpendable == -1)
@@ -684,7 +684,7 @@ bool Nullkiller::handleTrading()
if (toGive && toGive <= available[mostExpendable]) //don't try to sell 0 resources if (toGive && toGive <= available[mostExpendable]) //don't try to sell 0 resources
{ {
cc->trade(m->getObjInstanceID(), EMarketMode::RESOURCE_RESOURCE, GameResID(mostExpendable), GameResID(mostWanted), toGive); cc->trade(m->getObjInstanceID(), EMarketMode::RESOURCE_RESOURCE, GameResID(mostExpendable), GameResID(mostWanted), toGive);
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->info("Traded %d of %s for %d of %s at %s", toGive, mostExpendable, toGet, mostWanted, obj->getObjectName()); logAi->info("Traded %d of %s for %d of %s at %s", toGive, mostExpendable, toGet, mostWanted, obj->getObjectName());
#endif #endif
haveTraded = true; haveTraded = true;
@@ -708,7 +708,7 @@ void Nullkiller::invalidatePaths()
void Nullkiller::tracePlayerStatus(bool beginning) const void Nullkiller::tracePlayerStatus(bool beginning) const
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
float totalHeroesStrength = 0; float totalHeroesStrength = 0;
int totalTownsLevel = 0; int totalTownsLevel = 0;
for (const auto *heroInfo : cc->getHeroesInfo()) for (const auto *heroInfo : cc->getHeroesInfo())

View File

@@ -1185,7 +1185,7 @@ public:
if (bi.id == BuildingID::MARKETPLACE || bi.dailyIncome[EGameResID::WOOD] > 0) if (bi.id == BuildingID::MARKETPLACE || bi.dailyIncome[EGameResID::WOOD] > 0)
evaluationContext.isTradeBuilding = true; evaluationContext.isTradeBuilding = true;
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Building costs for %s : %s MarketValue: %d",bi.toString(), evaluationContext.buildingCost.toString(), evaluationContext.buildingCost.marketValue()); logAi->trace("Building costs for %s : %s MarketValue: %d",bi.toString(), evaluationContext.buildingCost.toString(), evaluationContext.buildingCost.marketValue());
#endif #endif
@@ -1365,7 +1365,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
} }
if (priorityTier == PriorityTier::FAR_HUNTER_GATHER && currentPositionThreatened == true) if (priorityTier == PriorityTier::FAR_HUNTER_GATHER && currentPositionThreatened == true)
{ {
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("Skip FAR_HUNTER_GATHER because hero would be threatened."); logAi->trace("Skip FAR_HUNTER_GATHER because hero would be threatened.");
#endif #endif
return 0; return 0;
@@ -1380,7 +1380,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
if (aiNk->cc->getDate(Date::DAY_OF_WEEK) + evaluationContext.turn > 7 && priorityTier < PriorityTier::FAR_KILL) if (aiNk->cc->getDate(Date::DAY_OF_WEEK) + evaluationContext.turn > 7 && priorityTier < PriorityTier::FAR_KILL)
arriveNextWeek = true; arriveNextWeek = true;
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, maxWillingToLose: %f, turn: %d, turns main: %f, scout: %f, armyInvolvement: %f, goldRewardVsMovement: %f, cost: %d, armyReward: %f, armyGrowth: %f skillReward: %f danger: %d, threatTurns: %d, threat: %d, heroRole: %s, strategicalValue: %f, conquestValue: %f closestWayRatio: %f, enemyHeroDangerRatio: %f, dangerThreshold: %f explorePriority: %d isDefend: %d isEnemy: %d arriveNextWeek: %d powerRatio: %f", logAi->trace("BEFORE: priorityTier %d, Evaluated %s, loss: %f, maxWillingToLose: %f, turn: %d, turns main: %f, scout: %f, armyInvolvement: %f, goldRewardVsMovement: %f, cost: %d, armyReward: %f, armyGrowth: %f skillReward: %f danger: %d, threatTurns: %d, threat: %d, heroRole: %s, strategicalValue: %f, conquestValue: %f closestWayRatio: %f, enemyHeroDangerRatio: %f, dangerThreshold: %f explorePriority: %d isDefend: %d isEnemy: %d arriveNextWeek: %d powerRatio: %f",
priorityTier, priorityTier,
task->toString(), task->toString(),
@@ -1664,7 +1664,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
return 0; return 0;
} }
#if NKAI_TRACE_LEVEL >= 2 #if NK2AI_TRACE_LEVEL >= 2
logAi->trace("priorityTier %d, Evaluated %s, loss: %f, turn: %d, turns main: %f, scout: %f, armyInvolvement: %f, goldRewardVsMovement: %f, cost: %d, armyReward: %f, armyGrowth: %f skillReward: %f danger: %d, threatTurns: %d, threat: %d, heroRole: %s, strategicalValue: %f, conquestValue: %f closestWayRatio: %f, enemyHeroDangerRatio: %f, result %f", logAi->trace("priorityTier %d, Evaluated %s, loss: %f, turn: %d, turns main: %f, scout: %f, armyInvolvement: %f, goldRewardVsMovement: %f, cost: %d, armyReward: %f, armyGrowth: %f skillReward: %f danger: %d, threatTurns: %d, threat: %d, heroRole: %s, strategicalValue: %f, conquestValue: %f closestWayRatio: %f, enemyHeroDangerRatio: %f, result %f",
priorityTier, priorityTier,
task->toString(), task->toString(),

View File

@@ -28,7 +28,7 @@ ExecuteHeroChain::ExecuteHeroChain(const AIPath & path, const CGObjectInstance *
{ {
objid = obj->id.getNum(); objid = obj->id.getNum();
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
targetName = obj->getObjectName() + tile.toString(); targetName = obj->getObjectName() + tile.toString();
#else #else
targetName = obj->getTypeName() + tile.toString(); targetName = obj->getTypeName() + tile.toString();
@@ -287,7 +287,7 @@ void ExecuteHeroChain::accept(AIGateway * aiGw)
std::string ExecuteHeroChain::toString() const std::string ExecuteHeroChain::toString() const
{ {
#if NKAI_TRACE_LEVEL >= 1 #if NK2AI_TRACE_LEVEL >= 1
return "ExecuteHeroChain " + targetName + " by " + chainPath.toString(); return "ExecuteHeroChain " + targetName + " by " + chainPath.toString();
#else #else
return "ExecuteHeroChain " + targetName + " by " + chainPath.targetHero->getNameTranslated(); return "ExecuteHeroChain " + targetName + " by " + chainPath.targetHero->getNameTranslated();

View File

@@ -331,7 +331,7 @@ void AINodeStorage::commit(
destination->theNodeBefore = source->theNodeBefore; destination->theNodeBefore = source->theNodeBefore;
destination->chainOther = nullptr; destination->chainOther = nullptr;
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Committed %s -> %s, layer: %d, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld", "Committed %s -> %s, layer: %d, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
source->coord.toString(), source->coord.toString(),
@@ -374,7 +374,7 @@ void AINodeStorage::calculateNeighbours(
{ {
if(getAccessibility(neighbour, layer) == EPathAccessibility::NOT_SET) if(getAccessibility(neighbour, layer) == EPathAccessibility::NOT_SET)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Node %s rejected for %s, layer %d because of inaccessibility", "Node %s rejected for %s, layer %d because of inaccessibility",
neighbour.toString(), neighbour.toString(),
@@ -388,7 +388,7 @@ void AINodeStorage::calculateNeighbours(
if(!nextNode) if(!nextNode)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Failed to allocate node at %s[%d]", "Failed to allocate node at %s[%d]",
neighbour.toString(), neighbour.toString(),
@@ -397,7 +397,7 @@ void AINodeStorage::calculateNeighbours(
continue; continue;
} }
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Node %s added to neighbors of %s, layer %d", "Node %s added to neighbors of %s, layer %d",
neighbour.toString(), neighbour.toString(),
@@ -679,7 +679,7 @@ void HeroChainCalculationTask::cleanupInefectiveChains(std::vector<ExchangeCandi
auto isNotEffective = storage.hasBetterChain(chainInfo.carrierParent, chainInfo) auto isNotEffective = storage.hasBetterChain(chainInfo.carrierParent, chainInfo)
|| storage.hasBetterChain(chainInfo.carrierParent, chainInfo, result); || storage.hasBetterChain(chainInfo.carrierParent, chainInfo, result);
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
if(isNotEffective) if(isNotEffective)
{ {
logAi->trace( logAi->trace(
@@ -725,7 +725,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|| (node->action == EPathNodeAction::UNKNOWN && node->actor->hero) || (node->action == EPathNodeAction::UNKNOWN && node->actor->hero)
|| (node->actor->chainMask & srcNode->actor->chainMask) != 0) || (node->actor->chainMask & srcNode->actor->chainMask) != 0)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Skip exchange %s[%x] -> %s[%x] at %s because of %s", "Skip exchange %s[%x] -> %s[%x] at %s because of %s",
node->actor->toString(), node->actor->toString(),
@@ -742,7 +742,7 @@ void HeroChainCalculationTask::calculateHeroChain(
continue; continue;
} }
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Thy exchange %s[%x] -> %s[%x] at %s", "Thy exchange %s[%x] -> %s[%x] at %s",
node->actor->toString(), node->actor->toString(),
@@ -766,7 +766,7 @@ void HeroChainCalculationTask::calculateHeroChain(
&& carrier->action != EPathNodeAction::BLOCKING_VISIT && carrier->action != EPathNodeAction::BLOCKING_VISIT
&& (other->armyLoss == 0 || other->armyLoss < other->actor->armyValue)) && (other->armyLoss == 0 || other->armyLoss < other->actor->armyValue))
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Exchange allowed %s[%x] -> %s[%x] at %s", "Exchange allowed %s[%x] -> %s[%x] at %s",
other->actor->toString(), other->actor->toString(),
@@ -783,7 +783,7 @@ void HeroChainCalculationTask::calculateHeroChain(
if(hasLessMp && hasLessExperience) if(hasLessMp && hasLessExperience)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace("Exchange at %s is inefficient. Blocked.", carrier->coord.toString()); logAi->trace("Exchange at %s is inefficient. Blocked.", carrier->coord.toString());
#endif #endif
return; return;
@@ -808,7 +808,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
if(!chainNodeOptional) if(!chainNodeOptional)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace("Exchange at %s can not allocate node. Blocked.", carrier->coord.toString()); logAi->trace("Exchange at %s can not allocate node. Blocked.", carrier->coord.toString());
#endif #endif
continue; continue;
@@ -818,7 +818,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
if(exchangeNode->action != EPathNodeAction::UNKNOWN) if(exchangeNode->action != EPathNodeAction::UNKNOWN)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Skip exchange %s[%x] -> %s[%x] at %s because node is in use", "Skip exchange %s[%x] -> %s[%x] at %s because node is in use",
other->actor->toString(), other->actor->toString(),
@@ -832,7 +832,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
if(exchangeNode->turns != 0xFF && exchangeNode->getCost() < chainInfo.getCost()) if(exchangeNode->turns != 0xFF && exchangeNode->getCost() < chainInfo.getCost())
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Skip exchange %s[%x] -> %s[%x] at %s because not effective enough. %f < %f", "Skip exchange %s[%x] -> %s[%x] at %s because not effective enough. %f < %f",
other->actor->toString(), other->actor->toString(),
@@ -870,7 +870,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
exchangeNode->chainOther = other; exchangeNode->chainOther = other;
exchangeNode->armyLoss = chainInfo.armyLoss; exchangeNode->armyLoss = chainInfo.armyLoss;
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Chain accepted at %s %s -> %s, mask %x, cost %f, turn: %s, mp: %d, army %i", "Chain accepted at %s %s -> %s, mask %x, cost %f, turn: %s, mp: %d, army %i",
exchangeNode->coord.toString(), exchangeNode->coord.toString(),
@@ -1211,7 +1211,7 @@ void AINodeStorage::calculateTownPortal(
if(nodeOptional) if(nodeOptional)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace("Adding town portal node at %s", targetTown->getObjectName()); logAi->trace("Adding town portal node at %s", targetTown->getObjectName());
#endif #endif
output.push_back(nodeOptional.value()); output.push_back(nodeOptional.value());
@@ -1321,7 +1321,7 @@ bool AINodeStorage::isOtherChainBetter(
{ {
if(other.getCost() < candidateNode.getCost()) if(other.getCost() < candidateNode.getCost())
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Block inefficient battle move %s->%s, hero: %s[%X], army %lld, mp diff: %i", "Block inefficient battle move %s->%s, hero: %s[%X], army %lld, mp diff: %i",
source->coord.toString(), source->coord.toString(),
@@ -1345,7 +1345,7 @@ bool AINodeStorage::isOtherChainBetter(
if(nodeArmyValue > candidateArmyValue if(nodeArmyValue > candidateArmyValue
&& other.getCost() <= candidateNode.getCost()) && other.getCost() <= candidateNode.getCost())
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Block inefficient move because of stronger army %s->%s, hero: %s[%X], army %lld, mp diff: %i", "Block inefficient move because of stronger army %s->%s, hero: %s[%X], army %lld, mp diff: %i",
source->coord.toString(), source->coord.toString(),
@@ -1371,7 +1371,7 @@ bool AINodeStorage::isOtherChainBetter(
return false; return false;
} }
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Block inefficient move because of stronger hero %s->%s, hero: %s[%X], army %lld, mp diff: %i", "Block inefficient move because of stronger hero %s->%s, hero: %s[%X], army %lld, mp diff: %i",
source->coord.toString(), source->coord.toString(),

View File

@@ -10,9 +10,9 @@
#pragma once #pragma once
#define NKAI_PATHFINDER_TRACE_LEVEL 0 #define NK2AI_PATHFINDER_TRACE_LEVEL 0
constexpr int NKAI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat constexpr int NK2AI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat
#define NKAI_TRACE_LEVEL 2 #define NK2AI_TRACE_LEVEL 2
#include "../../../lib/pathfinder/CGPathNode.h" #include "../../../lib/pathfinder/CGPathNode.h"
#include "../../../lib/pathfinder/INodeStorage.h" #include "../../../lib/pathfinder/INodeStorage.h"

View File

@@ -41,7 +41,7 @@ namespace AIPathfinding
{ {
if(cpsic->getPlayerRelations(hero->tempOwner, shipyard->getObject()->getOwner()) == PlayerRelations::ENEMIES) if(cpsic->getPlayerRelations(hero->tempOwner, shipyard->getObject()->getOwner()) == PlayerRelations::ENEMIES)
{ {
#if NKAI_TRACE_LEVEL > 1 #if NK2AI_TRACE_LEVEL > 1
logAi->trace("Can not build a boat. Shipyard is enemy."); logAi->trace("Can not build a boat. Shipyard is enemy.");
#endif #endif
return false; return false;
@@ -53,7 +53,7 @@ namespace AIPathfinding
if(!cpsic->getResourceAmount().canAfford(reservedResources + boatCost)) if(!cpsic->getResourceAmount().canAfford(reservedResources + boatCost))
{ {
#if NKAI_TRACE_LEVEL > 1 #if NK2AI_TRACE_LEVEL > 1
logAi->trace("Can not build a boat. Not enough resources."); logAi->trace("Can not build a boat. Not enough resources.");
#endif #endif

View File

@@ -69,7 +69,7 @@ ChainActor::ChainActor(const CGObjectInstance * obj, const CCreatureSet * creatu
int ChainActor::maxMovePoints(CGPathNode::ELayer layer) int ChainActor::maxMovePoints(CGPathNode::ELayer layer)
{ {
#if NKAI_TRACE_LEVEL > 0 #if NK2AI_TRACE_LEVEL > 0
if(!hero) if(!hero)
throw std::logic_error("Asking movement points for static actor"); throw std::logic_error("Asking movement points for static actor");
#endif #endif
@@ -264,7 +264,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
if(!resources.canAfford(actor->armyCost + other->armyCost)) if(!resources.canAfford(actor->armyCost + other->armyCost))
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Can not afford exchange because of total cost %s but we have %s", "Can not afford exchange because of total cost %s but we have %s",
(actor->armyCost + other->armyCost).toString(), (actor->armyCost + other->armyCost).toString(),
@@ -309,7 +309,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
auto reinforcement = newArmyStrength - oldArmyStrength; auto reinforcement = newArmyStrength - oldArmyStrength;
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Exchange %s->%s reinforcement: %d, %f%%", "Exchange %s->%s reinforcement: %d, %f%%",
actor->toString(), actor->toString(),

View File

@@ -36,7 +36,7 @@ namespace AIPathfinding
{ {
LayerTransitionRule::process(source, destination, pathfinderConfig, pathfinderHelper); LayerTransitionRule::process(source, destination, pathfinderConfig, pathfinderHelper);
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace("Layer transitioning %s -> %s, action: %d, blocked: %s", logAi->trace("Layer transitioning %s -> %s, action: %d, blocked: %s",
source.coord.toString(), source.coord.toString(),
destination.coord.toString(), destination.coord.toString(),
@@ -66,7 +66,7 @@ namespace AIPathfinding
if(virtualBoat && tryUseSpecialAction(destination, source, virtualBoat, EPathNodeAction::EMBARK)) if(virtualBoat && tryUseSpecialAction(destination, source, virtualBoat, EPathNodeAction::EMBARK))
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace("Embarking to virtual boat while moving %s -> %s!", source.coord.toString(), destination.coord.toString()); logAi->trace("Embarking to virtual boat while moving %s -> %s!", source.coord.toString(), destination.coord.toString());
#endif #endif
} }
@@ -84,7 +84,7 @@ namespace AIPathfinding
if(action != waterWalkingActions.end() && tryUseSpecialAction(destination, source, action->second, EPathNodeAction::NORMAL)) if(action != waterWalkingActions.end() && tryUseSpecialAction(destination, source, action->second, EPathNodeAction::NORMAL))
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace("Casting water walk while moving %s -> %s!", source.coord.toString(), destination.coord.toString()); logAi->trace("Casting water walk while moving %s -> %s!", source.coord.toString(), destination.coord.toString());
#endif #endif
} }
@@ -102,7 +102,7 @@ namespace AIPathfinding
if(action != airWalkingActions.end() && tryUseSpecialAction(destination, source, action->second, EPathNodeAction::NORMAL)) if(action != airWalkingActions.end() && tryUseSpecialAction(destination, source, action->second, EPathNodeAction::NORMAL))
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace("Casting fly while moving %s -> %s!", source.coord.toString(), destination.coord.toString()); logAi->trace("Casting fly while moving %s -> %s!", source.coord.toString(), destination.coord.toString());
#endif #endif
} }
@@ -236,7 +236,7 @@ namespace AIPathfinding
} }
else else
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Special transition node already allocated. Blocked moving %s -> %s", "Special transition node already allocated. Blocked moving %s -> %s",
source.coord.toString(), source.coord.toString(),

View File

@@ -85,7 +85,7 @@ namespace AIPathfinding
return; return;
} }
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
logAi->trace( logAi->trace(
"Movement from tile %s is blocked. Try to bypass. Action: %d, blocker: %d, source: %s", "Movement from tile %s is blocked. Try to bypass. Action: %d, blocker: %d, source: %s",
destination.coord.toString(), destination.coord.toString(),
@@ -263,7 +263,7 @@ namespace AIPathfinding
if(guardsAlreadyBypassed && srcNode->actor->allowBattle) if(guardsAlreadyBypassed && srcNode->actor->allowBattle)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Bypass guard at destination while moving %s -> %s", "Bypass guard at destination while moving %s -> %s",
source.coord.toString(), source.coord.toString(),
@@ -291,7 +291,7 @@ namespace AIPathfinding
if(!battleNodeOptional) if(!battleNodeOptional)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Can not allocate battle node while moving %s -> %s", "Can not allocate battle node while moving %s -> %s",
source.coord.toString(), source.coord.toString(),
@@ -304,7 +304,7 @@ namespace AIPathfinding
if(battleNode->locked) if(battleNode->locked)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Block bypass guard at destination while moving %s -> %s", "Block bypass guard at destination while moving %s -> %s",
source.coord.toString(), source.coord.toString(),
@@ -336,7 +336,7 @@ namespace AIPathfinding
battleNode->addSpecialAction(std::make_shared<BattleAction>(destination.coord)); battleNode->addSpecialAction(std::make_shared<BattleAction>(destination.coord));
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Begin bypass guard at destination with danger %s while moving %s -> %s", "Begin bypass guard at destination with danger %s while moving %s -> %s",
std::to_string(danger), std::to_string(danger),

View File

@@ -55,7 +55,7 @@ namespace AIPathfinding
if(actor->allowBattle) if(actor->allowBattle)
{ {
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Bypass src guard while moving from %s to %s", "Bypass src guard while moving from %s to %s",
source.coord.toString(), source.coord.toString(),

View File

@@ -39,7 +39,7 @@ namespace AIPathfinding
// we can not directly bypass objects, we need to interact with them first // we can not directly bypass objects, we need to interact with them first
destination.node->theNodeBefore = source.node; destination.node->theNodeBefore = source.node;
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1 #if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
logAi->trace( logAi->trace(
"Link src node %s to destination node %s while bypassing visitable obj", "Link src node %s to destination node %s while bypassing visitable obj",
source.coord.toString(), source.coord.toString(),