Fuzzy.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include "../FuzzyLite/FuzzyLite.h"
  3. #include "Goals.h"
  4. /*
  5. * Fuzzy.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. class VCAI;
  14. class CArmedInstance;
  15. //class TSubgoal;
  16. //class TGoalVec;
  17. //class AbstractGoal;
  18. class FuzzyHelper
  19. {
  20. friend class VCAI;
  21. fl::FuzzyEngine engine;
  22. fl::InputLVar* bankInput;
  23. fl::OutputLVar* bankDanger;
  24. fl::RuleBlock bankBlock;
  25. class TacticalAdvantage
  26. {
  27. public:
  28. fl::InputLVar * ourWalkers, * ourShooters, * ourFlyers, * enemyWalkers, * enemyShooters, * enemyFlyers;
  29. fl::InputLVar * ourSpeed, * enemySpeed;
  30. fl::InputLVar * bankPresent;
  31. fl::InputLVar * castleWalls;
  32. fl::OutputLVar * threat;
  33. fl::RuleBlock tacticalAdvantage;
  34. ~TacticalAdvantage();
  35. } ta;
  36. class EvalVisitTile
  37. {
  38. public:
  39. fl::InputLVar * strengthRatio;
  40. fl::InputLVar * heroStrength;
  41. fl::InputLVar * tileDistance;
  42. fl::InputLVar * missionImportance;
  43. fl::InputLVar * movement;
  44. fl::OutputLVar * value;
  45. fl::RuleBlock rules;
  46. ~EvalVisitTile();
  47. } vt;
  48. public:
  49. enum RuleBlocks {BANK_DANGER, TACTICAL_ADVANTAGE, VISIT_TILE}; //where is it used and why it's needed?
  50. FuzzyHelper();
  51. void initBank();
  52. void initTacticalAdvantage();
  53. void initVisitTile();
  54. float evaluate (Goals::Explore & g);
  55. float evaluate (Goals::RecruitHero & g);
  56. float evaluate (Goals::VisitTile & g);
  57. float evaluate (Goals::VisitHero & g);
  58. float evaluate (Goals::BuildThis & g);
  59. float evaluate (Goals::DigAtTile & g);
  60. float evaluate (Goals::CollectRes & g);
  61. float evaluate (Goals::Build & g);
  62. float evaluate (Goals::Invalid & g);
  63. float evaluate (Goals::AbstractGoal & g);
  64. ui64 estimateBankDanger (int ID);
  65. float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us
  66. Goals::TSubgoal chooseSolution (Goals::TGoalVec vec);
  67. //shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec);
  68. };