mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Nullkiller: calibration and small behavior fixes
This commit is contained in:
parent
37f49f2ac5
commit
f832a8b3cd
@ -92,7 +92,9 @@ bool needToRecruitHero(const CGTownInstance * startupTown)
|
||||
}
|
||||
|
||||
auto basicCount = cb->getTownsInfo().size() + 2;
|
||||
auto boost = (int)std::floor(std::pow(treasureSourcesCount / 3.0, 2));
|
||||
auto boost = (int)std::floor(std::pow(treasureSourcesCount / 2.0, 2));
|
||||
|
||||
logAi->trace("Startup allows %d+%d heroes", basicCount, boost);
|
||||
|
||||
return cb->getHeroCount(ai->playerID, true) < basicCount + boost;
|
||||
}
|
||||
@ -106,21 +108,24 @@ Goals::TGoalVec StartupBehavior::decompose() const
|
||||
return tasks;
|
||||
|
||||
const CGTownInstance * startupTown = towns.front();
|
||||
bool canRecruitHero = needToRecruitHero(startupTown);
|
||||
|
||||
if(towns.size() > 1)
|
||||
{
|
||||
startupTown = *vstd::maxElementByFun(towns, [](const CGTownInstance * town) -> float
|
||||
{
|
||||
if(town->garrisonHero)
|
||||
return ai->ah->evaluateHero(town->garrisonHero.get());
|
||||
|
||||
auto closestHero = getNearestHero(town);
|
||||
|
||||
if(!closestHero)
|
||||
return 0;
|
||||
|
||||
if(closestHero)
|
||||
return ai->ah->evaluateHero(closestHero);
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
bool canRecruitHero = needToRecruitHero(startupTown);
|
||||
auto closestHero = getNearestHero(startupTown);
|
||||
|
||||
if(closestHero)
|
||||
@ -174,6 +179,19 @@ Goals::TGoalVec StartupBehavior::decompose() const
|
||||
tasks.push_back(Goals::sptr(Goals::RecruitHero(startupTown)));
|
||||
}
|
||||
|
||||
if(tasks.empty() && !startupTown->visitingHero)
|
||||
{
|
||||
for(auto town : towns)
|
||||
{
|
||||
if(!town->visitingHero && needToRecruitHero(town))
|
||||
{
|
||||
tasks.push_back(Goals::sptr(Goals::RecruitHero(town)));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tasks.empty() && towns.size())
|
||||
{
|
||||
for(const CGTownInstance * town : towns)
|
||||
|
@ -310,10 +310,10 @@ float getStrategicalValue(const CGObjectInstance * target)
|
||||
switch(target->ID)
|
||||
{
|
||||
case Obj::MINE:
|
||||
return target->subID == Res::GOLD ? 0.5f : 0.05f * getTotalResourceRequirementStrength(target->subID) + 0.05f * getResourceRequirementStrength(target->subID);
|
||||
return target->subID == Res::GOLD ? 0.5f : 0.02f * getTotalResourceRequirementStrength(target->subID) + 0.02f * getResourceRequirementStrength(target->subID);
|
||||
|
||||
case Obj::RESOURCE:
|
||||
return target->subID == Res::GOLD ? 0 : 0.3f * getResourceRequirementStrength(target->subID);
|
||||
return target->subID == Res::GOLD ? 0 : 0.1f * getResourceRequirementStrength(target->subID);
|
||||
|
||||
case Obj::TOWN:
|
||||
return dynamic_cast<const CGTownInstance *>(target)->hasFort()
|
||||
|
@ -42,14 +42,15 @@ namespace AIPathfinding
|
||||
}
|
||||
|
||||
CPathfinderHelper * AIPathfinderConfig::getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs)
|
||||
{
|
||||
if(!pathfindingHelper)
|
||||
{
|
||||
auto hero = aiNodeStorage->getHero(source.node);
|
||||
auto & helper = pathfindingHelpers[hero];
|
||||
|
||||
pathfindingHelper.reset(new CPathfinderHelper(gs, hero, options));
|
||||
if(!helper)
|
||||
{
|
||||
helper.reset(new CPathfinderHelper(gs, hero, options));
|
||||
}
|
||||
|
||||
return pathfindingHelper.get();
|
||||
return helper.get();
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace AIPathfinding
|
||||
class AIPathfinderConfig : public PathfinderConfig
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<CPathfinderHelper> pathfindingHelper;
|
||||
std::map<const CGHeroInstance *, std::unique_ptr<CPathfinderHelper>> pathfindingHelpers;
|
||||
std::shared_ptr<AINodeStorage> aiNodeStorage;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user