diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index d0d2d998a..861ee237a 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -36,8 +36,6 @@ namespace NKAI // our to enemy strength ratio constants const float SAFE_ATTACK_CONSTANT = 1.1f; -const float RETREAT_THRESHOLD = 0.3f; -const double RETREAT_ABSOLUTE_THRESHOLD = 10000.; //one thread may be turn of AI and another will be handling a side effect for AI2 thread_local CCallback * cb = nullptr; @@ -553,7 +551,7 @@ std::optional AIGateway::makeSurrenderRetreatDecision(const Battle double fightRatio = ourStrength / (double)battleState.getEnemyStrength(); // if we have no towns - things are already bad, so retreat is not an option. - if(cb->getTownsInfo().size() && ourStrength < RETREAT_ABSOLUTE_THRESHOLD && fightRatio < RETREAT_THRESHOLD && battleState.canFlee) + if(cb->getTownsInfo().size() && ourStrength < nullkiller->settings->getRetreatThresholdAbsoolute() && fightRatio < nullkiller->settings->getRetreatThresholdRelative() && battleState.canFlee) { return BattleAction::makeRetreat(battleState.ourSide); } diff --git a/AI/Nullkiller/Engine/Settings.cpp b/AI/Nullkiller/Engine/Settings.cpp index 7271a361f..eaf44d1b7 100644 --- a/AI/Nullkiller/Engine/Settings.cpp +++ b/AI/Nullkiller/Engine/Settings.cpp @@ -28,7 +28,9 @@ namespace NKAI : maxRoamingHeroes(8), mainHeroTurnDistanceLimit(10), scoutHeroTurnDistanceLimit(5), - maxGoldPressure(0.3f), + maxGoldPressure(0.3f), + retreatThresholdRelative(0.3), + retreatThresholdAbsoolute(10000), maxpass(10), pathfinderBucketsCount(1), pathfinderBucketSize(32), @@ -48,6 +50,8 @@ namespace NKAI pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer(); pathfinderBucketSize = node["pathfinderBucketSize"].Integer(); maxGoldPressure = node["maxGoldPressure"].Float(); + retreatThresholdRelative = node["retreatThresholdRelative"].Float(); + retreatThresholdAbsoolute = node["retreatThresholdAbsoolute"].Float(); allowObjectGraph = node["allowObjectGraph"].Bool(); openMap = node["openMap"].Bool(); useFuzzy = node["useFuzzy"].Bool(); diff --git a/AI/Nullkiller/Engine/Settings.h b/AI/Nullkiller/Engine/Settings.h index 2dad59c69..dfecb6530 100644 --- a/AI/Nullkiller/Engine/Settings.h +++ b/AI/Nullkiller/Engine/Settings.h @@ -28,6 +28,8 @@ namespace NKAI int pathfinderBucketsCount; int pathfinderBucketSize; float maxGoldPressure; + float retreatThresholdRelative; + float retreatThresholdAbsoolute; bool allowObjectGraph; bool useTroopsFromGarrisons; bool openMap; @@ -38,6 +40,8 @@ namespace NKAI int getMaxPass() const { return maxpass; } float getMaxGoldPressure() const { return maxGoldPressure; } + float getRetreatThresholdRelative() const { return retreatThresholdRelative; } + float getRetreatThresholdAbsoolute() const { return retreatThresholdAbsoolute; } int getMaxRoamingHeroes() const { return maxRoamingHeroes; } int getMainHeroTurnDistanceLimit() const { return mainHeroTurnDistanceLimit; } int getScoutHeroTurnDistanceLimit() const { return scoutHeroTurnDistanceLimit; } diff --git a/config/ai/nkai/nkai-settings.json b/config/ai/nkai/nkai-settings.json index 345e1a007..6ef63c453 100644 --- a/config/ai/nkai/nkai-settings.json +++ b/config/ai/nkai/nkai-settings.json @@ -10,6 +10,8 @@ "allowObjectGraph": false, "pathfinderBucketsCount" : 1, // old value: 3, "pathfinderBucketSize" : 32, // old value: 7, + "retreatThresholdRelative" : 0.3, + "retreatThresholdAbsoolute" : 10000, "useFuzzy" : false }, @@ -24,6 +26,8 @@ "allowObjectGraph": false, "pathfinderBucketsCount" : 1, // old value: 3, "pathfinderBucketSize" : 32, // old value: 7, + "retreatThresholdRelative" : 0.3, + "retreatThresholdAbsoolute" : 10000, "useFuzzy" : false }, @@ -38,6 +42,8 @@ "allowObjectGraph": false, "pathfinderBucketsCount" : 1, // old value: 3, "pathfinderBucketSize" : 32, // old value: 7, + "retreatThresholdRelative" : 0.3, + "retreatThresholdAbsoolute" : 10000, "useFuzzy" : false }, @@ -52,6 +58,8 @@ "allowObjectGraph": false, "pathfinderBucketsCount" : 1, // old value: 3, "pathfinderBucketSize" : 32, // old value: 7, + "retreatThresholdRelative" : 0.3, + "retreatThresholdAbsoolute" : 10000, "useFuzzy" : false }, @@ -66,6 +74,8 @@ "allowObjectGraph": false, "pathfinderBucketsCount" : 1, // old value: 3, "pathfinderBucketSize" : 32, // old value: 7, + "retreatThresholdRelative" : 0.3, + "retreatThresholdAbsoolute" : 10000, "useFuzzy" : false } } \ No newline at end of file