Fuzzy.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Fuzzy.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "fl/Headers.h"
  12. #include "Goals.h"
  13. class VCAI;
  14. class CArmedInstance;
  15. class CBank;
  16. struct 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::InputVariable * estimatedReward;
  47. fl::OutputVariable * value;
  48. fl::RuleBlock rules;
  49. ~EvalVisitTile();
  50. } vt;
  51. class EvalWanderTargetObject : public engineBase //designed for use with VCAI::wander()
  52. {
  53. public:
  54. fl::InputVariable * distance;
  55. fl::InputVariable * objectValue;
  56. fl::OutputVariable * visitGain;
  57. ~EvalWanderTargetObject();
  58. } wanderTarget;
  59. private:
  60. float calculateTurnDistanceInputValue(const CGHeroInstance * h, int3 tile) const;
  61. public:
  62. enum RuleBlocks {BANK_DANGER, TACTICAL_ADVANTAGE, VISIT_TILE};
  63. //blocks should be initialized in this order, which may be confusing :/
  64. FuzzyHelper();
  65. void initTacticalAdvantage();
  66. void initVisitTile();
  67. void initWanderTarget();
  68. float evaluate(Goals::Explore & g);
  69. float evaluate(Goals::RecruitHero & g);
  70. float evaluate(Goals::VisitTile & g);
  71. float evaluate(Goals::VisitHero & g);
  72. float evaluate(Goals::BuildThis & g);
  73. float evaluate(Goals::DigAtTile & g);
  74. float evaluate(Goals::CollectRes & g);
  75. float evaluate(Goals::Build & g);
  76. float evaluate(Goals::BuyArmy & g);
  77. float evaluate(Goals::GatherArmy & g);
  78. float evaluate(Goals::ClearWayTo & g);
  79. float evaluate(Goals::Invalid & g);
  80. float evaluate(Goals::AbstractGoal & g);
  81. void setPriority(Goals::TSubgoal & g);
  82. ui64 estimateBankDanger(const CBank * bank);
  83. float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
  84. float getWanderTargetObjectValue(const CGHeroInstance & h, const ObjectIdRef & obj);
  85. Goals::TSubgoal chooseSolution(Goals::TGoalVec vec);
  86. //std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec);
  87. };