mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
AI logging convert 1
This commit is contained in:
parent
74a82c4c9d
commit
22884d9150
@ -179,7 +179,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
logAi->errorStream() << "Exception occurred in " << __FUNCTION__ << " " << e.what();
|
||||
logAi->error("Exception occurred in %s %s",__FUNCTION__, e.what());
|
||||
}
|
||||
|
||||
return BattleAction::makeDefend(stack);
|
||||
@ -268,7 +268,7 @@ void CBattleAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
|
||||
|
||||
void CBattleAI::print(const std::string &text) const
|
||||
{
|
||||
logAi->traceStream() << "CBattleAI [" << this <<"]: " << text;
|
||||
logAi->trace("CBattleAI [%p]: %s", this, text);
|
||||
}
|
||||
|
||||
BattleAction CBattleAI::goTowards(const CStack * stack, BattleHex destination)
|
||||
|
@ -261,7 +261,7 @@ void CStupidAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
|
||||
|
||||
void CStupidAI::print(const std::string &text) const
|
||||
{
|
||||
logAi->traceStream() << "CStupidAI [" << this <<"]: " << text;
|
||||
logAi->trace("CStupidAI [%p]: %s", this, text);
|
||||
}
|
||||
|
||||
BattleAction CStupidAI::goTowards(const CStack * stack, BattleHex destination)
|
||||
|
@ -339,7 +339,7 @@ bool isSafeToVisit(HeroPtr h, crint3 tile)
|
||||
{
|
||||
if(heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength)
|
||||
{
|
||||
logAi->traceStream() << boost::format("It's safe for %s to visit tile %s") % h->name % tile;
|
||||
logAi->trace("It's safe for %s to visit tile %s", h->name, tile());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -42,7 +42,7 @@ struct HeroPtr
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
|
||||
|
||||
HeroPtr();
|
||||
HeroPtr(const CGHeroInstance *H);
|
||||
~HeroPtr();
|
||||
@ -105,7 +105,7 @@ struct TimeCheck
|
||||
|
||||
~TimeCheck()
|
||||
{
|
||||
logAi->traceStream() << boost::format("Time of %s was %d ms.") % txt % time.getDiff();
|
||||
logAi->trace("Time of %s was %d ms.",txt,time.getDiff());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,7 @@ engineBase::engineBase()
|
||||
void engineBase::configure()
|
||||
{
|
||||
engine.configure("Minimum", "Maximum", "Minimum", "AlgebraicSum", "Centroid");
|
||||
logAi->infoStream() << engine.toString();
|
||||
logAi->info(engine.toString());
|
||||
}
|
||||
|
||||
void engineBase::addRule(const std::string &txt)
|
||||
@ -149,7 +149,7 @@ void FuzzyHelper::initTacticalAdvantage()
|
||||
{
|
||||
fl::Rectangle* none = new fl::Rectangle("NONE", CGTownInstance::NONE, CGTownInstance::NONE + (CGTownInstance::FORT - CGTownInstance::NONE) * 0.5f);
|
||||
ta.castleWalls->addTerm(none);
|
||||
|
||||
|
||||
fl::Trapezoid* medium = new fl::Trapezoid("MEDIUM", (CGTownInstance::FORT - CGTownInstance::NONE) * 0.5f, CGTownInstance::FORT,
|
||||
CGTownInstance::CITADEL, CGTownInstance::CITADEL + (CGTownInstance::CASTLE - CGTownInstance::CITADEL) * 0.5f);
|
||||
ta.castleWalls->addTerm(medium);
|
||||
@ -160,7 +160,7 @@ void FuzzyHelper::initTacticalAdvantage()
|
||||
ta.castleWalls->setRange(CGTownInstance::NONE, CGTownInstance::CASTLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ta.bankPresent = new fl::InputVariable("Bank");
|
||||
ta.engine.addInputVariable(ta.bankPresent);
|
||||
@ -201,7 +201,7 @@ void FuzzyHelper::initTacticalAdvantage()
|
||||
}
|
||||
catch (fl::Exception & pe)
|
||||
{
|
||||
logAi->errorStream() << "initTacticalAdvantage " << ": " << pe.getWhat();
|
||||
logAi->error("initTacticalAdvantage: %s", pe.getWhat());
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ float FuzzyHelper::getTacticalAdvantage (const CArmedInstance *we, const CArmedI
|
||||
}
|
||||
catch (fl::Exception & fe)
|
||||
{
|
||||
logAi->errorStream() << "getTacticalAdvantage " << ": " << fe.getWhat();
|
||||
logAi->error("getTacticalAdvantage: %s ",fe.getWhat());
|
||||
}
|
||||
|
||||
if (output < 0 || (output != output))
|
||||
@ -273,7 +273,7 @@ float FuzzyHelper::getTacticalAdvantage (const CArmedInstance *we, const CArmedI
|
||||
|
||||
for (int i = 0; i < boost::size(tab); i++)
|
||||
log << names[i] << ": " << tab[i]->getInputValue() << " ";
|
||||
logAi->errorStream() << log.str();
|
||||
logAi->error(log.str());
|
||||
assert(false);
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ void FuzzyHelper::initVisitTile()
|
||||
}
|
||||
catch (fl::Exception & fe)
|
||||
{
|
||||
logAi->errorStream() << "visitTile " << ": " << fe.getWhat();
|
||||
logAi->error("visitTile: %s",fe.getWhat());
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,11 +455,10 @@ float FuzzyHelper::evaluate (Goals::VisitTile & g)
|
||||
}
|
||||
catch (fl::Exception & fe)
|
||||
{
|
||||
logAi->errorStream() << "evaluate VisitTile " << ": " << fe.getWhat();
|
||||
logAi->error("evaluate VisitTile: %s",fe.getWhat());
|
||||
}
|
||||
assert (g.priority >= 0);
|
||||
return g.priority;
|
||||
|
||||
}
|
||||
float FuzzyHelper::evaluate (Goals::VisitHero & g)
|
||||
{
|
||||
@ -468,7 +467,7 @@ float FuzzyHelper::evaluate (Goals::VisitHero & g)
|
||||
return -100; //hero died in the meantime
|
||||
//TODO: consider direct copy (constructor?)
|
||||
g.setpriority(Goals::VisitTile(obj->visitablePos()).sethero(g.hero).setisAbstract(g.isAbstract).accept(this));
|
||||
return g.priority;
|
||||
return g.priority;
|
||||
}
|
||||
float FuzzyHelper::evaluate (Goals::GatherArmy & g)
|
||||
{
|
||||
@ -525,7 +524,7 @@ float FuzzyHelper::evaluate (Goals::Invalid & g)
|
||||
}
|
||||
float FuzzyHelper::evaluate (Goals::AbstractGoal & g)
|
||||
{
|
||||
logAi->warnStream() << boost::format("Cannot evaluate goal %s") % g.name();
|
||||
logAi->warn("Cannot evaluate goal %s", g.name());
|
||||
return g.priority;
|
||||
}
|
||||
void FuzzyHelper::setPriority (Goals::TSubgoal & g)
|
||||
|
@ -182,7 +182,7 @@ namespace Goals
|
||||
|
||||
//TSubgoal AbstractGoal::whatToDoToAchieve()
|
||||
//{
|
||||
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
|
||||
// logAi->debug("Decomposing goal of type %s",name());
|
||||
// return sptr (Goals::Explore());
|
||||
//}
|
||||
|
||||
@ -422,7 +422,7 @@ TSubgoal VisitHero::whatToDoToAchieve()
|
||||
if (hero && ai->isAccessibleForHero(pos, hero, true) && isSafeToVisit(hero, pos)) //enemy heroes can get reinforcements
|
||||
{
|
||||
if (hero->pos == pos)
|
||||
logAi->errorStream() << "Hero " << hero.name << " tries to visit himself.";
|
||||
logAi->error("Hero %s tries to visit himself.", hero.name);
|
||||
else
|
||||
{
|
||||
//can't use VISIT_TILE here as tile appears blocked by target hero
|
||||
@ -442,8 +442,7 @@ bool VisitHero::fulfillsMe (TSubgoal goal)
|
||||
auto obj = cb->getObj(ObjectInstanceID(objid));
|
||||
if (!obj)
|
||||
{
|
||||
logAi->errorStream() << boost::format("Hero %s: VisitHero::fulfillsMe at %s: object %d not found")
|
||||
% hero.name % goal->tile % objid;
|
||||
logAi->error("Hero %s: VisitHero::fulfillsMe at %s: object %d not found", hero.name, goal->tile, objid);
|
||||
return false;
|
||||
}
|
||||
return obj->visitablePos() == goal->tile;
|
||||
@ -462,7 +461,7 @@ TSubgoal ClearWayTo::whatToDoToAchieve()
|
||||
assert(cb->isInTheMap(tile)); //set tile
|
||||
if(!cb->isVisible(tile))
|
||||
{
|
||||
logAi->errorStream() << "Clear way should be used with visible tiles!";
|
||||
logAi->error("Clear way should be used with visible tiles!");
|
||||
return sptr (Goals::Explore());
|
||||
}
|
||||
|
||||
@ -513,7 +512,7 @@ TGoalVec ClearWayTo::getAllPossibleSubgoals()
|
||||
|
||||
if (topObj->ID == Obj::HERO && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != PlayerRelations::ENEMIES)
|
||||
if (topObj != hero.get(true)) //the hero we want to free
|
||||
logAi->errorStream() << boost::format("%s stands in the way of %s") % topObj->getObjectName() % h->getObjectName();
|
||||
logAi->error("%s stands in the way of %s", topObj->getObjectName(), h->getObjectName());
|
||||
if (topObj->ID == Obj::QUEST_GUARD || topObj->ID == Obj::BORDERGUARD)
|
||||
{
|
||||
if (shouldVisit(h, topObj))
|
||||
@ -525,7 +524,7 @@ TGoalVec ClearWayTo::getAllPossibleSubgoals()
|
||||
else
|
||||
{
|
||||
//TODO: we should be able to return apriopriate quest here (VCAI::striveToQuest)
|
||||
logAi->debugStream() << "Quest guard blocks the way to " + tile();
|
||||
logAi->debug("Quest guard blocks the way to %s", tile());
|
||||
continue; //do not access quets guard if we can't complete the quest
|
||||
}
|
||||
}
|
||||
@ -545,7 +544,7 @@ TGoalVec ClearWayTo::getAllPossibleSubgoals()
|
||||
|
||||
if (ret.empty())
|
||||
{
|
||||
logAi->warnStream() << "There is no known way to clear the way to tile " + tile();
|
||||
logAi->warn("There is no known way to clear the way to tile %s",tile());
|
||||
throw goalFulfilledException (sptr(Goals::ClearWayTo(tile))); //make sure asigned hero gets unlocked
|
||||
}
|
||||
|
||||
@ -1129,7 +1128,7 @@ TGoalVec GatherArmy::getAllPossibleSubgoals()
|
||||
|
||||
//TSubgoal AbstractGoal::whatToDoToAchieve()
|
||||
//{
|
||||
// logAi->debugStream() << boost::format("Decomposing goal of type %s") % name();
|
||||
// logAi->debug("Decomposing goal of type %s",name());
|
||||
// return sptr (Goals::Explore());
|
||||
//}
|
||||
|
||||
|
@ -135,7 +135,7 @@ void VCAI::heroMoved(const TryMoveHero & details)
|
||||
{
|
||||
knownSubterraneanGates[o1] = o2;
|
||||
knownSubterraneanGates[o2] = o1;
|
||||
logAi->debugStream() << boost::format("Found a pair of subterranean gates between %s and %s!") % from % to;
|
||||
logAi->debug("Found a pair of subterranean gates between %s and %s!", from(), to());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user