FuzzyEngines.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * FuzzyEngines.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "fl/Headers.h"
  12. #include "Goals.h"
  13. class CArmedInstance;
  14. class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these...
  15. {
  16. protected:
  17. fl::Engine engine;
  18. fl::RuleBlock rules;
  19. virtual void configure();
  20. void addRule(const std::string & txt);
  21. public:
  22. engineBase();
  23. };
  24. class TacticalAdvantageEngine : public engineBase
  25. {
  26. public:
  27. TacticalAdvantageEngine();
  28. float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
  29. private:
  30. fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers;
  31. fl::InputVariable * ourSpeed, *enemySpeed;
  32. fl::InputVariable * bankPresent;
  33. fl::InputVariable * castleWalls;
  34. fl::OutputVariable * threat;
  35. };
  36. class HeroMovementGoalEngineBase : public engineBase //in future - maybe derive from some (GoalEngineBase : public engineBase) class for handling non-movement goals with common utility for goal engines
  37. {
  38. public:
  39. HeroMovementGoalEngineBase();
  40. protected:
  41. void setSharedFuzzyVariables(Goals::AbstractGoal & goal);
  42. fl::InputVariable * strengthRatio;
  43. fl::InputVariable * heroStrength;
  44. fl::InputVariable * turnDistance;
  45. fl::InputVariable * missionImportance;
  46. fl::OutputVariable * value;
  47. private:
  48. float calculateTurnDistanceInputValue(const CGHeroInstance * h, int3 tile) const;
  49. };
  50. class VisitTileEngine : public HeroMovementGoalEngineBase
  51. {
  52. public:
  53. VisitTileEngine();
  54. float evaluate(Goals::VisitTile & goal);
  55. };
  56. class VisitObjEngine : public HeroMovementGoalEngineBase
  57. {
  58. public:
  59. VisitObjEngine();
  60. float evaluate(Goals::VisitObj & goal);
  61. protected:
  62. fl::InputVariable * objectValue;
  63. };