Fuzzy.h 2.3 KB

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