Merge pull request #6939 from Laserlicht/configurable_days

[1.7.4] Configurable days
This commit is contained in:
Ivan Savenko
2026-03-05 23:28:59 +02:00
committed by GitHub
19 changed files with 81 additions and 45 deletions
+1 -1
View File
@@ -344,7 +344,7 @@ std::vector<creInfo> ArmyManager::getArmyAvailableToBuy(
{
std::vector<creInfo> creaturesInDwellings;
int freeHeroSlots = GameConstants::ARMY_SIZE - hero->stacksCount();
bool countGrowth = (cpsic->getDate(Date::DAY_OF_WEEK) + turn) > 7;
bool countGrowth = (cpsic->getDate(Date::DAY_OF_WEEK) + turn) > LIBRARY->engineSettings()->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK);
const CGTownInstance * town = dwelling->ID == Obj::TOWN
? dynamic_cast<const CGTownInstance *>(dwelling)
+1 -1
View File
@@ -209,7 +209,7 @@ std::string BuildingInfo::toString() const
float BuildAnalyzer::calculateGoldPressure(TResource lockedGold, float armyCostGold, float economyDevelopmentCost, float freeGold, float dailyIncomeGold)
{
auto pressure = (lockedGold + armyCostGold + economyDevelopmentCost) / (1 + 2 * freeGold + dailyIncomeGold * 7.0f);
auto pressure = (lockedGold + armyCostGold + economyDevelopmentCost) / (1 + 2 * freeGold + dailyIncomeGold * static_cast<float>(LIBRARY->engineSettings()->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK)));
#if NK2AI_TRACE_LEVEL >= 1
logAi->trace("Gold pressure: %f", pressure);
+2 -1
View File
@@ -21,6 +21,7 @@
#include "../Goals/ExecuteHeroChain.h"
#include "../Goals/RecruitHero.h"
#include "../Markers/DefendTown.h"
#include "../../lib/IGameSettings.h"
namespace NK2AI
{
@@ -53,7 +54,7 @@ bool isThreatUnderControl(const CGTownInstance * town, const HitMapInfo & threat
for(const AIPath & path : paths)
{
bool threatIsWeak = path.getHeroStrength() / (float)threat.danger > THREAT_IGNORE_RATIO;
bool needToSaveGrowth = threat.turn == 0 && dayOfWeek == 7;
bool needToSaveGrowth = threat.turn == 0 && dayOfWeek == LIBRARY->engineSettings()->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK);
if(threatIsWeak && !needToSaveGrowth)
{
+3 -2
View File
@@ -1181,7 +1181,8 @@ public:
Goals::BuildThis & buildThis = dynamic_cast<Goals::BuildThis &>(*task);
auto & bi = buildThis.buildingInfo;
evaluationContext.goldReward += 7 * bi.dailyIncome.marketValue() / 2; // 7 day income but half we already have
constexpr int dailyIncomeValueFactor = 7;
evaluationContext.goldReward += dailyIncomeValueFactor * bi.dailyIncome.marketValue() / 2; // 7 day income but half we already have
evaluationContext.heroRole = HeroRole::MAIN;
evaluationContext.movementCostByRole[evaluationContext.heroRole] += bi.prerequisitesCount;
int32_t cost = bi.buildCost[EGameResID::GOLD];
@@ -1421,7 +1422,7 @@ float PriorityEvaluator::evaluate(Goals::TSubgoal task, int priorityTier)
? aiNk->settings->getMaxArmyLossTarget() * evaluationContext.powerRatio
: 1.0;
const float maxEnemyDangerRatio = evaluationContext.powerRatio > 0 ? evaluationContext.powerRatio : 1.0;
const bool arriveNextWeek = aiNk->cc->getDate(Date::DAY_OF_WEEK) + evaluationContext.turn > 7;
const bool arriveNextWeek = aiNk->cc->getDate(Date::DAY_OF_WEEK) + evaluationContext.turn > LIBRARY->engineSettings()->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK);
#if NK2AI_TRACE_LEVEL >= 2
logAi->trace(