1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

NKAI: loosen gold presure on build system.

This commit is contained in:
Andrii Danylchenko 2023-07-29 18:54:20 +03:00
parent 6490c65490
commit fb7477047a
7 changed files with 18 additions and 11 deletions

View File

@ -166,7 +166,7 @@ void BuildAnalyzer::update()
}
else
{
goldPreasure = ai->getLockedResources()[EGameResID::GOLD] / 10000.0f
goldPreasure = ai->getLockedResources()[EGameResID::GOLD] / 5000.0f
+ (float)armyCost[EGameResID::GOLD] / (1 + ai->getFreeGold() + (float)dailyIncome[EGameResID::GOLD] * 7.0f);
}

View File

@ -236,7 +236,7 @@ const CGHeroInstance * HeroManager::findWeakHeroToDismiss(uint64_t armyLimit) co
for(auto existingHero : myHeroes)
{
if(ai->isHeroLocked(existingHero)
if(ai->isHeroLocked(existingHero) && ai->getHeroLockedReason(existingHero) == HeroLockedReason::DEFENCE
|| existingHero->getArmyStrength() >armyLimit
|| getHeroRole(existingHero) == HeroRole::MAIN
|| existingHero->movementPointsRemaining()

View File

@ -360,7 +360,7 @@ Goals::TGoalVec GatherArmyBehavior::upgradeArmy(const CGTownInstance * upgrader)
auto armyValue = (float)upgrade.upgradeValue / path.getHeroStrength();
if((armyValue < 0.1f && upgrade.upgradeValue < 20000) || upgrade.upgradeValue < 300) // avoid small upgrades
if((armyValue < 0.25f && upgrade.upgradeValue < 40000) || upgrade.upgradeValue < 2000) // avoid small upgrades
{
#if NKAI_TRACE_LEVEL >= 2
logAi->trace("Ignore path. Army value is too small (%f)", armyValue);

View File

@ -134,6 +134,9 @@ void Nullkiller::updateAiState(int pass, bool fast)
activeHero = nullptr;
setTargetObject(-1);
decomposer->reset();
buildAnalyzer->update();
if(!fast)
{
memory->removeInvisibleObjects(cb.get());
@ -179,8 +182,6 @@ void Nullkiller::updateAiState(int pass, bool fast)
}
armyManager->update();
buildAnalyzer->update();
decomposer->reset();
logAi->debug("AI state updated in %ld", timeElapsed(start));
}

View File

@ -23,7 +23,7 @@
namespace NKAI
{
const float MAX_GOLD_PEASURE = 0.3f;
const float MAX_GOLD_PEASURE = 0.6f;
const float MIN_PRIORITY = 0.01f;
const float SMALL_SCAN_MIN_PRIORITY = 0.4f;

View File

@ -420,10 +420,10 @@ float RewardEvaluator::getTotalResourceRequirementStrength(int resType) const
return 0;
float ratio = dailyIncome[resType] == 0
? (float)requiredResources[resType] / 50.0f
: (float)requiredResources[resType] / dailyIncome[resType] / 50.0f;
? (float)requiredResources[resType] / 10.0f
: (float)requiredResources[resType] / dailyIncome[resType] / 20.0f;
return std::min(ratio, 1.0f);
return std::min(ratio, 2.0f);
}
uint64_t RewardEvaluator::townArmyGrowth(const CGTownInstance * town) const
@ -954,7 +954,9 @@ public:
if(bi.notEnoughRes && bi.prerequisitesCount == 1)
{
evaluationContext.strategicalValue /= 2;
evaluationContext.strategicalValue /= 3;
evaluationContext.movementCostByRole[evaluationContext.heroRole] += 5;
evaluationContext.turn += 5;
}
}
};

View File

@ -879,8 +879,12 @@ void AINodeStorage::setHeroes(std::map<const CGHeroInstance *, HeroRole> heroes)
for(auto & hero : heroes)
{
// do not allow our own heroes in garrison to act on map
if(hero.first->getOwner() == ai->playerID && hero.first->inTownGarrison && ai->isHeroLocked(hero.first))
if(hero.first->getOwner() == ai->playerID
&& hero.first->inTownGarrison
&& (ai->isHeroLocked(hero.first) || ai->heroManager->heroCapReached()))
{
continue;
}
uint64_t mask = FirstActorMask << actors.size();
auto actor = std::make_shared<HeroActor>(hero.first, hero.second, mask, ai);