FuzzyEngines.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/AbstractGoal.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CArmedInstance;
  15. VCMI_LIB_NAMESPACE_END
  16. class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these...
  17. {
  18. protected:
  19. fl::Engine engine;
  20. fl::RuleBlock * rules;
  21. virtual void configure();
  22. void addRule(const std::string & txt);
  23. public:
  24. engineBase();
  25. };
  26. class TacticalAdvantageEngine : public engineBase //TODO: rework this engine, it does not work well (example: AI hero with 140 beholders attacked 150 beholders - engine lowered danger 50000 -> 35000)
  27. {
  28. public:
  29. TacticalAdvantageEngine();
  30. float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
  31. private:
  32. fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers;
  33. fl::InputVariable * ourSpeed, *enemySpeed;
  34. fl::InputVariable * bankPresent;
  35. fl::InputVariable * castleWalls;
  36. fl::OutputVariable * threat;
  37. };
  38. 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
  39. {
  40. public:
  41. HeroMovementGoalEngineBase();
  42. protected:
  43. void setSharedFuzzyVariables(Goals::AbstractGoal & goal);
  44. fl::InputVariable * strengthRatio;
  45. fl::InputVariable * heroStrength;
  46. fl::InputVariable * turnDistance;
  47. fl::InputVariable * missionImportance;
  48. fl::OutputVariable * value;
  49. private:
  50. float calculateTurnDistanceInputValue(const Goals::AbstractGoal & goal) const;
  51. };
  52. class VisitTileEngine : public HeroMovementGoalEngineBase
  53. {
  54. public:
  55. VisitTileEngine();
  56. float evaluate(Goals::VisitTile & goal);
  57. };
  58. class VisitObjEngine : public HeroMovementGoalEngineBase
  59. {
  60. public:
  61. VisitObjEngine();
  62. float evaluate(Goals::VisitObj & goal);
  63. protected:
  64. fl::InputVariable * objectValue;
  65. };