diff --git a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp index b8d2929b9..3266e20c9 100644 --- a/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp +++ b/AI/Nullkiller/Analyzers/BuildAnalyzer.cpp @@ -106,10 +106,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(); @@ -119,7 +126,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(); @@ -340,6 +347,7 @@ void TownDevelopmentInfo::addExistingDwelling(const BuildingInfo & existingDwell void TownDevelopmentInfo::addBuildingToBuild(const BuildingInfo & nextToBuild) { townDevelopmentCost += nextToBuild.buildCostWithPrerequisites; + townDevelopmentCost += withoutGold(nextToBuild.armyCost); if(nextToBuild.canBuild) { diff --git a/config/ai/nkai/object-priorities.txt b/config/ai/nkai/object-priorities.txt index 44c8ef954..3d804f0ef 100644 --- a/config/ai/nkai/object-priorities.txt +++ b/config/ai/nkai/object-priorities.txt @@ -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 diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index c4e0264b3..05cc41ac3 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -523,6 +523,7 @@ CGameHandler::CGameHandler(CVCMIServer * lobby) , turnOrder(std::make_unique(this)) , queries(std::make_unique()) , playerMessages(std::make_unique(this)) + , randomNumberGenerator(std::make_unique()) , complainNoCreatures("No creatures to split") , complainNotEnoughCreatures("Cannot split that stack, not enough creatures!") , complainInvalidSlot("Invalid slot accessed!") @@ -552,7 +553,6 @@ void CGameHandler::reinitScripting() void CGameHandler::init(StartInfo *si, Load::ProgressAccumulator & progressTracking) { - randomNumberGenerator = std::make_unique(); int requestedSeed = settings["server"]["seed"].Integer(); if (requestedSeed != 0) randomNumberGenerator->setSeed(requestedSeed); diff --git a/server/CGameHandler.h b/server/CGameHandler.h index 60e7d8be0..ad90a0bbe 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -238,7 +238,7 @@ public: template void serialize(Handler &h) { h & QID; - h & randomNumberGenerator; + h & *randomNumberGenerator; h & *battles; h & *heroPool; h & *playerMessages;