Nullkiller.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Nullkiller.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 "PriorityEvaluator.h"
  12. #include "FuzzyHelper.h"
  13. #include "AIMemory.h"
  14. #include "../Analyzers/DangerHitMapAnalyzer.h"
  15. #include "../Analyzers/BuildAnalyzer.h"
  16. #include "../Analyzers/ArmyManager.h"
  17. #include "../Analyzers/HeroManager.h"
  18. #include "../Analyzers/ObjectClusterizer.h"
  19. #include "../Goals/AbstractGoal.h"
  20. const float MAX_GOLD_PEASURE = 0.3f;
  21. const float MIN_PRIORITY = 0.01f;
  22. enum class HeroLockedReason
  23. {
  24. NOT_LOCKED = 0,
  25. STARTUP = 1,
  26. DEFENCE = 2,
  27. HERO_CHAIN = 3
  28. };
  29. class Nullkiller
  30. {
  31. private:
  32. const CGHeroInstance * activeHero;
  33. int3 targetTile;
  34. std::map<const CGHeroInstance *, HeroLockedReason> lockedHeroes;
  35. public:
  36. std::unique_ptr<DangerHitMapAnalyzer> dangerHitMap;
  37. std::unique_ptr<BuildAnalyzer> buildAnalyzer;
  38. std::unique_ptr<ObjectClusterizer> objectClusterizer;
  39. std::unique_ptr<PriorityEvaluator> priorityEvaluator;
  40. std::unique_ptr<AIPathfinder> pathfinder;
  41. std::unique_ptr<HeroManager> heroManager;
  42. std::unique_ptr<ArmyManager> armyManager;
  43. std::unique_ptr<AIMemory> memory;
  44. std::unique_ptr<FuzzyHelper> dangerEvaluator;
  45. PlayerColor playerID;
  46. std::shared_ptr<CCallback> cb;
  47. Nullkiller();
  48. void init(std::shared_ptr<CCallback> cb, PlayerColor playerID);
  49. void makeTurn();
  50. bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }
  51. bool isHeroLocked(const CGHeroInstance * hero) const;
  52. HeroPtr getActiveHero() { return activeHero; }
  53. HeroLockedReason getHeroLockedReason(const CGHeroInstance * hero) const;
  54. int3 getTargetTile() const { return targetTile; }
  55. void setActive(const CGHeroInstance * hero, int3 tile) { activeHero = hero; targetTile = tile; }
  56. void lockHero(const CGHeroInstance * hero, HeroLockedReason lockReason) { lockedHeroes[hero] = lockReason; }
  57. void unlockHero(const CGHeroInstance * hero) { lockedHeroes.erase(hero); }
  58. bool arePathHeroesLocked(const AIPath & path) const;
  59. private:
  60. void resetAiState();
  61. void updateAiState(int pass);
  62. Goals::TTask choseBestTask(Goals::TSubgoal behavior) const;
  63. Goals::TTask choseBestTask(Goals::TTaskVec & tasks) const;
  64. };