1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

NKAI: take into account 7lvl creature cost when we consider what resources we need

This commit is contained in:
Andrii Danylchenko 2024-07-18 20:20:40 +03:00
parent e227fa1691
commit e9e5948d61
2 changed files with 13 additions and 5 deletions

View File

@ -100,10 +100,17 @@ int32_t convertToGold(const TResources & res)
+ 125 * (res[EGameResID::GEMS] + res[EGameResID::CRYSTAL] + res[EGameResID::MERCURY] + res[EGameResID::SULFUR]);
}
TResources withoutGold(TResources other)
{
other[GameResID::GOLD] = 0;
return other;
}
TResources BuildAnalyzer::getResourcesRequiredNow() const
{
auto resourcesAvailable = ai->getFreeResources();
auto result = requiredResources - resourcesAvailable;
auto result = withoutGold(armyCost) + requiredResources - resourcesAvailable;
result.positive();
@ -113,7 +120,7 @@ TResources BuildAnalyzer::getResourcesRequiredNow() const
TResources BuildAnalyzer::getTotalResourcesRequired() const
{
auto resourcesAvailable = ai->getFreeResources();
auto result = totalDevelopmentCost - resourcesAvailable;
auto result = totalDevelopmentCost + withoutGold(armyCost) - resourcesAvailable;
result.positive();
@ -341,6 +348,7 @@ void TownDevelopmentInfo::addExistingDwelling(const BuildingInfo & existingDwell
void TownDevelopmentInfo::addBuildingToBuild(const BuildingInfo & nextToBuild)
{
townDevelopmentCost += nextToBuild.buildCostWithPrerequisites;
townDevelopmentCost += withoutGold(nextToBuild.armyCost);
if(nextToBuild.canBuild)
{

View File

@ -15,9 +15,9 @@ InputVariable: scoutTurnDistance
range: 0.000 10.000
lock-range: true
term: LOWEST Ramp 0.250 0.000
term: LOW Discrete 0.000 1.000 0.500 0.800 1.000 0.000
term: MEDIUM Discrete 0.000 0.000 0.500 0.200 1.000 1.000 2.500 0.300 4.000 0.000
term: LONG Discrete 1.000 0.000 1.500 0.200 3.000 0.800 10.000 1.000
term: LOW Discrete 0.000 1.000 1.000 0.800 2.500 0.000
term: MEDIUM Discrete 0.000 0.000 1.000 0.200 2.500 1.000 3.500 0.300 5.000 0.000
term: LONG Discrete 2.500 0.000 3.500 0.200 5.000 0.800 10.000 1.000
InputVariable: goldReward
description: estimated amount of gold received
enabled: true