Settings.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Settings.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include <limits>
  12. #include "Settings.h"
  13. #include "../../../lib/constants/StringConstants.h"
  14. #include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
  15. #include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
  16. #include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
  17. #include "../../../lib/mapObjects/MapObjects.h"
  18. #include "../../../lib/modding/CModHandler.h"
  19. #include "../../../lib/VCMI_Lib.h"
  20. #include "../../../lib/filesystem/Filesystem.h"
  21. #include "../../../lib/json/JsonUtils.h"
  22. namespace NKAI
  23. {
  24. Settings::Settings(int difficultyLevel)
  25. : maxRoamingHeroes(8),
  26. mainHeroTurnDistanceLimit(10),
  27. scoutHeroTurnDistanceLimit(5),
  28. maxGoldPressure(0.3f),
  29. retreatThresholdRelative(0.3),
  30. retreatThresholdAbsolute(10000),
  31. safeAttackRatio(1.1),
  32. maxpass(10),
  33. pathfinderBucketsCount(1),
  34. pathfinderBucketSize(32),
  35. allowObjectGraph(true),
  36. useTroopsFromGarrisons(false),
  37. openMap(true),
  38. useFuzzy(false)
  39. {
  40. const std::string & difficultyName = GameConstants::DIFFICULTY_NAMES[difficultyLevel];
  41. const JsonNode & rootNode = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
  42. const JsonNode & node = rootNode[difficultyName];
  43. maxRoamingHeroes = node["maxRoamingHeroes"].Integer();
  44. mainHeroTurnDistanceLimit = node["mainHeroTurnDistanceLimit"].Integer();
  45. scoutHeroTurnDistanceLimit = node["scoutHeroTurnDistanceLimit"].Integer();
  46. maxpass = node["maxpass"].Integer();
  47. pathfinderBucketsCount = node["pathfinderBucketsCount"].Integer();
  48. pathfinderBucketSize = node["pathfinderBucketSize"].Integer();
  49. maxGoldPressure = node["maxGoldPressure"].Float();
  50. retreatThresholdRelative = node["retreatThresholdRelative"].Float();
  51. retreatThresholdAbsolute = node["retreatThresholdAbsolute"].Float();
  52. safeAttackRatio = node["safeAttackRatio"].Float();
  53. allowObjectGraph = node["allowObjectGraph"].Bool();
  54. openMap = node["openMap"].Bool();
  55. useFuzzy = node["useFuzzy"].Bool();
  56. useTroopsFromGarrisons = node["useTroopsFromGarrisons"].Bool();
  57. }
  58. }