diff --git a/AI/VCAI/Fuzzy.cpp b/AI/VCAI/Fuzzy.cpp index 2c7a8b4d5..e9154d53a 100644 --- a/AI/VCAI/Fuzzy.cpp +++ b/AI/VCAI/Fuzzy.cpp @@ -278,20 +278,21 @@ float FuzzyHelper::getTacticalAdvantage (const CArmedInstance *we, const CArmedI } //shared_ptr chooseSolution (std::vector> & vec) -//{ -// typedef std::pair, float> goalValue; -// std::vector values; -// -// for (auto g : vec) -// { -// values.push_back (std::make_pair(g, 66.6f)); -// } -// -// auto compareGoals = [&](const goalValue & lhs, const goalValue & rhs) -> bool -// { -// return lhs.second < rhs.second; -// }; -// -// boost::sort (values, compareGoals); -// return values.end()->first; -//} \ No newline at end of file +Goals::TSubgoal chooseSolution (Goals::TGoalVec & vec) +{ + typedef std::pair goalValue; + std::vector values; + + for (auto g : vec) + { + values.push_back (std::make_pair(g, 66.6f)); + } + + auto compareGoals = [&](const goalValue & lhs, const goalValue & rhs) -> bool + { + return lhs.second < rhs.second; + }; + + boost::sort (values, compareGoals); + return values.end()->first; +} \ No newline at end of file diff --git a/AI/VCAI/Fuzzy.h b/AI/VCAI/Fuzzy.h index 5f617f376..c34a78c9f 100644 --- a/AI/VCAI/Fuzzy.h +++ b/AI/VCAI/Fuzzy.h @@ -1,5 +1,6 @@ #pragma once #include "../FuzzyLite/FuzzyLite.h" +#include "Goals.h" /* * Fuzzy.h, part of VCMI engine @@ -44,7 +45,6 @@ public: ui64 estimateBankDanger (int ID); float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us - //FIXME: use Goals namespace - //Goals::TSubgoal chooseSolution (Goals::TGoalVec & vec); + Goals::TSubgoal chooseSolution (Goals::TGoalVec & vec); //shared_ptr chooseSolution (std::vector> & vec); }; diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 81db79adc..b6ee61546 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -869,13 +869,19 @@ void CGoal::accept (VCAI * ai) } //TODO: find out why the following are not generated automatically on MVS? -void CGoal::accept (VCAI * ai) -{ - ai->tryRealize(static_cast(*this)); -} - -void CGoal::accept (VCAI * ai) -{ - ai->tryRealize(static_cast(*this)); + +namespace Goals +{ + template <> + void CGoal::accept (VCAI * ai) + { + ai->tryRealize(static_cast(*this)); + } + + template <> + void CGoal::accept (VCAI * ai) + { + ai->tryRealize(static_cast(*this)); + } }