Fuzzy.h 2.2 KB

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