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:
@@ -11,7 +11,7 @@
|
||||
#pragma once
|
||||
|
||||
#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
|
||||
|
||||
#include "../../../lib/pathfinder/CGPathNode.h"
|
||||
|
||||
@@ -173,7 +173,7 @@ void AIPathfinder::updateGraphs(
|
||||
}
|
||||
});
|
||||
|
||||
if(NKAI_GRAPH_TRACE_LEVEL >= 1)
|
||||
if(NK2AI_GRAPH_TRACE_LEVEL >= 1)
|
||||
{
|
||||
for(auto hero : heroes)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ void BuildAnalyzer::update()
|
||||
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
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Checking town %s", town->getNameTranslated());
|
||||
#endif
|
||||
|
||||
@@ -69,7 +69,7 @@ void BuildAnalyzer::update()
|
||||
|
||||
armyCost += tdi.armyCost;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
for(const auto & biToBuild : tdi.toBuild)
|
||||
logAi->trace("Building preferences %s", biToBuild.toString());
|
||||
#endif
|
||||
@@ -192,7 +192,7 @@ float BuildAnalyzer::calculateGoldPressure(TResource lockedGold, float armyCostG
|
||||
{
|
||||
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);
|
||||
#endif
|
||||
|
||||
@@ -221,7 +221,7 @@ void BuildAnalyzer::updateDwellings(TownDevelopmentInfo & developmentInfo, std::
|
||||
{
|
||||
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);
|
||||
#endif
|
||||
std::vector<BuildingID> dwellingsInTown;
|
||||
@@ -372,13 +372,13 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
|
||||
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());
|
||||
#endif
|
||||
}
|
||||
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);
|
||||
#endif
|
||||
BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], armyManager, cc, excludeDwellingDependencies);
|
||||
@@ -407,7 +407,7 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Can't build. The building requires itself as prerequisite");
|
||||
#endif
|
||||
return info;
|
||||
@@ -415,14 +415,14 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Can't build. Reason: %d", static_cast<int>(canBuild));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Dwelling %d exists", b.getNum());
|
||||
#endif
|
||||
info.isBuilt = true;
|
||||
|
||||
@@ -27,7 +27,7 @@ double HitMapInfo::value() const
|
||||
|
||||
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)
|
||||
{
|
||||
foreach_tile_pos([&b, &data](const int3 & pos)
|
||||
|
||||
@@ -332,7 +332,7 @@ void ObjectClusterizer::clusterize()
|
||||
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) {
|
||||
#else
|
||||
tbb::blocked_range<size_t> r(0, objs.size());
|
||||
@@ -345,7 +345,7 @@ void ObjectClusterizer::clusterize()
|
||||
{
|
||||
clusterizeObject(objs[i], priorityEvaluator.get(), pathCache, heroes);
|
||||
}
|
||||
#if NKAI_TRACE_LEVEL == 0
|
||||
#if NK2AI_TRACE_LEVEL == 0
|
||||
});
|
||||
#endif
|
||||
|
||||
@@ -358,7 +358,7 @@ void ObjectClusterizer::clusterize()
|
||||
|
||||
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()))
|
||||
{
|
||||
logAi->trace("Object %s %s", obj->getObjectName(), obj->visitablePos().toString());
|
||||
@@ -379,13 +379,13 @@ void ObjectClusterizer::clusterizeObject(
|
||||
{
|
||||
if(!shouldVisitObject(obj))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Skip object %s%s.", obj->getObjectName(), obj->visitablePos().toString());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Check object %s%s.", obj->getObjectName(), obj->visitablePos().toString());
|
||||
#endif
|
||||
|
||||
@@ -398,7 +398,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
if(pathCache.empty())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("No paths found.");
|
||||
#endif
|
||||
return;
|
||||
@@ -413,7 +413,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -424,7 +424,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
for(auto & path : pathCache)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("ObjectClusterizer Checking path %s", path.toString());
|
||||
#endif
|
||||
|
||||
@@ -435,7 +435,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
// if(path.movementCost() > 2.0f)
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -448,7 +448,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
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);
|
||||
#endif
|
||||
continue;
|
||||
@@ -457,7 +457,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -473,7 +473,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -498,7 +498,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -529,7 +529,7 @@ void ObjectClusterizer::clusterizeObject(
|
||||
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",
|
||||
path.toString(),
|
||||
interestingObject ? "near" : "far",
|
||||
|
||||
@@ -64,13 +64,13 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
{
|
||||
tasks.push_back(sptr(Goals::Invalid()));
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Path found %s", path.toString());
|
||||
#endif
|
||||
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -86,7 +86,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
&& (path.getTotalDanger() == 0 || path.turn() > 0)
|
||||
&& 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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -97,7 +97,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -116,7 +116,7 @@ Goals::TGoalVec CaptureObjectsBehavior::getVisitGoals(
|
||||
|
||||
auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, nullkiller->settings->getSafeAttackRatio());
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
|
||||
isSafe ? "safe" : "not safe",
|
||||
@@ -195,13 +195,13 @@ void CaptureObjectsBehavior::decomposeObjects(
|
||||
if(!objectMatchesFilter(objToVisit))
|
||||
continue;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Checking object %s, %s", objToVisit->getObjectName(), objToVisit->visitablePos().toString());
|
||||
#endif
|
||||
|
||||
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());
|
||||
#endif
|
||||
vstd::concatenate(tasksLocal, getVisitGoals(paths, nullkiller, objToVisit, specificObjects));
|
||||
|
||||
@@ -51,7 +51,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
|
||||
|
||||
TGoalVec goals;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Checking cluster %s %s, found %d paths",
|
||||
cluster->blocker->getObjectName(),
|
||||
@@ -61,7 +61,7 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
|
||||
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -90,13 +90,13 @@ Goals::TGoalVec ClusterBehavior::decomposeCluster(const Nullkiller * aiNk, std::
|
||||
for(auto & node : clonedPath.nodes)
|
||||
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());
|
||||
#endif
|
||||
path++;
|
||||
}
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Decompose unlock paths");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat
|
||||
|| path.turn() < threat.turn - 1
|
||||
|| (path.turn() < threat.turn && threat.turn >= 2))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Hero %s can eliminate danger for town %s using path %s.",
|
||||
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
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Evaluating defence for %s", town->getNameTranslated());
|
||||
#endif
|
||||
|
||||
@@ -166,7 +166,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
}
|
||||
if(!threatNode.fastestDanger.hero)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("No threat found for town %s", town->getNameTranslated());
|
||||
#endif
|
||||
return;
|
||||
@@ -176,7 +176,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
if(reinforcement)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Town %s can buy defence army %lld", town->getNameTranslated(), reinforcement);
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Town %s has threat %lld in %s turns, hero: %s",
|
||||
town->getNameTranslated(),
|
||||
@@ -205,7 +205,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
if(paths.empty())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("No ways to defend town %s", town->getNameTranslated());
|
||||
#endif
|
||||
|
||||
@@ -223,7 +223,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
if (!closestWay || path.movementCost() < closestWay->movementCost())
|
||||
closestWay = &path;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Hero %s can defend town with force %lld in %s turns, cost: %f, path: %s",
|
||||
path.targetHero->getObjectName(),
|
||||
@@ -250,7 +250,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
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",
|
||||
town->getObjectName(),
|
||||
path.targetHero->getObjectName());
|
||||
@@ -263,7 +263,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
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",
|
||||
path.targetHero->getObjectName(),
|
||||
town->getObjectName());
|
||||
@@ -273,7 +273,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
|
||||
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",
|
||||
path.targetHero->getObjectName(),
|
||||
town->getObjectName());
|
||||
@@ -318,7 +318,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
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.",
|
||||
path.targetHero->getObjectName(),
|
||||
town->getObjectName());
|
||||
@@ -355,7 +355,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
composition.addNext(ExchangeSwapTownHeroes(town, town->getGarrisonHero(), HeroLockedReason::DEFENCE));
|
||||
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",
|
||||
town->getGarrisonHero()->getObjectName(),
|
||||
town->getObjectName());
|
||||
@@ -367,7 +367,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
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",
|
||||
path.targetHero->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",
|
||||
path.targetHero->getObjectName(),
|
||||
town->getObjectName());
|
||||
@@ -401,13 +401,13 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
|
||||
if(subGoal->invalid())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Path is invalid. Skipping");
|
||||
#endif
|
||||
continue;
|
||||
@@ -458,7 +458,7 @@ void DefenceBehavior::evaluateRecruitingHero(Goals::TGoalVec & tasks, const HitM
|
||||
|
||||
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());
|
||||
#endif
|
||||
bool needSwap = false;
|
||||
|
||||
@@ -65,19 +65,19 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
const int3 pos = hero->visitablePos();
|
||||
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());
|
||||
#endif
|
||||
|
||||
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());
|
||||
#endif
|
||||
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
|
||||
if(path.containsHero(hero))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Selfcontaining path. Ignore");
|
||||
#endif
|
||||
continue;
|
||||
@@ -94,7 +94,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
|
||||
if(aiNk->arePathHeroesLocked(path))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Ignore path because of locked hero");
|
||||
#endif
|
||||
continue;
|
||||
@@ -108,7 +108,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
// avoid transferring very small amount of army
|
||||
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.");
|
||||
#endif
|
||||
continue;
|
||||
@@ -138,7 +138,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
|
||||
if(hasOtherMainInPath)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Army value is too large.");
|
||||
#endif
|
||||
continue;
|
||||
@@ -147,7 +147,7 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
auto danger = path.getTotalDanger();
|
||||
auto isSafe = isSafeToVisit(hero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio());
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
|
||||
isSafe ? "safe" : "not safe",
|
||||
@@ -193,14 +193,14 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const Nullkiller * aiNk, c
|
||||
|
||||
if(blockedAction)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Action is blocked. Considering decomposition.");
|
||||
#endif
|
||||
auto subGoal = blockedAction->decompose(aiNk, path.targetHero);
|
||||
|
||||
if(subGoal->invalid())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Path is invalid. Skipping");
|
||||
#endif
|
||||
continue;
|
||||
@@ -222,7 +222,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
const int3 pos = upgrader->visitablePos();
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -231,7 +231,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
|
||||
std::vector<std::shared_ptr<ExecuteHeroChain>> waysToVisitObj;
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Found %d paths", paths.size());
|
||||
#endif
|
||||
|
||||
@@ -250,13 +250,13 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
auto & path = paths[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());
|
||||
#endif
|
||||
|
||||
if(visitGoal->invalid())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Ignore path. Not valid way.");
|
||||
#endif
|
||||
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 NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Ignore path. Town has visiting hero.");
|
||||
#endif
|
||||
continue;
|
||||
@@ -272,7 +272,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
|
||||
if(aiNk->arePathHeroesLocked(path))
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Ignore path because of locked hero");
|
||||
#endif
|
||||
continue;
|
||||
@@ -280,7 +280,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
|
||||
if(path.getFirstBlockedAction())
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
// TODO: decomposition?
|
||||
logAi->trace("Ignore path. Action is blocked.");
|
||||
#endif
|
||||
@@ -332,7 +332,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
// TODO: Mircea: Move to constant
|
||||
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);
|
||||
#endif
|
||||
continue;
|
||||
@@ -341,7 +341,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const Nullkiller * aiNk, const C
|
||||
auto danger = path.getTotalDanger();
|
||||
auto isSafe = isSafeToVisit(path.targetHero, path.heroArmy, danger, aiNk->settings->getSafeAttackRatio());
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"It is %s to visit %s by %s with army %lld, danger %lld and army loss %lld",
|
||||
isSafe ? "safe" : "not safe",
|
||||
|
||||
@@ -52,7 +52,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
|
||||
TSubgoal current = goals[depth].back();
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -74,7 +74,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
|
||||
|
||||
// TODO: Mircea: Issue with CGameHandler::spawnWanderingMonsters, see getFreeTiles(tiles, true);
|
||||
// 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());
|
||||
#endif
|
||||
if(!isCompositionLoop(subgoal))
|
||||
@@ -89,7 +89,7 @@ void DeepDecomposer::decompose(TGoalVec & results, TSubgoal behavior, int depthL
|
||||
}
|
||||
else if(depth < depthLimit - 1)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
logAi->trace("Found abstract goal %s", subgoal->toString());
|
||||
#endif
|
||||
if(!isCompositionLoop(subgoal))
|
||||
@@ -179,7 +179,7 @@ bool DeepDecomposer::isCompositionLoop(TSubgoal goal)
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
@@ -191,7 +191,7 @@ TGoalVec DeepDecomposer::decomposeCached(TSubgoal goal, bool & fromCache)
|
||||
|
||||
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);
|
||||
#endif
|
||||
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
|
||||
}
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->trace("Calling decompose on %s, level %s", goal->toString(), depth);
|
||||
#endif
|
||||
|
||||
@@ -224,7 +224,7 @@ void DeepDecomposer::addToCache(TSubgoal 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);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
return true;
|
||||
@@ -342,7 +342,7 @@ bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
|
||||
|
||||
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());
|
||||
#endif
|
||||
return true;
|
||||
@@ -384,12 +384,12 @@ void Nullkiller::makeTurn()
|
||||
decompose(tasks, sptr(ExplorationBehavior()), MAX_DEPTH);
|
||||
|
||||
TTaskVec selectedTasks;
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
int prioOfTask = 0;
|
||||
#endif
|
||||
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;
|
||||
#endif
|
||||
selectedTasks = buildPlan(tasks, prio);
|
||||
@@ -463,7 +463,7 @@ void Nullkiller::makeTurn()
|
||||
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);
|
||||
#endif
|
||||
|
||||
@@ -511,7 +511,7 @@ bool Nullkiller::makeTurnHelperPriorityPass(Goals::TGoalVec & tempResults, int p
|
||||
bestPrioPassTask = choseBestTask(tempResults);
|
||||
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);
|
||||
#endif
|
||||
|
||||
@@ -623,7 +623,7 @@ bool Nullkiller::handleTrading()
|
||||
TResources required = buildAnalyzer->getTotalResourcesRequired();
|
||||
TResources income = buildAnalyzer->getDailyIncome();
|
||||
TResources available = cc->getResourceAmount();
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->debug("Available %s", available.toString());
|
||||
logAi->debug("Required %s", required.toString());
|
||||
#endif
|
||||
@@ -670,7 +670,7 @@ bool Nullkiller::handleTrading()
|
||||
mostExpendable = i;
|
||||
}
|
||||
}
|
||||
#if NKAI_TRACE_LEVEL >= 2
|
||||
#if NK2AI_TRACE_LEVEL >= 2
|
||||
logAi->debug("mostExpendable: %d mostWanted: %d", mostExpendable, mostWanted);
|
||||
#endif
|
||||
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
|
||||
{
|
||||
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());
|
||||
#endif
|
||||
haveTraded = true;
|
||||
@@ -708,7 +708,7 @@ void Nullkiller::invalidatePaths()
|
||||
|
||||
void Nullkiller::tracePlayerStatus(bool beginning) const
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
float totalHeroesStrength = 0;
|
||||
int totalTownsLevel = 0;
|
||||
for (const auto *heroInfo : cc->getHeroesInfo())
|
||||
|
||||
@@ -1185,7 +1185,7 @@ public:
|
||||
if (bi.id == BuildingID::MARKETPLACE || bi.dailyIncome[EGameResID::WOOD] > 0)
|
||||
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());
|
||||
#endif
|
||||
|
||||
@@ -1365,7 +1365,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
}
|
||||
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.");
|
||||
#endif
|
||||
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)
|
||||
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",
|
||||
priorityTier,
|
||||
task->toString(),
|
||||
@@ -1664,7 +1664,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
|
||||
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",
|
||||
priorityTier,
|
||||
task->toString(),
|
||||
|
||||
@@ -28,7 +28,7 @@ ExecuteHeroChain::ExecuteHeroChain(const AIPath & path, const CGObjectInstance *
|
||||
{
|
||||
objid = obj->id.getNum();
|
||||
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
targetName = obj->getObjectName() + tile.toString();
|
||||
#else
|
||||
targetName = obj->getTypeName() + tile.toString();
|
||||
@@ -287,7 +287,7 @@ void ExecuteHeroChain::accept(AIGateway * aiGw)
|
||||
|
||||
std::string ExecuteHeroChain::toString() const
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL >= 1
|
||||
#if NK2AI_TRACE_LEVEL >= 1
|
||||
return "ExecuteHeroChain " + targetName + " by " + chainPath.toString();
|
||||
#else
|
||||
return "ExecuteHeroChain " + targetName + " by " + chainPath.targetHero->getNameTranslated();
|
||||
|
||||
@@ -331,7 +331,7 @@ void AINodeStorage::commit(
|
||||
destination->theNodeBefore = source->theNodeBefore;
|
||||
destination->chainOther = nullptr;
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Committed %s -> %s, layer: %d, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
|
||||
source->coord.toString(),
|
||||
@@ -374,7 +374,7 @@ void AINodeStorage::calculateNeighbours(
|
||||
{
|
||||
if(getAccessibility(neighbour, layer) == EPathAccessibility::NOT_SET)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Node %s rejected for %s, layer %d because of inaccessibility",
|
||||
neighbour.toString(),
|
||||
@@ -388,7 +388,7 @@ void AINodeStorage::calculateNeighbours(
|
||||
|
||||
if(!nextNode)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Failed to allocate node at %s[%d]",
|
||||
neighbour.toString(),
|
||||
@@ -397,7 +397,7 @@ void AINodeStorage::calculateNeighbours(
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Node %s added to neighbors of %s, layer %d",
|
||||
neighbour.toString(),
|
||||
@@ -679,7 +679,7 @@ void HeroChainCalculationTask::cleanupInefectiveChains(std::vector<ExchangeCandi
|
||||
auto isNotEffective = storage.hasBetterChain(chainInfo.carrierParent, chainInfo)
|
||||
|| storage.hasBetterChain(chainInfo.carrierParent, chainInfo, result);
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
if(isNotEffective)
|
||||
{
|
||||
logAi->trace(
|
||||
@@ -725,7 +725,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|
||||
|| (node->action == EPathNodeAction::UNKNOWN && node->actor->hero)
|
||||
|| (node->actor->chainMask & srcNode->actor->chainMask) != 0)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Skip exchange %s[%x] -> %s[%x] at %s because of %s",
|
||||
node->actor->toString(),
|
||||
@@ -742,7 +742,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Thy exchange %s[%x] -> %s[%x] at %s",
|
||||
node->actor->toString(),
|
||||
@@ -766,7 +766,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|
||||
&& carrier->action != EPathNodeAction::BLOCKING_VISIT
|
||||
&& (other->armyLoss == 0 || other->armyLoss < other->actor->armyValue))
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Exchange allowed %s[%x] -> %s[%x] at %s",
|
||||
other->actor->toString(),
|
||||
@@ -783,7 +783,7 @@ void HeroChainCalculationTask::calculateHeroChain(
|
||||
|
||||
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());
|
||||
#endif
|
||||
return;
|
||||
@@ -808,7 +808,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
|
||||
|
||||
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());
|
||||
#endif
|
||||
continue;
|
||||
@@ -818,7 +818,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
|
||||
|
||||
if(exchangeNode->action != EPathNodeAction::UNKNOWN)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Skip exchange %s[%x] -> %s[%x] at %s because node is in use",
|
||||
other->actor->toString(),
|
||||
@@ -832,7 +832,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
|
||||
|
||||
if(exchangeNode->turns != 0xFF && exchangeNode->getCost() < chainInfo.getCost())
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Skip exchange %s[%x] -> %s[%x] at %s because not effective enough. %f < %f",
|
||||
other->actor->toString(),
|
||||
@@ -870,7 +870,7 @@ void HeroChainCalculationTask::addHeroChain(const std::vector<ExchangeCandidate>
|
||||
exchangeNode->chainOther = other;
|
||||
exchangeNode->armyLoss = chainInfo.armyLoss;
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Chain accepted at %s %s -> %s, mask %x, cost %f, turn: %s, mp: %d, army %i",
|
||||
exchangeNode->coord.toString(),
|
||||
@@ -1211,7 +1211,7 @@ void AINodeStorage::calculateTownPortal(
|
||||
|
||||
if(nodeOptional)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace("Adding town portal node at %s", targetTown->getObjectName());
|
||||
#endif
|
||||
output.push_back(nodeOptional.value());
|
||||
@@ -1321,7 +1321,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
{
|
||||
if(other.getCost() < candidateNode.getCost())
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block inefficient battle move %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
@@ -1345,7 +1345,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
if(nodeArmyValue > candidateArmyValue
|
||||
&& other.getCost() <= candidateNode.getCost())
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block inefficient move because of stronger army %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
@@ -1371,7 +1371,7 @@ bool AINodeStorage::isOtherChainBetter(
|
||||
return false;
|
||||
}
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Block inefficient move because of stronger hero %s->%s, hero: %s[%X], army %lld, mp diff: %i",
|
||||
source->coord.toString(),
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define NKAI_PATHFINDER_TRACE_LEVEL 0
|
||||
constexpr int NKAI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat
|
||||
#define NKAI_TRACE_LEVEL 2
|
||||
#define NK2AI_PATHFINDER_TRACE_LEVEL 0
|
||||
constexpr int NK2AI_GRAPH_TRACE_LEVEL = 0; // To actually enable graph visualization, enter `/vslog graph` in game chat
|
||||
#define NK2AI_TRACE_LEVEL 2
|
||||
|
||||
#include "../../../lib/pathfinder/CGPathNode.h"
|
||||
#include "../../../lib/pathfinder/INodeStorage.h"
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace AIPathfinding
|
||||
{
|
||||
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.");
|
||||
#endif
|
||||
return false;
|
||||
@@ -53,7 +53,7 @@ namespace AIPathfinding
|
||||
|
||||
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.");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ ChainActor::ChainActor(const CGObjectInstance * obj, const CCreatureSet * creatu
|
||||
|
||||
int ChainActor::maxMovePoints(CGPathNode::ELayer layer)
|
||||
{
|
||||
#if NKAI_TRACE_LEVEL > 0
|
||||
#if NK2AI_TRACE_LEVEL > 0
|
||||
if(!hero)
|
||||
throw std::logic_error("Asking movement points for static actor");
|
||||
#endif
|
||||
@@ -264,7 +264,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
|
||||
|
||||
if(!resources.canAfford(actor->armyCost + other->armyCost))
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Can not afford exchange because of total cost %s but we have %s",
|
||||
(actor->armyCost + other->armyCost).toString(),
|
||||
@@ -309,7 +309,7 @@ ExchangeResult HeroExchangeMap::tryExchangeNoLock(const ChainActor * other)
|
||||
|
||||
auto reinforcement = newArmyStrength - oldArmyStrength;
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Exchange %s->%s reinforcement: %d, %f%%",
|
||||
actor->toString(),
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace AIPathfinding
|
||||
{
|
||||
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",
|
||||
source.coord.toString(),
|
||||
destination.coord.toString(),
|
||||
@@ -66,7 +66,7 @@ namespace AIPathfinding
|
||||
|
||||
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());
|
||||
#endif
|
||||
}
|
||||
@@ -84,7 +84,7 @@ namespace AIPathfinding
|
||||
|
||||
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());
|
||||
#endif
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace AIPathfinding
|
||||
|
||||
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());
|
||||
#endif
|
||||
}
|
||||
@@ -236,7 +236,7 @@ namespace AIPathfinding
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Special transition node already allocated. Blocked moving %s -> %s",
|
||||
source.coord.toString(),
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace AIPathfinding
|
||||
return;
|
||||
}
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 2
|
||||
logAi->trace(
|
||||
"Movement from tile %s is blocked. Try to bypass. Action: %d, blocker: %d, source: %s",
|
||||
destination.coord.toString(),
|
||||
@@ -263,7 +263,7 @@ namespace AIPathfinding
|
||||
|
||||
if(guardsAlreadyBypassed && srcNode->actor->allowBattle)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Bypass guard at destination while moving %s -> %s",
|
||||
source.coord.toString(),
|
||||
@@ -291,7 +291,7 @@ namespace AIPathfinding
|
||||
|
||||
if(!battleNodeOptional)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Can not allocate battle node while moving %s -> %s",
|
||||
source.coord.toString(),
|
||||
@@ -304,7 +304,7 @@ namespace AIPathfinding
|
||||
|
||||
if(battleNode->locked)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Block bypass guard at destination while moving %s -> %s",
|
||||
source.coord.toString(),
|
||||
@@ -336,7 +336,7 @@ namespace AIPathfinding
|
||||
|
||||
battleNode->addSpecialAction(std::make_shared<BattleAction>(destination.coord));
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Begin bypass guard at destination with danger %s while moving %s -> %s",
|
||||
std::to_string(danger),
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace AIPathfinding
|
||||
|
||||
if(actor->allowBattle)
|
||||
{
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Bypass src guard while moving from %s to %s",
|
||||
source.coord.toString(),
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace AIPathfinding
|
||||
// we can not directly bypass objects, we need to interact with them first
|
||||
destination.node->theNodeBefore = source.node;
|
||||
|
||||
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
#if NK2AI_PATHFINDER_TRACE_LEVEL >= 1
|
||||
logAi->trace(
|
||||
"Link src node %s to destination node %s while bypassing visitable obj",
|
||||
source.coord.toString(),
|
||||
|
||||
Reference in New Issue
Block a user