123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- /*
- * AIhelper.h, part of VCMI engine
- *
- * Authors: listed in file AUTHORS in main folder
- *
- * License: GNU General Public License v2.0 or later
- * Full text of license available in license.txt file, in main folder
- *
- */
- #include "StdInc.h"
- #include "AIhelper.h"
- AIhelper::AIhelper()
- {
- resourceManager.reset(new ResourceManager());
- buildingManager.reset(new BuildingManager());
- pathfindingManager.reset(new PathfindingManager());
- armyManager.reset(new ArmyManager());
- heroManager.reset(new HeroManager());
- }
- AIhelper::~AIhelper()
- {
- }
- bool AIhelper::notifyGoalCompleted(Goals::TSubgoal goal)
- {
- return resourceManager->notifyGoalCompleted(goal);
- }
- void AIhelper::init(CPlayerSpecificInfoCallback * CB)
- {
- resourceManager->init(CB);
- buildingManager->init(CB);
- pathfindingManager->init(CB);
- armyManager->init(CB);
- heroManager->init(CB);
- }
- void AIhelper::setAI(VCAI * AI)
- {
- resourceManager->setAI(AI);
- buildingManager->setAI(AI);
- pathfindingManager->setAI(AI);
- armyManager->setAI(AI);
- heroManager->setAI(AI);
- }
- void AIhelper::update()
- {
- armyManager->update();
- heroManager->update();
- }
- bool AIhelper::getBuildingOptions(const CGTownInstance * t)
- {
- return buildingManager->getBuildingOptions(t);
- }
- BuildingID AIhelper::getMaxPossibleGoldBuilding(const CGTownInstance * t)
- {
- return buildingManager->getMaxPossibleGoldBuilding(t);
- }
- boost::optional<PotentialBuilding> AIhelper::immediateBuilding() const
- {
- return buildingManager->immediateBuilding();
- }
- boost::optional<PotentialBuilding> AIhelper::expensiveBuilding() const
- {
- return buildingManager->expensiveBuilding();
- }
- boost::optional<BuildingID> AIhelper::canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays) const
- {
- return buildingManager->canBuildAnyStructure(t, buildList, maxDays);
- }
- Goals::TSubgoal AIhelper::whatToDo(TResources & res, Goals::TSubgoal goal)
- {
- return resourceManager->whatToDo(res, goal);
- }
- Goals::TSubgoal AIhelper::whatToDo() const
- {
- return resourceManager->whatToDo();
- }
- bool AIhelper::containsObjective(Goals::TSubgoal goal) const
- {
- return resourceManager->containsObjective(goal);
- }
- bool AIhelper::hasTasksLeft() const
- {
- return resourceManager->hasTasksLeft();
- }
- bool AIhelper::removeOutdatedObjectives(std::function<bool(const Goals::TSubgoal&)> predicate)
- {
- return resourceManager->removeOutdatedObjectives(predicate);
- }
- bool AIhelper::canAfford(const TResources & cost) const
- {
- return resourceManager->canAfford(cost);
- }
- TResources AIhelper::reservedResources() const
- {
- return resourceManager->reservedResources();
- }
- TResources AIhelper::freeResources() const
- {
- return resourceManager->freeResources();
- }
- TResource AIhelper::freeGold() const
- {
- return resourceManager->freeGold();
- }
- TResources AIhelper::allResources() const
- {
- return resourceManager->allResources();
- }
- TResource AIhelper::allGold() const
- {
- return resourceManager->allGold();
- }
- Goals::TGoalVec AIhelper::howToVisitTile(const int3 & tile, bool allowGatherArmy) const
- {
- return pathfindingManager->howToVisitTile(tile, allowGatherArmy);
- }
- Goals::TGoalVec AIhelper::howToVisitObj(ObjectIdRef obj, bool allowGatherArmy) const
- {
- return pathfindingManager->howToVisitObj(obj, allowGatherArmy);
- }
- Goals::TGoalVec AIhelper::howToVisitTile(const HeroPtr & hero, const int3 & tile, bool allowGatherArmy) const
- {
- return pathfindingManager->howToVisitTile(hero, tile, allowGatherArmy);
- }
- Goals::TGoalVec AIhelper::howToVisitObj(const HeroPtr & hero, ObjectIdRef obj, bool allowGatherArmy) const
- {
- return pathfindingManager->howToVisitObj(hero, obj, allowGatherArmy);
- }
- std::vector<AIPath> AIhelper::getPathsToTile(const HeroPtr & hero, const int3 & tile) const
- {
- return pathfindingManager->getPathsToTile(hero, tile);
- }
- std::vector<AIPath> AIhelper::getPathsToTile(const int3 & tile) const
- {
- return pathfindingManager->getPathsToTile(tile);
- }
- void AIhelper::updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain)
- {
- pathfindingManager->updatePaths(heroes, useHeroChain);
- }
- uint64_t AIhelper::evaluateStackPower(const CCreature * creature, int count) const
- {
- return armyManager->evaluateStackPower(creature, count);
- }
- SlotInfo AIhelper::getTotalCreaturesAvailable(CreatureID creatureID) const
- {
- return armyManager->getTotalCreaturesAvailable(creatureID);
- }
- bool AIhelper::canGetArmy(const CArmedInstance * army, const CArmedInstance * source) const
- {
- return armyManager->canGetArmy(army, source);
- }
- ui64 AIhelper::howManyReinforcementsCanBuy(const CCreatureSet * h, const CGDwelling * t) const
- {
- return armyManager->howManyReinforcementsCanBuy(h, t);
- }
- ui64 AIhelper::howManyReinforcementsCanGet(const CCreatureSet * target, const CCreatureSet * source) const
- {
- return armyManager->howManyReinforcementsCanGet(target, source);
- }
- std::vector<SlotInfo> AIhelper::getBestArmy(const CCreatureSet * target, const CCreatureSet * source) const
- {
- return armyManager->getBestArmy(target, source);
- }
- std::vector<SlotInfo>::iterator AIhelper::getWeakestCreature(std::vector<SlotInfo> & army) const
- {
- return armyManager->getWeakestCreature(army);
- }
- std::vector<SlotInfo> AIhelper::getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const
- {
- return armyManager->getSortedSlots(target, source);
- }
- std::vector<creInfo> AIhelper::getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling) const
- {
- return armyManager->getArmyAvailableToBuy(hero, dwelling);
- }
- ArmyUpgradeInfo AIhelper::calculateCreateresUpgrade(
- const CCreatureSet * army,
- const CGObjectInstance * upgrader,
- const TResources & availableResources) const
- {
- return armyManager->calculateCreateresUpgrade(army, upgrader, availableResources);
- }
- int AIhelper::selectBestSkill(const HeroPtr & hero, const std::vector<SecondarySkill> & skills) const
- {
- return heroManager->selectBestSkill(hero, skills);
- }
- const std::map<HeroPtr, HeroRole> & AIhelper::getHeroRoles() const
- {
- return heroManager->getHeroRoles();
- }
- HeroRole AIhelper::getHeroRole(const HeroPtr & hero) const
- {
- return heroManager->getHeroRole(hero);
- }
- float AIhelper::evaluateSecSkill(SecondarySkill skill, const CGHeroInstance * hero) const
- {
- return heroManager->evaluateSecSkill(skill, hero);
- }
- float AIhelper::evaluateHero(const CGHeroInstance * hero) const
- {
- return heroManager->evaluateHero(hero);
- }
|