mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Allow per-difficulty parameters for NKAI
This commit is contained in:
@@ -34,13 +34,12 @@ using namespace Goals;
|
|||||||
std::unique_ptr<ObjectGraph> Nullkiller::baseGraph;
|
std::unique_ptr<ObjectGraph> Nullkiller::baseGraph;
|
||||||
|
|
||||||
Nullkiller::Nullkiller()
|
Nullkiller::Nullkiller()
|
||||||
:activeHero(nullptr), scanDepth(ScanDepth::MAIN_FULL), useHeroChain(true)
|
: activeHero(nullptr)
|
||||||
|
, scanDepth(ScanDepth::MAIN_FULL)
|
||||||
|
, useHeroChain(true)
|
||||||
|
, memory(std::make_unique<AIMemory>())
|
||||||
{
|
{
|
||||||
memory = std::make_unique<AIMemory>();
|
|
||||||
settings = std::make_unique<Settings>();
|
|
||||||
|
|
||||||
useObjectGraph = settings->isObjectGraphAllowed();
|
|
||||||
openMap = settings->isOpenMap() || useObjectGraph;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
|
bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
|
||||||
@@ -62,17 +61,23 @@ bool canUseOpenMap(std::shared_ptr<CCallback> cb, PlayerColor playerID)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb->getStartInfo()->difficulty >= 3;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nullkiller::init(std::shared_ptr<CCallback> cb, AIGateway * gateway)
|
void Nullkiller::init(std::shared_ptr<CCallback> cb, AIGateway * gateway)
|
||||||
{
|
{
|
||||||
this->cb = cb;
|
this->cb = cb;
|
||||||
this->gateway = gateway;
|
this->gateway = gateway;
|
||||||
|
this->playerID = gateway->playerID;
|
||||||
playerID = gateway->playerID;
|
|
||||||
|
|
||||||
if(openMap && !canUseOpenMap(cb, playerID))
|
settings = std::make_unique<Settings>(cb->getStartInfo()->difficulty);
|
||||||
|
|
||||||
|
if(canUseOpenMap(cb, playerID))
|
||||||
|
{
|
||||||
|
useObjectGraph = settings->isObjectGraphAllowed();
|
||||||
|
openMap = settings->isOpenMap() || useObjectGraph;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
useObjectGraph = false;
|
useObjectGraph = false;
|
||||||
openMap = false;
|
openMap = false;
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#include "../../../lib/constants/StringConstants.h"
|
||||||
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
||||||
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
||||||
#include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
|
#include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
|
||||||
@@ -22,7 +24,7 @@
|
|||||||
|
|
||||||
namespace NKAI
|
namespace NKAI
|
||||||
{
|
{
|
||||||
Settings::Settings()
|
Settings::Settings(int difficultyLevel)
|
||||||
: maxRoamingHeroes(8),
|
: maxRoamingHeroes(8),
|
||||||
mainHeroTurnDistanceLimit(10),
|
mainHeroTurnDistanceLimit(10),
|
||||||
scoutHeroTurnDistanceLimit(5),
|
scoutHeroTurnDistanceLimit(5),
|
||||||
@@ -35,7 +37,9 @@ namespace NKAI
|
|||||||
openMap(true),
|
openMap(true),
|
||||||
useFuzzy(false)
|
useFuzzy(false)
|
||||||
{
|
{
|
||||||
JsonNode node = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
|
const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
|
||||||
|
const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
|
||||||
|
const JsonNode & node = rootNode[difficultyName];
|
||||||
|
|
||||||
maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
|
maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
|
||||||
mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
|
mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace NKAI
|
|||||||
bool useFuzzy;
|
bool useFuzzy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Settings();
|
explicit Settings(int difficultyLevel);
|
||||||
|
|
||||||
int getMaxPass() const { return maxpass; }
|
int getMaxPass() const { return maxpass; }
|
||||||
float getMaxGoldPressure() const { return maxGoldPressure; }
|
float getMaxGoldPressure() const { return maxGoldPressure; }
|
||||||
|
|||||||
@@ -1,13 +1,71 @@
|
|||||||
{
|
{
|
||||||
"maxRoamingHeroes" : 8,
|
"pawn" : {
|
||||||
"maxpass" : 30,
|
"maxRoamingHeroes" : 8,
|
||||||
"mainHeroTurnDistanceLimit" : 10,
|
"maxpass" : 30,
|
||||||
"scoutHeroTurnDistanceLimit" : 5,
|
"mainHeroTurnDistanceLimit" : 10,
|
||||||
"maxGoldPressure" : 0.3,
|
"scoutHeroTurnDistanceLimit" : 5,
|
||||||
"useTroopsFromGarrisons" : true,
|
"maxGoldPressure" : 0.3,
|
||||||
"openMap": true,
|
"useTroopsFromGarrisons" : true,
|
||||||
"allowObjectGraph": false,
|
"openMap": false,
|
||||||
"pathfinderBucketsCount" : 1, // old value: 3,
|
"allowObjectGraph": false,
|
||||||
"pathfinderBucketSize" : 32, // old value: 7,
|
"pathfinderBucketsCount" : 1, // old value: 3,
|
||||||
"useFuzzy" : false
|
"pathfinderBucketSize" : 32, // old value: 7,
|
||||||
|
"useFuzzy" : false
|
||||||
|
},
|
||||||
|
|
||||||
|
"knight" : {
|
||||||
|
"maxRoamingHeroes" : 8,
|
||||||
|
"maxpass" : 30,
|
||||||
|
"mainHeroTurnDistanceLimit" : 10,
|
||||||
|
"scoutHeroTurnDistanceLimit" : 5,
|
||||||
|
"maxGoldPressure" : 0.3,
|
||||||
|
"useTroopsFromGarrisons" : true,
|
||||||
|
"openMap": false,
|
||||||
|
"allowObjectGraph": false,
|
||||||
|
"pathfinderBucketsCount" : 1, // old value: 3,
|
||||||
|
"pathfinderBucketSize" : 32, // old value: 7,
|
||||||
|
"useFuzzy" : false
|
||||||
|
},
|
||||||
|
|
||||||
|
"rook" : {
|
||||||
|
"maxRoamingHeroes" : 8,
|
||||||
|
"maxpass" : 30,
|
||||||
|
"mainHeroTurnDistanceLimit" : 10,
|
||||||
|
"scoutHeroTurnDistanceLimit" : 5,
|
||||||
|
"maxGoldPressure" : 0.3,
|
||||||
|
"useTroopsFromGarrisons" : true,
|
||||||
|
"openMap": false,
|
||||||
|
"allowObjectGraph": false,
|
||||||
|
"pathfinderBucketsCount" : 1, // old value: 3,
|
||||||
|
"pathfinderBucketSize" : 32, // old value: 7,
|
||||||
|
"useFuzzy" : false
|
||||||
|
},
|
||||||
|
|
||||||
|
"queen" : {
|
||||||
|
"maxRoamingHeroes" : 8,
|
||||||
|
"maxpass" : 30,
|
||||||
|
"mainHeroTurnDistanceLimit" : 10,
|
||||||
|
"scoutHeroTurnDistanceLimit" : 5,
|
||||||
|
"maxGoldPressure" : 0.3,
|
||||||
|
"useTroopsFromGarrisons" : true,
|
||||||
|
"openMap": true,
|
||||||
|
"allowObjectGraph": false,
|
||||||
|
"pathfinderBucketsCount" : 1, // old value: 3,
|
||||||
|
"pathfinderBucketSize" : 32, // old value: 7,
|
||||||
|
"useFuzzy" : false
|
||||||
|
},
|
||||||
|
|
||||||
|
"king" : {
|
||||||
|
"maxRoamingHeroes" : 8,
|
||||||
|
"maxpass" : 30,
|
||||||
|
"mainHeroTurnDistanceLimit" : 10,
|
||||||
|
"scoutHeroTurnDistanceLimit" : 5,
|
||||||
|
"maxGoldPressure" : 0.3,
|
||||||
|
"useTroopsFromGarrisons" : true,
|
||||||
|
"openMap": true,
|
||||||
|
"allowObjectGraph": false,
|
||||||
|
"pathfinderBucketsCount" : 1, // old value: 3,
|
||||||
|
"pathfinderBucketSize" : 32, // old value: 7,
|
||||||
|
"useFuzzy" : false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user