Fuzzy.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "fl/Headers.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 SectorMap;
  17. class engineBase
  18. {
  19. public:
  20. fl::Engine engine;
  21. fl::RuleBlock rules;
  22. engineBase();
  23. void configure();
  24. void addRule(const std::string &txt);
  25. };
  26. class FuzzyHelper
  27. {
  28. friend class VCAI;
  29. class TacticalAdvantage : public engineBase
  30. {
  31. public:
  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. ~TacticalAdvantage();
  38. } ta;
  39. class EvalVisitTile : public engineBase
  40. {
  41. public:
  42. fl::InputVariable * strengthRatio;
  43. fl::InputVariable * heroStrength;
  44. fl::InputVariable * turnDistance;
  45. fl::InputVariable * missionImportance;
  46. fl::OutputVariable * value;
  47. fl::RuleBlock rules;
  48. ~EvalVisitTile();
  49. } vt;
  50. public:
  51. enum RuleBlocks {BANK_DANGER, TACTICAL_ADVANTAGE, VISIT_TILE};
  52. //blocks should be initialized in this order, which may be confusing :/
  53. FuzzyHelper();
  54. void initTacticalAdvantage();
  55. void initVisitTile();
  56. float evaluate (Goals::Explore & g);
  57. float evaluate (Goals::RecruitHero & g);
  58. float evaluate (Goals::VisitTile & g);
  59. float evaluate (Goals::VisitHero & g);
  60. float evaluate (Goals::BuildThis & g);
  61. float evaluate (Goals::DigAtTile & g);
  62. float evaluate (Goals::CollectRes & g);
  63. float evaluate (Goals::Build & g);
  64. float evaluate (Goals::GatherArmy & g);
  65. float evaluate (Goals::ClearWayTo & g);
  66. float evaluate (Goals::Invalid & g);
  67. float evaluate (Goals::AbstractGoal & g);
  68. void setPriority (Goals::TSubgoal & g);
  69. ui64 estimateBankDanger (const CBank * bank);
  70. float getTacticalAdvantage (const CArmedInstance *we, const CArmedInstance *enemy); //returns factor how many times enemy is stronger than us
  71. Goals::TSubgoal chooseSolution (Goals::TGoalVec vec);
  72. //std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec);
  73. };