From a7c2d03c87a0fdef517b9a563dc33e2326d14f5e Mon Sep 17 00:00:00 2001 From: Dydzio Date: Fri, 10 Aug 2018 20:36:42 +0200 Subject: [PATCH] Fixes --- AI/VCAI/FuzzyEngines.cpp | 21 +++++++++------------ AI/VCAI/FuzzyEngines.h | 10 ++++------ AI/VCAI/FuzzyHelper.cpp | 2 +- AI/VCAI/FuzzyHelper.h | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/AI/VCAI/FuzzyEngines.cpp b/AI/VCAI/FuzzyEngines.cpp index 2adb5ec82..421a6900f 100644 --- a/AI/VCAI/FuzzyEngines.cpp +++ b/AI/VCAI/FuzzyEngines.cpp @@ -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(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 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(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; } \ No newline at end of file diff --git a/AI/VCAI/FuzzyEngines.h b/AI/VCAI/FuzzyEngines.h index f175654f7..e0b028b9b 100644 --- a/AI/VCAI/FuzzyEngines.h +++ b/AI/VCAI/FuzzyEngines.h @@ -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; }; \ No newline at end of file diff --git a/AI/VCAI/FuzzyHelper.cpp b/AI/VCAI/FuzzyHelper.cpp index 094711fe1..304cb45c8 100644 --- a/AI/VCAI/FuzzyHelper.cpp +++ b/AI/VCAI/FuzzyHelper.cpp @@ -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) { diff --git a/AI/VCAI/FuzzyHelper.h b/AI/VCAI/FuzzyHelper.h index 619dbd11a..52715eb02 100644 --- a/AI/VCAI/FuzzyHelper.h +++ b/AI/VCAI/FuzzyHelper.h @@ -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);