mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Reduce excessive NKAI logging
This commit is contained in:
@@ -20,7 +20,9 @@ void BuildAnalyzer::updateTownDwellings(TownDevelopmentInfo & developmentInfo)
|
|||||||
{
|
{
|
||||||
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
|
||||||
logAi->trace("Checking dwelling level %d", level);
|
logAi->trace("Checking dwelling level %d", level);
|
||||||
|
#endif
|
||||||
std::vector<BuildingID> dwellingsInTown;
|
std::vector<BuildingID> dwellingsInTown;
|
||||||
|
|
||||||
for(BuildingID buildID = BuildingID::getDwellingFromLevel(level, 0); buildID.hasValue(); BuildingID::advanceDwelling(buildID))
|
for(BuildingID buildID = BuildingID::getDwellingFromLevel(level, 0); buildID.hasValue(); BuildingID::advanceDwelling(buildID))
|
||||||
@@ -143,9 +145,9 @@ void BuildAnalyzer::update()
|
|||||||
{
|
{
|
||||||
if(town->built >= cb->getSettings().getInteger(EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP))
|
if(town->built >= cb->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
|
||||||
logAi->trace("Checking town %s", town->getNameTranslated());
|
logAi->trace("Checking town %s", town->getNameTranslated());
|
||||||
|
#endif
|
||||||
developmentInfos.push_back(TownDevelopmentInfo(town));
|
developmentInfos.push_back(TownDevelopmentInfo(town));
|
||||||
TownDevelopmentInfo & developmentInfo = developmentInfos.back();
|
TownDevelopmentInfo & developmentInfo = developmentInfos.back();
|
||||||
|
|
||||||
@@ -161,10 +163,10 @@ void BuildAnalyzer::update()
|
|||||||
}
|
}
|
||||||
armyCost += developmentInfo.armyCost;
|
armyCost += developmentInfo.armyCost;
|
||||||
|
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
for(auto bi : developmentInfo.toBuild)
|
for(auto bi : developmentInfo.toBuild)
|
||||||
{
|
|
||||||
logAi->trace("Building preferences %s", bi.toString());
|
logAi->trace("Building preferences %s", bi.toString());
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(developmentInfos.begin(), developmentInfos.end(), [](const TownDevelopmentInfo & t1, const TownDevelopmentInfo & t2) -> bool
|
std::sort(developmentInfos.begin(), developmentInfos.end(), [](const TownDevelopmentInfo & t1, const TownDevelopmentInfo & t2) -> bool
|
||||||
@@ -179,7 +181,9 @@ void BuildAnalyzer::update()
|
|||||||
|
|
||||||
goldPressure = (ai->getLockedResources()[EGameResID::GOLD] + (float)armyCost[EGameResID::GOLD] + economyDevelopmentCost) / (1 + 2 * ai->getFreeGold() + (float)dailyIncome[EGameResID::GOLD] * 7.0f);
|
goldPressure = (ai->getLockedResources()[EGameResID::GOLD] + (float)armyCost[EGameResID::GOLD] + economyDevelopmentCost) / (1 + 2 * ai->getFreeGold() + (float)dailyIncome[EGameResID::GOLD] * 7.0f);
|
||||||
|
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("Gold pressure: %f", goldPressure);
|
logAi->trace("Gold pressure: %f", goldPressure);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildAnalyzer::reset()
|
void BuildAnalyzer::reset()
|
||||||
@@ -268,12 +272,15 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
|||||||
|
|
||||||
if(vstd::contains_if(missingBuildings, otherDwelling))
|
if(vstd::contains_if(missingBuildings, otherDwelling))
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("cant build %d. Need other dwelling %d", toBuild.getNum(), missingBuildings.front().getNum());
|
logAi->trace("cant build %d. Need other dwelling %d", toBuild.getNum(), missingBuildings.front().getNum());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if(missingBuildings[0] != toBuild)
|
else if(missingBuildings[0] != toBuild)
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("cant build %d. Need %d", toBuild.getNum(), missingBuildings[0].num);
|
logAi->trace("cant build %d. Need %d", toBuild.getNum(), missingBuildings[0].num);
|
||||||
|
#endif
|
||||||
BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], excludeDwellingDependencies);
|
BuildingInfo prerequisite = getBuildingOrPrerequisite(town, missingBuildings[0], excludeDwellingDependencies);
|
||||||
|
|
||||||
prerequisite.buildCostWithPrerequisites += info.buildCost;
|
prerequisite.buildCostWithPrerequisites += info.buildCost;
|
||||||
@@ -298,19 +305,24 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("Cant build. The building requires itself as prerequisite");
|
logAi->trace("Cant build. The building requires itself as prerequisite");
|
||||||
|
#endif
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("Cant build. Reason: %d", static_cast<int>(canBuild));
|
logAi->trace("Cant build. Reason: %d", static_cast<int>(canBuild));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("Dwelling %d exists", toBuild.getNum());
|
logAi->trace("Dwelling %d exists", toBuild.getNum());
|
||||||
|
#endif
|
||||||
info.exists = true;
|
info.exists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -151,7 +151,9 @@ bool handleGarrisonHeroFromPreviousTurn(const CGTownInstance * town, Goals::TGoa
|
|||||||
|
|
||||||
void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * ai) const
|
void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInstance * town, const Nullkiller * ai) const
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("Evaluating defence for %s", town->getNameTranslated());
|
logAi->trace("Evaluating defence for %s", town->getNameTranslated());
|
||||||
|
#endif
|
||||||
|
|
||||||
auto threatNode = ai->dangerHitMap->getObjectThreat(town);
|
auto threatNode = ai->dangerHitMap->getObjectThreat(town);
|
||||||
std::vector<HitMapInfo> threats = ai->dangerHitMap->getTownThreats(town);
|
std::vector<HitMapInfo> threats = ai->dangerHitMap->getTownThreats(town);
|
||||||
@@ -164,8 +166,9 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
|||||||
}
|
}
|
||||||
if(!threatNode.fastestDanger.hero)
|
if(!threatNode.fastestDanger.hero)
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("No threat found for town %s", town->getNameTranslated());
|
logAi->trace("No threat found for town %s", town->getNameTranslated());
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +176,9 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
|||||||
|
|
||||||
if(reinforcement)
|
if(reinforcement)
|
||||||
{
|
{
|
||||||
|
#if NKAI_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
|
||||||
tasks.push_back(Goals::sptr(Goals::BuyArmy(town, reinforcement).setpriority(0.5f)));
|
tasks.push_back(Goals::sptr(Goals::BuyArmy(town, reinforcement).setpriority(0.5f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,13 +186,14 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
|||||||
|
|
||||||
for(auto & threat : threats)
|
for(auto & threat : threats)
|
||||||
{
|
{
|
||||||
|
#if NKAI_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(),
|
||||||
threat.danger,
|
threat.danger,
|
||||||
std::to_string(threat.turn),
|
std::to_string(threat.turn),
|
||||||
threat.hero ? threat.hero->getNameTranslated() : std::string("<no hero>"));
|
threat.hero ? threat.hero->getNameTranslated() : std::string("<no hero>"));
|
||||||
|
#endif
|
||||||
handleCounterAttack(town, threat, threatNode.maximumDanger, ai, tasks);
|
handleCounterAttack(town, threat, threatNode.maximumDanger, ai, tasks);
|
||||||
|
|
||||||
if(isThreatUnderControl(town, threat, ai, paths))
|
if(isThreatUnderControl(town, threat, ai, paths))
|
||||||
@@ -199,7 +205,9 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
|||||||
|
|
||||||
if(paths.empty())
|
if(paths.empty())
|
||||||
{
|
{
|
||||||
|
#if NKAI_TRACE_LEVEL >= 1
|
||||||
logAi->trace("No ways to defend town %s", town->getNameTranslated());
|
logAi->trace("No ways to defend town %s", town->getNameTranslated());
|
||||||
|
#endif
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -1201,7 +1201,9 @@ 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
|
||||||
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
|
||||||
|
|
||||||
if(bi.creatureID != CreatureID::NONE)
|
if(bi.creatureID != CreatureID::NONE)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user