Fuzzy.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. #include "StdInc.h"
  2. #include "Fuzzy.h"
  3. #include <limits>
  4. #include "../../lib/CObjectHandler.h"
  5. #include "../../lib/CCreatureHandler.h"
  6. #include "../../lib/VCMI_Lib.h"
  7. #include "../../CCallback.h"
  8. //#include "Goals.cpp"
  9. #include "VCAI.h"
  10. /*
  11. * Fuzzy.cpp, part of VCMI engine
  12. *
  13. * Authors: listed in file AUTHORS in main folder
  14. *
  15. * License: GNU General Public License v2.0 or later
  16. * Full text of license available in license.txt file, in main folder
  17. *
  18. */
  19. #define MIN_AI_STRENGHT (0.5f) //lower when combat AI gets smarter
  20. #define UNGUARDED_OBJECT (100.0f) //we consider unguarded objects 10 times weaker than us
  21. struct BankConfig;
  22. class FuzzyEngine;
  23. class InputLVar;
  24. class CGTownInstance;
  25. using namespace boost::assign;
  26. using namespace vstd;
  27. //using namespace Goals;
  28. FuzzyHelper *fh;
  29. extern boost::thread_specific_ptr<CCallback> cb;
  30. extern boost::thread_specific_ptr<VCAI> ai;
  31. struct armyStructure
  32. {
  33. float walkers, shooters, flyers;
  34. ui32 maxSpeed;
  35. };
  36. ui64 evaluateBankConfig (BankConfig * bc)
  37. {
  38. ui64 danger = 0;
  39. for (auto opt : bc->guards)
  40. {
  41. danger += VLC->creh->creatures[opt.first]->fightValue * opt.second;
  42. }
  43. return danger;
  44. }
  45. armyStructure evaluateArmyStructure (const CArmedInstance * army)
  46. {
  47. ui64 totalStrenght = army->getArmyStrength();
  48. double walkersStrenght = 0;
  49. double flyersStrenght = 0;
  50. double shootersStrenght = 0;
  51. ui32 maxSpeed = 0;
  52. for(auto s : army->Slots())
  53. {
  54. bool walker = true;
  55. if (s.second->type->hasBonusOfType(Bonus::SHOOTER))
  56. {
  57. shootersStrenght += s.second->getPower();
  58. walker = false;
  59. }
  60. if (s.second->type->hasBonusOfType(Bonus::FLYING))
  61. {
  62. flyersStrenght += s.second->getPower();
  63. walker = false;
  64. }
  65. if (walker)
  66. walkersStrenght += s.second->getPower();
  67. amax (maxSpeed, s.second->type->valOfBonuses(Bonus::STACKS_SPEED));
  68. }
  69. armyStructure as;
  70. as.walkers = walkersStrenght / totalStrenght;
  71. as.shooters = shootersStrenght / totalStrenght;
  72. as.flyers = flyersStrenght / totalStrenght;
  73. as.maxSpeed = maxSpeed;
  74. return as;
  75. }
  76. FuzzyHelper::FuzzyHelper()
  77. {
  78. engine.hedgeSet().add(new fl::HedgeSomewhat());
  79. engine.hedgeSet().add(new fl::HedgeVery());
  80. engine.fuzzyOperator().setAggregation(new fl::FuzzyOrSum()); //to consider all cases simultaneously
  81. initBank();
  82. initTacticalAdvantage();
  83. initVisitTile();
  84. logAi->infoStream() << engine.toString();
  85. }
  86. void FuzzyHelper::initBank()
  87. {
  88. try
  89. {
  90. //Trivial bank estimation
  91. bankInput = new fl::InputLVar("BankInput");
  92. bankDanger = new fl::OutputLVar("BankDanger");
  93. bankInput->addTerm(new fl::SingletonTerm ("SET", 0.5));
  94. engine.addInputLVar (bankInput);
  95. engine.addOutputLVar (bankDanger);
  96. engine.addRuleBlock (&bankBlock);
  97. for (int i = 0; i < 4; ++i)
  98. {
  99. bankDanger->addTerm(new fl::TriangularTerm ("Bank" + boost::lexical_cast<std::string>(i), 0, 1));
  100. bankBlock.addRule(new fl::MamdaniRule("if BankInput is SET then BankDanger is Bank" + boost::lexical_cast<std::string>(i), engine));
  101. }
  102. }
  103. catch (fl::FuzzyException & fe)
  104. {
  105. logAi->errorStream() << "initBank " << fe.name() << ": " << fe.message();
  106. }
  107. }
  108. void FuzzyHelper::initTacticalAdvantage()
  109. {
  110. try
  111. {
  112. //Tactical advantage calculation
  113. std::vector<fl::InputLVar*> helper;
  114. ta.ourShooters = new fl::InputLVar("OurShooters");
  115. ta.ourWalkers = new fl::InputLVar("OurWalkers");
  116. ta.ourFlyers = new fl::InputLVar("OurFlyers");
  117. ta.enemyShooters = new fl::InputLVar("EnemyShooters");
  118. ta.enemyWalkers = new fl::InputLVar("EnemyWalkers");
  119. ta.enemyFlyers = new fl::InputLVar("EnemyFlyers");
  120. helper += ta.ourShooters, ta.ourWalkers, ta.ourFlyers, ta.enemyShooters, ta.enemyWalkers, ta.enemyFlyers;
  121. for (auto val : helper)
  122. {
  123. engine.addInputLVar(val);
  124. val->addTerm (new fl::ShoulderTerm("FEW", 0, 0.6, true));
  125. val->addTerm (new fl::ShoulderTerm("MANY", 0.4, 1, false));
  126. }
  127. helper.clear();
  128. ta.ourSpeed = new fl::InputLVar("OurSpeed");
  129. ta.enemySpeed = new fl::InputLVar("EnemySpeed");
  130. helper += ta.ourSpeed, ta.enemySpeed;
  131. for (auto val : helper)
  132. {
  133. engine.addInputLVar(val);
  134. val->addTerm (new fl::ShoulderTerm("LOW", 3, 6.5, true));
  135. val->addTerm (new fl::TriangularTerm("MEDIUM", 5.5, 10.5));
  136. val->addTerm (new fl::ShoulderTerm("HIGH", 8.5, 16, false));
  137. }
  138. ta.castleWalls = new fl::InputLVar("CastleWalls");
  139. engine.addInputLVar(ta.castleWalls);
  140. ta.castleWalls->addTerm(new fl::SingletonTerm("NONE", CGTownInstance::NONE));
  141. ta.castleWalls->addTerm(new fl::TrapezoidalTerm("MEDIUM", CGTownInstance::FORT, 2.5));
  142. ta.castleWalls->addTerm(new fl::ShoulderTerm("HIGH", CGTownInstance::CITADEL - 0.1, CGTownInstance::CASTLE, false));
  143. ta.bankPresent = new fl::InputLVar("Bank");
  144. engine.addInputLVar(ta.bankPresent);
  145. ta.bankPresent->addTerm(new fl::SingletonTerm("FALSE", 0));
  146. ta.bankPresent->addTerm(new fl::SingletonTerm("TRUE", 1));
  147. ta.threat = new fl::OutputLVar("Threat");
  148. engine.addOutputLVar(ta.threat);
  149. ta.threat->addTerm (new fl::ShoulderTerm("LOW", MIN_AI_STRENGHT, 1, true));
  150. ta.threat->addTerm (new fl::TriangularTerm("MEDIUM", 0.8, 1.2));
  151. ta.threat->addTerm (new fl::ShoulderTerm("HIGH", 1, 1.5, false));
  152. engine.addRuleBlock (&ta.tacticalAdvantage);
  153. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurShooters is MANY and EnemySpeed is LOW then Threat is LOW", engine));
  154. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurShooters is MANY and EnemyShooters is FEW then Threat is LOW", engine));
  155. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurSpeed is LOW and EnemyShooters is MANY then Threat is HIGH", engine));
  156. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurSpeed is HIGH and EnemyShooters is MANY then Threat is LOW", engine));
  157. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurWalkers is FEW and EnemyShooters is MANY then Threat is somewhat LOW", engine));
  158. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if OurShooters is MANY and EnemySpeed is HIGH then Threat is somewhat HIGH", engine));
  159. //just to cover all cases
  160. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if EnemySpeed is MEDIUM then Threat is MEDIUM", engine));
  161. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if EnemySpeed is LOW and OurShooters is FEW then Threat is MEDIUM", engine));
  162. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if Bank is TRUE and OurShooters is MANY then Threat is somewhat HIGH", engine));
  163. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if Bank is TRUE and EnemyShooters is MANY then Threat is LOW", engine));
  164. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if CastleWalls is HIGH and OurWalkers is MANY then Threat is very HIGH", engine));
  165. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if CastleWalls is HIGH and OurFlyers is MANY and OurShooters is MANY then Threat is MEDIUM", engine));
  166. ta.tacticalAdvantage.addRule(new fl::MamdaniRule("if CastleWalls is MEDIUM and OurShooters is MANY and EnemyWalkers is MANY then Threat is LOW", engine));
  167. }
  168. catch(fl::ParsingException & pe)
  169. {
  170. logAi->errorStream() << "initTacticalAdvantage " << pe.name() << ": " << pe.message();
  171. }
  172. catch (fl::FuzzyException & fe)
  173. {
  174. logAi->errorStream() << "initTacticalAdvantage " << fe.name() << ": " << fe.message();
  175. }
  176. }
  177. ui64 FuzzyHelper::estimateBankDanger (int ID)
  178. {
  179. std::vector <ConstTransitivePtr<BankConfig>> & configs = VLC->objh->banksInfo[ID];
  180. ui64 val = std::numeric_limits<ui64>::max();
  181. try
  182. {
  183. switch (configs.size())
  184. {
  185. case 4:
  186. try
  187. {
  188. for (int i = 0; i < 4; ++i)
  189. {
  190. int bankVal = evaluateBankConfig (VLC->objh->banksInfo[ID][i]);
  191. bankDanger->term("Bank" + boost::lexical_cast<std::string>(i))->setMinimum(bankVal * 0.5f);
  192. bankDanger->term("Bank" + boost::lexical_cast<std::string>(i))->setMaximum(bankVal * 1.5f);
  193. }
  194. //comparison purposes
  195. //int averageValue = (evaluateBankConfig (VLC->objh->banksInfo[ID][0]) + evaluateBankConfig (VLC->objh->banksInfo[ID][3])) * 0.5;
  196. //dynamic_cast<fl::SingletonTerm*>(bankInput->term("SET"))->setValue(0.5);
  197. bankInput->setInput (0.5);
  198. engine.process (BANK_DANGER);
  199. //engine.process();
  200. val = bankDanger->output().defuzzify(); //some expected value of this bank
  201. }
  202. catch (fl::FuzzyException & fe)
  203. {
  204. logAi->errorStream() << fe.name() << ": " << fe.message();
  205. }
  206. break;
  207. case 1: //rare case - Pyramid
  208. val = evaluateBankConfig (VLC->objh->banksInfo[ID][0]);
  209. break;
  210. default:
  211. logAi->warnStream() << ("Uhnandled bank config!");
  212. }
  213. }
  214. catch (fl::FuzzyException & fe)
  215. {
  216. logAi->errorStream() << "estimateBankDanger " << fe.name() << ": " << fe.message();
  217. }
  218. return val;
  219. }
  220. float FuzzyHelper::getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy)
  221. {
  222. float output = 1;
  223. try
  224. {
  225. armyStructure ourStructure = evaluateArmyStructure(we);
  226. armyStructure enemyStructure = evaluateArmyStructure(enemy);
  227. ta.ourWalkers->setInput(ourStructure.walkers);
  228. ta.ourShooters->setInput(ourStructure.shooters);
  229. ta.ourFlyers->setInput(ourStructure.flyers);
  230. ta.ourSpeed->setInput(ourStructure.maxSpeed);
  231. ta.enemyWalkers->setInput(enemyStructure.walkers);
  232. ta.enemyShooters->setInput(enemyStructure.shooters);
  233. ta.enemyFlyers->setInput(enemyStructure.flyers);
  234. ta.enemySpeed->setInput(enemyStructure.maxSpeed);
  235. bool bank = dynamic_cast<const CBank*>(enemy);
  236. if (bank)
  237. ta.bankPresent->setInput(1);
  238. else
  239. ta.bankPresent->setInput(0);
  240. const CGTownInstance * fort = dynamic_cast<const CGTownInstance*>(enemy);
  241. if (fort)
  242. {
  243. ta.castleWalls->setInput (fort->fortLevel());
  244. }
  245. else
  246. ta.castleWalls->setInput(0);
  247. engine.process (TACTICAL_ADVANTAGE);
  248. //engine.process();
  249. output = ta.threat->output().defuzzify();
  250. }
  251. catch (fl::FuzzyException & fe)
  252. {
  253. logAi->errorStream() << "getTacticalAdvantage " << fe.name() << ": " << fe.message();
  254. }
  255. return output;
  256. }
  257. FuzzyHelper::TacticalAdvantage::~TacticalAdvantage()
  258. {
  259. //TODO: smart pointers?
  260. delete ourWalkers;
  261. delete ourShooters;
  262. delete ourFlyers;
  263. delete enemyWalkers;
  264. delete enemyShooters;
  265. delete enemyFlyers;
  266. delete ourSpeed;
  267. delete enemySpeed;
  268. delete bankPresent;
  269. delete castleWalls;
  270. delete threat;
  271. }
  272. //shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec)
  273. Goals::TSubgoal FuzzyHelper::chooseSolution (Goals::TGoalVec vec)
  274. {
  275. if (vec.empty()) //no possibilities found
  276. return sptr(Goals::Invalid());
  277. for (auto g : vec)
  278. {
  279. setPriority(g);
  280. }
  281. auto compareGoals = [](const Goals::TSubgoal & lhs, const Goals::TSubgoal & rhs) -> bool
  282. {
  283. return lhs->priority < rhs->priority;
  284. };
  285. boost::sort (vec, compareGoals);
  286. return vec.back();
  287. }
  288. float FuzzyHelper::evaluate (Goals::Explore & g)
  289. {
  290. return 1;
  291. }
  292. float FuzzyHelper::evaluate (Goals::RecruitHero & g)
  293. {
  294. return 1; //just try to recruit hero as one of options
  295. }
  296. FuzzyHelper::EvalVisitTile::~EvalVisitTile()
  297. {
  298. delete strengthRatio;
  299. delete heroStrength;
  300. delete turnDistance;
  301. delete missionImportance;
  302. }
  303. void FuzzyHelper::initVisitTile()
  304. {
  305. try
  306. {
  307. std::vector<fl::InputLVar*> helper;
  308. vt.strengthRatio = new fl::InputLVar("strengthRatio"); //hero must be strong enough to defeat guards
  309. vt.heroStrength = new fl::InputLVar("heroStrength"); //we want to use weakest possible hero
  310. vt.turnDistance = new fl::InputLVar("turnDistance"); //we want to use hero who is near
  311. vt.missionImportance = new fl::InputLVar("lockedMissionImportance"); //we may want to preempt hero with low-priority mission
  312. vt.value = new fl::OutputLVar("Value");
  313. helper += vt.strengthRatio, vt.heroStrength, vt.turnDistance, vt.missionImportance;
  314. for (auto val : helper)
  315. {
  316. engine.addInputLVar(val);
  317. }
  318. engine.addOutputLVar (vt.value);
  319. vt.strengthRatio->addTerm (new fl::ShoulderTerm("LOW", 0, SAFE_ATTACK_CONSTANT, true));
  320. vt.strengthRatio->addTerm (new fl::ShoulderTerm("HIGH", SAFE_ATTACK_CONSTANT, SAFE_ATTACK_CONSTANT * 3, false));
  321. //strength compared to our main hero
  322. vt.heroStrength->addTerm (new fl::ShoulderTerm("LOW", 0, 0.2, true));
  323. vt.heroStrength->addTerm (new fl::TriangularTerm("MEDIUM", 0.2, 0.8));
  324. vt.heroStrength->addTerm (new fl::ShoulderTerm("HIGH", 0.5, 1, false));
  325. vt.turnDistance->addTerm (new fl::ShoulderTerm("SMALL", 0, 0.5, true));
  326. vt.turnDistance->addTerm (new fl::TriangularTerm("MEDIUM", 0.1, 0.8));
  327. vt.turnDistance->addTerm (new fl::ShoulderTerm("LONG", 0.5, 3, false));
  328. vt.missionImportance->addTerm (new fl::ShoulderTerm("LOW", 0, 2.5, true));
  329. vt.missionImportance->addTerm (new fl::TriangularTerm("MEDIUM", 2, 3));
  330. vt.missionImportance->addTerm (new fl::ShoulderTerm("HIGH", 2.5, 5, false));
  331. //an issue: in 99% cases this outputs center of mass (2.5) regardless of actual input :/
  332. //should be same as "mission Importance" to keep consistency
  333. vt.value->addTerm (new fl::ShoulderTerm("LOW", 0, 2.5, true));
  334. vt.value->addTerm (new fl::TriangularTerm("MEDIUM", 2, 3)); //can't be center of mass :/
  335. vt.value->addTerm (new fl::ShoulderTerm("HIGH", 2.5, 5, false));
  336. engine.addRuleBlock (&vt.rules);
  337. //use unarmed scouts if possible
  338. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is HIGH and heroStrength is LOW then Value is very HIGH", engine));
  339. //we may want to use secondary hero(es) rather than main hero
  340. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is HIGH and heroStrength is MEDIUM then Value is somewhat HIGH", engine));
  341. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is HIGH and heroStrength is HIGH then Value is somewhat LOW", engine));
  342. //don't assign targets to heroes who are too weak, but prefer targets of our main hero (in case we need to gather army)
  343. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is LOW and heroStrength is LOW then Value is very LOW", engine));
  344. //attempt to arm secondary heroes is not stupid
  345. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is LOW and heroStrength is MEDIUM then Value is somewhat HIGH", engine));
  346. vt.rules.addRule (new fl::MamdaniRule("if strengthRatio is LOW and heroStrength is HIGH then Value is LOW", engine));
  347. //do not cancel important goals
  348. vt.rules.addRule (new fl::MamdaniRule("if lockedMissionImportance is HIGH then Value is very LOW", engine));
  349. vt.rules.addRule (new fl::MamdaniRule("if lockedMissionImportance is MEDIUM then Value is somewhat LOW", engine));
  350. vt.rules.addRule (new fl::MamdaniRule("if lockedMissionImportance is LOW then Value is HIGH", engine));
  351. //pick nearby objects if it's easy, avoid long walks
  352. vt.rules.addRule (new fl::MamdaniRule("if turnDistance is SMALL then Value is HIGH", engine));
  353. vt.rules.addRule (new fl::MamdaniRule("if turnDistance is MEDIUM then Value is MEDIUM", engine));
  354. vt.rules.addRule (new fl::MamdaniRule("if turnDistance is LONG then Value is LOW", engine));
  355. }
  356. catch (fl::FuzzyException & fe)
  357. {
  358. logAi->errorStream() << "visitTile " << fe.name() << ": " << fe.message();
  359. }
  360. }
  361. float FuzzyHelper::evaluate (Goals::VisitTile & g)
  362. {
  363. //we assume that hero is already set and we want to choose most suitable one for the mission
  364. if (!g.hero)
  365. return 0;
  366. //assert(cb->isInTheMap(g.tile));
  367. cb->setSelection (g.hero.h);
  368. float turns = 0;
  369. float distance = cb->getMovementCost(g.hero.h, g.tile);
  370. if (!distance) //we stand on that tile
  371. turns = 0;
  372. else
  373. {
  374. if (distance < g.hero->movement) //we can move there within one turn
  375. turns = (fl::flScalar)distance /g.hero->movement;
  376. else
  377. turns = 1 + (fl::flScalar)(distance - g.hero->movement)/g.hero->maxMovePoints(true); //bool on land?
  378. }
  379. float missionImportance = 0;
  380. if (vstd::contains(ai->lockedHeroes, g.hero))
  381. missionImportance = ai->lockedHeroes[g.hero]->priority;
  382. float strengthRatio = 10.0f; //we are much stronger than enemy
  383. ui64 danger = evaluateDanger (g.tile, g.hero.h);
  384. if (danger)
  385. strengthRatio = (fl::flScalar)g.hero.h->getTotalStrength() / danger;
  386. try
  387. {
  388. vt.strengthRatio->setInput (strengthRatio);
  389. vt.heroStrength->setInput ((fl::flScalar)g.hero->getTotalStrength()/ai->primaryHero()->getTotalStrength());
  390. vt.turnDistance->setInput (turns);
  391. vt.missionImportance->setInput (missionImportance);
  392. //engine.process();
  393. engine.process (VISIT_TILE);
  394. g.priority = vt.value->output().defuzzify();
  395. }
  396. catch (fl::FuzzyException & fe)
  397. {
  398. logAi->errorStream() << "evaluate VisitTile " << fe.name() << ": " << fe.message();
  399. }
  400. return g.priority;
  401. }
  402. float FuzzyHelper::evaluate (Goals::VisitHero & g)
  403. {
  404. auto obj = cb->getObj(ObjectInstanceID(g.objid)); //we assume for now that these goals are similiar
  405. //TODO: consider direct copy (constructor?)
  406. g.setpriority(Goals::VisitTile(obj->visitablePos()).sethero(g.hero).setisAbstract(g.isAbstract).accept(this));
  407. return g.priority;
  408. }
  409. float FuzzyHelper::evaluate (Goals::GatherArmy & g)
  410. {
  411. //the more army we need, the more important goal
  412. //the more army we lack, the less important goal
  413. float army = g.hero->getArmyStrength();
  414. return g.value / std::max(g.value - army, 1000.0f);
  415. }
  416. float FuzzyHelper::evaluate (Goals::BuildThis & g)
  417. {
  418. return 1;
  419. }
  420. float FuzzyHelper::evaluate (Goals::DigAtTile & g)
  421. {
  422. return 0;
  423. }
  424. float FuzzyHelper::evaluate (Goals::CollectRes & g)
  425. {
  426. return 0;
  427. }
  428. float FuzzyHelper::evaluate (Goals::Build & g)
  429. {
  430. return 0;
  431. }
  432. float FuzzyHelper::evaluate (Goals::Invalid & g)
  433. {
  434. return -1e10;
  435. }
  436. float FuzzyHelper::evaluate (Goals::AbstractGoal & g)
  437. {
  438. logAi->warnStream() << boost::format("Cannot evaluate goal %s") % g.name();
  439. return g.priority;
  440. }
  441. void FuzzyHelper::setPriority (Goals::TSubgoal & g)
  442. {
  443. g->setpriority(g->accept(this)); //this enforces returned value is set
  444. }