mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Nullkiller AI: further stabilisation, implement staged hero chain (first with limit 0 turns then 1 turn)
This commit is contained in:
committed by
Andrii Danylchenko
parent
6bebb766a6
commit
eea5cb7f0b
@@ -79,13 +79,26 @@ void Nullkiller::updateAiState()
|
||||
auto activeHeroes = ai->getMyHeroes();
|
||||
|
||||
vstd::erase_if(activeHeroes, [this](const HeroPtr & hero) -> bool{
|
||||
return isHeroLocked(hero.h);
|
||||
auto lockedReason = getHeroLockedReason(hero.h);
|
||||
|
||||
return lockedReason == HeroLockedReason::DEFENCE || lockedReason == HeroLockedReason::STARTUP;
|
||||
});
|
||||
|
||||
ai->ah->updatePaths(activeHeroes, true);
|
||||
ai->ah->updateHeroRoles();
|
||||
}
|
||||
|
||||
bool Nullkiller::arePathHeroesLocked(const AIPath & path) const
|
||||
{
|
||||
for(auto & node : path.nodes)
|
||||
{
|
||||
if(isHeroLocked(node.targetHero))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Nullkiller::makeTurn()
|
||||
{
|
||||
resetAiState();
|
||||
@@ -97,17 +110,14 @@ void Nullkiller::makeTurn()
|
||||
Goals::TGoalVec bestTasks = {
|
||||
choseBestTask(std::make_shared<BuyArmyBehavior>()),
|
||||
choseBestTask(std::make_shared<CaptureObjectsBehavior>()),
|
||||
choseBestTask(std::make_shared<RecruitHeroBehavior>())
|
||||
choseBestTask(std::make_shared<RecruitHeroBehavior>()),
|
||||
choseBestTask(std::make_shared<DefenceBehavior>())
|
||||
};
|
||||
|
||||
if(cb->getDate(Date::DAY) == 1)
|
||||
{
|
||||
bestTasks.push_back(choseBestTask(std::make_shared<StartupBehavior>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
bestTasks.push_back(choseBestTask(std::make_shared<DefenceBehavior>()));
|
||||
}
|
||||
|
||||
Goals::TSubgoal bestTask = choseBestTask(bestTasks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user