mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-18 03:21:27 +02:00
Moved retreat decision-making constants to config
This commit is contained in:
parent
71d9664295
commit
00492a60a7
@ -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<BattleAction> 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);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ namespace NKAI
|
||||
mainHeroTurnDistanceLimit(10),
|
||||
scoutHeroTurnDistanceLimit(5),
|
||||
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();
|
||||
|
@ -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; }
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user