1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
Dydzio 2018-08-10 20:36:42 +02:00
parent 72b206347f
commit a7c2d03c87
4 changed files with 15 additions and 20 deletions

View File

@ -342,7 +342,7 @@ void HeroMovementGoalEngineBase::setSharedFuzzyVariables(Goals::AbstractGoal & g
}
}
GetObjEngine::GetObjEngine()
VisitObjEngine::VisitObjEngine()
{
try
{
@ -367,14 +367,12 @@ GetObjEngine::GetObjEngine()
configure();
}
float GetObjEngine::evaluate(Goals::AbstractGoal & goal)
float VisitObjEngine::evaluate(Goals::VisitObj & goal)
{
auto g = dynamic_cast<Goals::VisitObj &>(goal);
if(!g.hero)
if(!goal.hero)
return 0;
auto obj = ai->myCb->getObj(ObjectInstanceID(g.objid));
auto obj = ai->myCb->getObj(ObjectInstanceID(goal.objid));
boost::optional<int> objValueKnownByAI = MapObjectsEvaluator::getInstance().getObjectValue(obj->ID, obj->subID);
@ -412,11 +410,10 @@ VisitTileEngine::VisitTileEngine() //so far no VisitTile-specific variables that
configure();
}
float VisitTileEngine::evaluate(Goals::AbstractGoal & goal)
float VisitTileEngine::evaluate(Goals::VisitTile & goal)
{
auto g = dynamic_cast<Goals::VisitTile &>(goal);
//we assume that hero is already set and we want to choose most suitable one for the mission
if(!g.hero)
if(!goal.hero)
return 0;
//assert(cb->isInTheMap(g.tile));
@ -426,12 +423,12 @@ float VisitTileEngine::evaluate(Goals::AbstractGoal & goal)
try
{
engine.process();
g.priority = value->getValue();
goal.priority = value->getValue();
}
catch(fl::Exception & fe)
{
logAi->error("evaluate VisitTile: %s", fe.getWhat());
}
assert(g.priority >= 0);
return g.priority;
assert(goal.priority >= 0);
return goal.priority;
}

View File

@ -42,8 +42,6 @@ class HeroMovementGoalEngineBase : public engineBase //in future - maybe derive
public:
HeroMovementGoalEngineBase();
virtual float evaluate(Goals::AbstractGoal & goal) = 0;
protected:
void setSharedFuzzyVariables(Goals::AbstractGoal & goal);
@ -61,14 +59,14 @@ class VisitTileEngine : public HeroMovementGoalEngineBase
{
public:
VisitTileEngine();
float evaluate(Goals::AbstractGoal & goal) override;
float evaluate(Goals::VisitTile & goal);
};
class GetObjEngine : public HeroMovementGoalEngineBase
class VisitObjEngine : public HeroMovementGoalEngineBase
{
public:
GetObjEngine();
float evaluate(Goals::AbstractGoal & goal) override;
VisitObjEngine();
float evaluate(Goals::VisitObj & goal);
protected:
fl::InputVariable * objectValue;
};

View File

@ -68,7 +68,7 @@ float FuzzyHelper::evaluate(Goals::VisitTile & g)
}
float FuzzyHelper::evaluate(Goals::VisitObj & g)
{
return getObjEngine.evaluate(g);
return visitObjEngine.evaluate(g);
}
float FuzzyHelper::evaluate(Goals::VisitHero & g)
{

View File

@ -17,7 +17,7 @@ class FuzzyHelper
public:
TacticalAdvantageEngine tacticalAdvantageEngine;
VisitTileEngine visitTileEngine;
GetObjEngine getObjEngine;
VisitObjEngine visitObjEngine;
float evaluate(Goals::Explore & g);
float evaluate(Goals::RecruitHero & g);