Fuzzy.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 FuzzyHelper
  16. {
  17. friend class VCAI;
  18. fl::FuzzyEngine engine;
  19. fl::InputLVar* bankInput;
  20. fl::OutputLVar* bankDanger;
  21. fl::RuleBlock bankBlock;
  22. class TacticalAdvantage
  23. {
  24. public:
  25. fl::InputLVar * ourWalkers, * ourShooters, * ourFlyers, * enemyWalkers, * enemyShooters, * enemyFlyers;
  26. fl::InputLVar * ourSpeed, * enemySpeed;
  27. fl::InputLVar * bankPresent;
  28. fl::InputLVar * castleWalls;
  29. fl::OutputLVar * threat;
  30. fl::RuleBlock tacticalAdvantage;
  31. ~TacticalAdvantage();
  32. } ta;
  33. class EvalVisitTile
  34. {
  35. public:
  36. fl::InputLVar * strengthRatio;
  37. fl::InputLVar * heroStrength;
  38. fl::InputLVar * turnDistance;
  39. fl::InputLVar * missionImportance;
  40. fl::OutputLVar * value;
  41. fl::RuleBlock rules;
  42. ~EvalVisitTile();
  43. } vt;
  44. public:
  45. enum RuleBlocks {BANK_DANGER, TACTICAL_ADVANTAGE, VISIT_TILE};
  46. //blocks should be initialized in this order, which may be confusing :/
  47. FuzzyHelper();
  48. void initBank();
  49. void initTacticalAdvantage();
  50. void initVisitTile();
  51. float evaluate (Goals::Explore & g);
  52. float evaluate (Goals::RecruitHero & g);
  53. float evaluate (Goals::VisitTile & g);
  54. float evaluate (Goals::VisitHero & g);
  55. float evaluate (Goals::BuildThis & g);
  56. float evaluate (Goals::DigAtTile & g);
  57. float evaluate (Goals::CollectRes & g);
  58. float evaluate (Goals::Build & g);
  59. float evaluate (Goals::Invalid & g);
  60. float evaluate (Goals::AbstractGoal & g);
  61. void setPriority (Goals::TSubgoal & g);
  62. ui64 estimateBankDanger (int ID);
  63. float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us
  64. Goals::TSubgoal chooseSolution (Goals::TGoalVec vec);
  65. //shared_ptr<AbstractGoal> chooseSolution (std::vector<shared_ptr<AbstractGoal>> & vec);
  66. };