Compare commits

...
Author SHA1 Message Date
admin 78937263a8 Remove broken random battle runner 2026-06-21 08:27:03 -07:00
adminandGitHub 2e63bcb5c3 Write flatbuffer allocator diagnostics to stderr (#7484) 2026-06-21 08:23:55 -07:00
adminandGitHub e231f0c34e Use streams for Shardok controller diagnostics (#7483) 2026-06-21 08:23:35 -07:00
adminandGitHub 8155fe7b3f Remove Postgres shardok row early returns (#7482) 2026-06-21 08:23:17 -07:00
adminandGitHub 6fe1bcdff2 Use streams for map info diagnostics (#7481) 2026-06-21 08:23:00 -07:00
adminandGitHub b6b488bd46 Remove changed faction writer early returns (#7480) 2026-06-21 08:15:09 -07:00
adminandGitHub d97cc0cadc Use streams for Shardok server diagnostics (#7479) 2026-06-21 08:13:19 -07:00
adminandGitHub 2a3c742be9 Remove SQLite to Postgres migration admin flow (#7478) 2026-06-21 08:11:06 -07:00
adminandGitHub cdee86dbcb Remove S3 startup save sync (#7475) 2026-06-21 08:10:47 -07:00
adminandGitHub 60264e2bfc Make Shardok numeric casts explicit (#7477) 2026-06-21 08:09:58 -07:00
adminandGitHub 19fb315500 Make remaining unit byte casts explicit (#7476) 2026-06-21 08:09:34 -07:00
adminandGitHub 66710659c9 Tighten Shardok ownership cleanup (#7472) 2026-06-21 07:57:14 -07:00
adminandGitHub de5a34c485 Make game state dumper casts explicit (#7474) 2026-06-21 07:54:29 -07:00
adminandGitHub e0c7ba3874 Make Shardok casts explicit (#7473) 2026-06-21 07:54:04 -07:00
adminandGitHub 9e58fbee56 Remove S3 sync early returns (#7471) 2026-06-21 05:59:23 -07:00
adminandGitHub 5315941f88 Remove sqlite postgres migration return (#7470) 2026-06-21 05:59:01 -07:00
adminandGitHub 3ffeb0250b Remove battle progress early return (#7469) 2026-06-21 05:58:39 -07:00
adminandGitHub 451e6bb406 Avoid unnecessary endl flushes (#7465) 2026-06-21 05:58:06 -07:00
adminandGitHub 58d680bd59 Remove tutorial hero factions early return (#7464) 2026-06-20 21:47:23 -07:00
adminandGitHub 79eb708adb Normalize Shardok header guards (#7463) 2026-06-20 21:44:58 -07:00
adminandGitHub 1282e62781 Remove AsyncS3Persister early returns (#7466) 2026-06-20 21:44:29 -07:00
adminandGitHub 4af501feee Make gtest helper casts explicit (#7467) 2026-06-20 21:44:07 -07:00
adminandGitHub ef7c24f6de Make game over response casts explicit (#7468) 2026-06-20 21:43:29 -07:00
adminandGitHub 62edd02a22 Remove attack decision early returns (#7462) 2026-06-20 21:43:10 -07:00
adminandGitHub 6f22edc8f3 Remove GameMigrator early returns (#7461) 2026-06-20 18:43:08 -07:00
adminandGitHub 27bba1c2da Replace GNU alignment attributes with alignas (#7460) 2026-06-20 17:59:59 -07:00
adminandGitHub c95bc22f0e Remove simple Unit early returns (#7459) 2026-06-20 17:45:04 -07:00
adminandGitHub 844bab253d Rename test settings helper global (#7458) 2026-06-20 17:42:44 -07:00
adminandGitHub b8372487cf Remove backstory recovery early return (#7457) 2026-06-20 17:40:46 -07:00
adminandGitHub 8cc38466e6 Replace AI client flee debug macro (#7456) 2026-06-20 17:40:25 -07:00
adminandGitHub 14935b1a52 Remove march availability early returns (#7455) 2026-06-20 17:37:29 -07:00
adminandGitHub f7b14cd9ba Replace coords set index check macro (#7454) 2026-06-20 17:36:03 -07:00
adminandGitHub 9d1e61ef8d Remove defend availability early return (#7453) 2026-06-20 17:33:01 -07:00
adminandGitHub 8c912c1b3e Replace SuppressBeastsCommand type test (#7450) 2026-06-20 17:32:41 -07:00
adminandGitHub 1ff6ae0195 Replace test type predicates (#7452) 2026-06-20 17:32:12 -07:00
adminandGitHub 641bf456fa Replace iterative deepening debug macro (#7451) 2026-06-20 17:28:10 -07:00
adminandGitHub f21eaabb15 Modernize disabled C++ logging toggles (#7449) 2026-06-20 17:25:13 -07:00
adminandGitHub 7d38336e67 Remove EngineImpl applyActionResults return (#7448) 2026-06-20 17:23:56 -07:00
adminandGitHub f37ec78d10 Remove auth early returns (#7447) 2026-06-20 17:23:02 -07:00
adminandGitHub eb0f92dcd0 Remove simple utility early returns (#7446) 2026-06-20 17:21:20 -07:00
adminandGitHub ee06235cf4 Remove quest chooser early returns (#7445) 2026-06-20 17:20:53 -07:00
adminandGitHub 48dfe9054d Replace simple isInstanceOf predicates (#7443) 2026-06-20 17:20:33 -07:00
adminandGitHub c7e39e67aa Remove simple availability early returns (#7444) 2026-06-20 17:20:07 -07:00
adminandGitHub 86e51a11b7 Replace AI evaluator control macros with constexpr (#7442) 2026-06-20 16:35:44 -07:00
adminandGitHub 3c0e98280d Rename reserved test settings include guard (#7441) 2026-06-20 16:35:15 -07:00
adminandGitHub c54c9f7955 Remove Gemini parser early returns (#7440) 2026-06-20 16:34:50 -07:00
adminandGitHub 614c404bf4 Replace test roll macros with constexpr constants (#7439) 2026-06-20 16:15:09 -07:00
adminandGitHub c1ebcd49fc Replace combat macros with constexpr constants (#7437) 2026-06-20 16:11:00 -07:00
adminandGitHub 49551614fe Default simple C++ special members (#7436) 2026-06-20 16:10:21 -07:00
adminandGitHub b2b8603f23 Generalize FunctionalRandom sequence helpers (#7438) 2026-06-20 16:09:41 -07:00
adminandGitHub 4a6ecda8f8 Remove SettingsLoader asInstanceOf generation (#7432) 2026-06-20 15:58:17 -07:00
adminandGitHub b65d3c25e1 Remove observer asInstanceOf cast (#7427) 2026-06-20 15:56:58 -07:00
adminandGitHub 65f5ec1c38 Remove domain asInstanceOf casts (#7426) 2026-06-20 15:56:43 -07:00
adminandGitHub b8b225eb84 Rename reserved AI evaluator identifiers (#7433) 2026-06-20 14:47:37 -07:00
adminandGitHub c20239b9e8 Normalize static const declarations (#7434) 2026-06-20 14:47:12 -07:00
adminandGitHub a8df7228b3 Mark single-argument constructors explicit (#7431) 2026-06-20 14:46:47 -07:00
adminandGitHub b8ebc0efd8 Remove remaining inline body semicolons (#7428) 2026-06-20 14:46:21 -07:00
adminandGitHub 5ee86faf80 Remove redundant command constructor semicolons (#7425) 2026-06-20 14:44:41 -07:00
adminandGitHub 3d6524b2fa Remove key asInstanceOf casts (#7423) 2026-06-20 14:21:03 -07:00
adminandGitHub 82b671b234 Remove redundant factory constructor semicolons (#7422) 2026-06-20 14:20:16 -07:00
adminandGitHub 3ad6de784f Remove JSON asInstanceOf casts (#7421) 2026-06-20 14:19:46 -07:00
253 changed files with 1878 additions and 2437 deletions
@@ -69,25 +69,6 @@ cc_binary(
],
)
cc_binary(
name = "random_battle_runner",
srcs = ["RandomBattleRunner.cpp"],
copts = COPTS,
data = [
"//src/main/resources/net/eagle0/shardok:battalion_types",
"//src/main/resources/net/eagle0/shardok:settings",
"//src/main/resources/net/eagle0/shardok/maps",
],
deps = [
"//src/main/cpp/net/eagle0/common:byte_vector",
"//src/main/cpp/net/eagle0/common:filesystem_utils",
"//src/main/cpp/net/eagle0/common:unit_conversions",
"//src/main/cpp/net/eagle0/shardok/library:shardok_c_types",
"//src/main/cpp/net/eagle0/shardok/server:games_manager",
"//src/main/protobuf/net/eagle0/common:random_units_cc_proto",
],
)
cc_library(
name = "map_info_calculator",
srcs = ["MapInfoCalculator.cpp"],
@@ -22,7 +22,7 @@ int main(const int argc, char** argv) {
const std::string outputPath = argv[2];
const byte_vector mapProtoBytes = byte_vector::FromPath(inputPath);
net::eagle0::shardok::common::HexMap mapProto;
mapProto.ParseFromArray(mapProtoBytes.data(), (int)mapProtoBytes.size());
mapProto.ParseFromArray(mapProtoBytes.data(), static_cast<int>(mapProtoBytes.size()));
ModifyMap(mapProto);
const std::string outputString = mapProto.SerializeAsString();
@@ -36,7 +36,7 @@ void ModifyMap(HexMapProto& map) {
for (int i = 0; i < map.terrain_size(); i++) {
const auto existingTerrainType = map.terrain(i).type();
const auto newTerrain =
(net::eagle0::shardok::common::Terrain_Type)(existingTerrainType + 2);
static_cast<net::eagle0::shardok::common::Terrain_Type>(existingTerrainType + 2);
map.mutable_terrain(i)->set_type(newTerrain);
}
}
@@ -4,13 +4,15 @@
#include "MapInfoCalculator.hpp"
#include <cstdlib>
#include <iostream>
#include "src/main/cpp/net/eagle0/shardok/ai/AIWaterCrossingCalculator.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/fb_helpers/HexMapHelpers.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/util/HexMapUtils.hpp"
#include "src/main/cpp/net/eagle0/shardok/util/MapLoader.hpp"
using namespace shardok;
using std::endl;
auto LoadMapFb(const string& mapName) -> Wrapper<HexMap> {
const HexMapProto mapProto = LoadMap(mapName);
@@ -40,7 +42,7 @@ auto CalculateMap(
const auto* positionList = hexMap->attacker_starting_positions()->Get(i);
if (positionList->positions()->size() < 1) continue;
if (positionList->positions()->size() != 10) {
printf("Should have 10 starting positions!");
std::cerr << "Should have 10 starting positions!" << '\n';
abort();
}
@@ -63,4 +65,4 @@ auto CalculateMap(
}
return info;
}
}
@@ -16,11 +16,11 @@ using namespace shardok;
using std::map;
using std::string;
struct OneMapInfo {
struct alignas(64) OneMapInfo {
uint32_t castleCount;
string name;
map<int, int> positionsRequiringCrossing;
} __attribute__((aligned(64)));
};
auto CalculateMap(
const string& mapName,
@@ -2,6 +2,7 @@
// Created by Dan Crosby on 4/18/22.
//
#include <fstream>
#include <iostream>
#include <memory>
@@ -11,15 +12,16 @@
#include "src/main/cpp/net/eagle0/shardok/util/MapLoader.hpp"
using namespace shardok;
using std::endl;
auto main(const int argc, char** argv) -> int {
FilesystemUtils::SetExecPath(argv[0]);
std::ostream* outputStreamPtr = &std::cout;
std::ofstream outputFile{};
if (argc > 1) {
const string outputPath = argv[1];
outputStreamPtr = new std::ofstream(outputPath);
outputFile.open(outputPath);
outputStreamPtr = &outputFile;
}
std::ostream& outputStream = *outputStreamPtr;
@@ -41,29 +43,29 @@ auto main(const int argc, char** argv) -> int {
bool firstMap = true;
for (const OneMapInfo& mapInfo : mapInfos) {
if (firstMap) {
outputStream << endl;
outputStream << '\n';
firstMap = false;
} else {
outputStream << "," << endl;
outputStream << "," << '\n';
}
outputStream << " {" << endl;
outputStream << R"( "name": ")" << mapInfo.name << "\"," << endl;
outputStream << " {" << '\n';
outputStream << R"( "name": ")" << mapInfo.name << "\"," << '\n';
outputStream << " \"castleCount\": " << mapInfo.castleCount << "," << endl;
outputStream << " \"castleCount\": " << mapInfo.castleCount << "," << '\n';
outputStream << " \"positions\": {";
bool firstPosition = true;
for (const auto& [position, count] : mapInfo.positionsRequiringCrossing) {
if (firstPosition) {
outputStream << endl;
outputStream << '\n';
firstPosition = false;
} else {
outputStream << "," << endl;
outputStream << "," << '\n';
}
outputStream << " \"" << position << "\": " << count;
}
outputStream << endl << " }" << endl << " }";
outputStream << '\n' << " }" << '\n' << " }";
}
outputStream << endl << "]" << endl;
outputStream << '\n' << "]" << '\n';
}
@@ -1,127 +0,0 @@
//
// Created by Dan Crosby on 3/29/21.
//
#include <memory>
#include <numeric>
#include <random>
#include <thread>
#include "src/main/cpp/net/eagle0/common/FilesystemUtils.hpp"
#include "src/main/cpp/net/eagle0/common/UnitConversions.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"
#include "src/main/cpp/net/eagle0/shardok/server/ShardokGamesManager.hpp"
#include "src/main/protobuf/net/eagle0/common/random_units.pb.h"
using net::eagle0::common::RandomUnits;
using std::shared_ptr;
using std::vector;
constexpr int THREAD_COUNT = 16;
#define FIXED_SEED true
#if FIXED_SEED
std::mt19937 g;
#else
std::random_device rd;
std::mt19937 g(rd());
#endif
vector<string> fileNames{};
using namespace shardok;
ShardokGamesManager* manager;
auto randInt(const int lowInc, const int hiInc) {
return std::uniform_int_distribution(lowInc, hiInc)(g);
}
void runBattle(const vector<shared_ptr<const UnitProto>>& units) {
auto mapName = fileNames[randInt(0, (int)fileNames.size() - 1)];
auto month = randInt(1, 12);
auto p1UnitCount = randInt(1, 20);
vector<UnitProto> p1Units{};
for (int i = 0; i < p1UnitCount; i++) {
auto unit = *units[i];
unit.set_player_id(0);
p1Units.push_back(unit);
}
auto p2UnitCount = randInt(1, 20);
vector<UnitProto> p2Units{};
for (int i = p1UnitCount; i < p1UnitCount + p2UnitCount; i++) {
auto unit = *units[i];
unit.set_player_id(1);
p2Units.push_back(unit);
}
printf("map name is %s, %d attacking %d\n", mapName.c_str(), p1UnitCount, p2UnitCount);
vector<VictoryConditionProto> attVictoryConditions{
VictoryConditionProto::VICTORY_CONDITION_HOLDS_CRITICAL_TILES,
VictoryConditionProto::VICTORY_CONDITION_LAST_PLAYER_STANDING};
vector<VictoryConditionProto> defVictoryConditions{
VictoryConditionProto::VICTORY_CONDITION_LAST_PLAYER_STANDING,
VictoryConditionProto::VICTORY_CONDITION_WIN_AFTER_MAX_ROUNDS};
auto p1 = PlayerInfoWithUnits(0, true, 5, false, 10000, attVictoryConditions, {}, p1Units);
auto p2 = PlayerInfoWithUnits(1, false, 7, false, 10000, defVictoryConditions, {}, p2Units);
string gameId = std::to_string(randInt(INT_MIN, INT_MAX));
manager->LockedCreateSpecifiedGame(gameId, {p1, p2}, mapName, "", month, "");
}
auto LoadUnits() -> vector<shared_ptr<const UnitProto>> {
const auto bytes = byte_vector::FromPath("/tmp/random_heroes.bin");
RandomUnits commonUnits;
commonUnits.ParseFromArray(bytes.data(), (int)bytes.size());
printf("Loaded %d units\n", commonUnits.units_size());
vector<shared_ptr<const UnitProto>> units{};
units.reserve(commonUnits.units_size());
for (const auto& commonUnit : commonUnits.units()) {
// FIXME: assumes 2 players
units.push_back(std::make_shared<const UnitProto>(ConvertUnit(commonUnit, 0, {0, 1})));
}
std::shuffle(units.begin(), units.end(), g);
return units;
}
[[noreturn]] void runBattlesThread(const vector<shared_ptr<const UnitProto>>& units) {
while (true) { runBattle(units); }
}
auto main(int argc, char** argv) -> int {
#if FIXED_SEED
std::srand(4564564);
g.seed(378473);
#else
std::srand(std::time(nullptr));
#endif
FilesystemUtils::SetExecPath(argv[0]);
auto randomUnits = LoadUnits();
printf("Map file directory is %s\n", FilesystemUtils::MapFilesDirectory().c_str());
fileNames = FilesystemUtils::FilesInDirectory(FilesystemUtils::MapFilesDirectory(), ".e0m");
for (auto& fileName : fileNames) { fileName.resize(fileName.size() - 4); }
manager = new ShardokGamesManager(nullptr, std::vector<std::string>());
std::thread threads[THREAD_COUNT];
for (int i = 0; i < THREAD_COUNT; i++) {
threads[i] = std::thread(runBattlesThread, randomUnits);
}
for (auto& thread : threads) { thread.join(); }
}
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/19/23.
//
#ifndef EAGLE0_AIATTACKGROUPS_HPP
#define EAGLE0_AIATTACKGROUPS_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_ATTACK_GROUPS_HPP
#define EAGLE0_SHARDOK_AI_AI_ATTACK_GROUPS_HPP
#include <functional>
#include <vector>
@@ -77,4 +77,4 @@ auto GenerateTargetPriorities(
} // namespace shardok
#endif // EAGLE0_AIATTACKGROUPS_HPP
#endif // EAGLE0_SHARDOK_AI_AI_ATTACK_GROUPS_HPP
@@ -20,7 +20,7 @@ using Unit = net::eagle0::shardok::storage::fb::Unit;
using std::shared_ptr;
using std::vector;
class AttackLocations {
class alignas(128) AttackLocations {
private:
const MapIndex rowCount;
const MapIndex columnCount;
@@ -147,9 +147,9 @@ public:
adjacentLocations += cs;
allLocations += cs;
}
} __attribute__((aligned(128)));
};
struct AttackLocationsCache {
struct alignas(128) AttackLocationsCache {
private:
const MapIndex rowCount;
const MapIndex columnCount;
@@ -166,7 +166,7 @@ public:
auto CachedLocations(const Coords& singleTarget, bool lateGame) -> const AttackLocations&;
auto CachedLocations(const CoordsSet& targets, bool lateGame) -> AttackLocations;
auto CachedLocations(const vector<const Unit*>& enemies, bool lateGame) -> AttackLocations;
} __attribute__((aligned(128)));
};
using ALCache = std::unique_ptr<AttackLocationsCache>;
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 1/9/22.
//
#ifndef EAGLE0_AIATTACKERSTRATEGYSELECTOR_HPP
#define EAGLE0_AIATTACKERSTRATEGYSELECTOR_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_ATTACKER_STRATEGY_SELECTOR_HPP
#define EAGLE0_SHARDOK_AI_AI_ATTACKER_STRATEGY_SELECTOR_HPP
#include "src/main/cpp/net/eagle0/shardok/ai/AIAttackLocations.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/AICommonTypes.hpp"
@@ -32,4 +32,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_AIATTACKERSTRATEGYSELECTOR_HPP
#endif // EAGLE0_SHARDOK_AI_AI_ATTACKER_STRATEGY_SELECTOR_HPP
@@ -22,11 +22,11 @@ namespace shardok {
// No need to forward declare internal functions - use the public interface instead
// Helper constants and static variables
static const std::vector<double> _averageSequence = {0.5};
static const auto _averageGenerator = std::make_shared<SequenceRandomGenerator>(_averageSequence);
static const std::vector<double> kAverageSequence = {0.5};
static const auto kAverageGenerator = std::make_shared<SequenceRandomGenerator>(kAverageSequence);
#define MULTITHREAD true
#define LOGGING_ 0
constexpr bool kMultithread = true;
constexpr bool kLogging = false;
// Helper function to determine if a command type is deterministic
static auto IsDeterministic(const CommandType type) -> bool {
@@ -237,15 +237,16 @@ auto AICommandEvaluator::EvaluateWithRandomness(
return lookaheadFuture.get();
};
#if MULTITHREAD
auto launchPolicy = remainingLookahead == 1 ? std::launch::async : std::launch::deferred;
returnValue.lookaheadScore = std::async(launchPolicy, lookaheadLambda);
#else
std::promise<EvaluationResult> p;
returnValue.lookaheadScore = p.get_future();
auto lambdaResult = lookaheadLambda();
p.set_value(lambdaResult);
#endif
if constexpr (kMultithread) {
auto launchPolicy =
remainingLookahead == 1 ? std::launch::async : std::launch::deferred;
returnValue.lookaheadScore = std::async(launchPolicy, lookaheadLambda);
} else {
std::promise<EvaluationResult> p;
returnValue.lookaheadScore = p.get_future();
auto lambdaResult = lookaheadLambda();
p.set_value(lambdaResult);
}
}
return returnValue;
@@ -302,22 +303,23 @@ auto AICommandEvaluator::FindBestCommand(
minDistToEnemies = 0.0; // No enemies found
}
#if LOGGING_
// Log command count and distance metrics for performance analysis
const auto allCommandCount = guessedDescriptors->size();
const auto filteredCommandCount = filteredIndices.size();
const int currentRound = gameState->current_round();
if constexpr (kLogging) {
// Log command count and distance metrics for performance analysis
const auto allCommandCount = guessedDescriptors->size();
const auto filteredCommandCount = filteredIndices.size();
const int currentRound = gameState->current_round();
printf("AI_COMMAND_COUNT: Round %d, Player %d, Defender %d, MinDist %.1f, Commands %zu -> %zu "
"(%.1f%% filtered)\n",
currentRound,
static_cast<int>(pid),
isDefender ? 1 : 0,
minDistToEnemies,
allCommandCount,
filteredCommandCount,
100.0 * (allCommandCount - filteredCommandCount) / allCommandCount);
#endif
printf("AI_COMMAND_COUNT: Round %d, Player %d, Defender %d, MinDist %.1f, Commands %zu -> "
"%zu "
"(%.1f%% filtered)\n",
currentRound,
static_cast<int>(pid),
isDefender ? 1 : 0,
minDistToEnemies,
allCommandCount,
filteredCommandCount,
100.0 * (allCommandCount - filteredCommandCount) / allCommandCount);
}
const auto commandCount = filteredIndices.size();
@@ -352,7 +354,7 @@ auto AICommandEvaluator::FindBestCommand(
originalIndex,
remainingLookahead,
maxRepeatCount,
_averageGenerator,
kAverageGenerator,
guessedEngine,
attackerStrategy,
allCastleCoords,
@@ -520,7 +522,7 @@ auto AICommandEvaluator::EvaluateCommand(
commandIndex,
remainingLookahead,
maxRepeatCount,
_averageGenerator,
kAverageGenerator,
guessedEngine,
attackerStrategy,
allCastleCoords,
@@ -3,8 +3,8 @@
// Separated from AIScoreCalculator to isolate pure state scoring from lookahead logic.
//
#ifndef EAGLE0_AICOMMANDEVALUATOR_HPP
#define EAGLE0_AICOMMANDEVALUATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_COMMAND_EVALUATOR_HPP
#define EAGLE0_SHARDOK_AI_AI_COMMAND_EVALUATOR_HPP
#include <chrono>
#include <future>
@@ -114,4 +114,4 @@ private:
} // namespace shardok
#endif // EAGLE0_AICOMMANDEVALUATOR_HPP
#endif // EAGLE0_SHARDOK_AI_AI_COMMAND_EVALUATOR_HPP
@@ -2,8 +2,8 @@
// Filter obviously bad commands to reduce search space for AI
//
#ifndef EAGLE0_AICOMMANDFILTER_HPP
#define EAGLE0_AICOMMANDFILTER_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_COMMAND_FILTER_HPP
#define EAGLE0_SHARDOK_AI_AI_COMMAND_FILTER_HPP
#include <memory>
#include <vector>
@@ -116,4 +116,4 @@ private:
} // namespace shardok
#endif // EAGLE0_AICOMMANDFILTER_HPP
#endif // EAGLE0_SHARDOK_AI_AI_COMMAND_FILTER_HPP
@@ -3,8 +3,8 @@
// Common type definitions used across AI utility functions
//
#ifndef EAGLE0_AICOMMONTYPES_HPP
#define EAGLE0_AICOMMONTYPES_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_COMMON_TYPES_HPP
#define EAGLE0_SHARDOK_AI_AI_COMMON_TYPES_HPP
#include <functional>
@@ -20,4 +20,4 @@ using BattalionTypeGetter = std::function<BattalionTypeSPtr(BattalionTypeId)>;
} // namespace shardok
#endif // EAGLE0_AICOMMONTYPES_HPP
#endif // EAGLE0_SHARDOK_AI_AI_COMMON_TYPES_HPP
@@ -2,8 +2,8 @@
// AI System Types and Configuration
//
#ifndef EAGLE0_AI_CONFIG_HPP
#define EAGLE0_AI_CONFIG_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_CONFIG_HPP
#define EAGLE0_SHARDOK_AI_AI_CONFIG_HPP
namespace shardok {
@@ -22,4 +22,4 @@ enum class ScoringCalculatorType {
} // namespace shardok
#endif // EAGLE0_AI_CONFIG_HPP
#endif // EAGLE0_SHARDOK_AI_AI_CONFIG_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 8/30/23.
//
#ifndef EAGLE0_AIDEFENDERSTRATEGYSELECTOR_HPP
#define EAGLE0_AIDEFENDERSTRATEGYSELECTOR_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_DEFENDER_STRATEGY_SELECTOR_HPP
#define EAGLE0_SHARDOK_AI_AI_DEFENDER_STRATEGY_SELECTOR_HPP
#include "src/main/cpp/net/eagle0/shardok/ai/AIAttackLocations.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/AICommonTypes.hpp"
@@ -26,4 +26,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_AIDEFENDERSTRATEGYSELECTOR_HPP
#endif // EAGLE0_SHARDOK_AI_AI_DEFENDER_STRATEGY_SELECTOR_HPP
@@ -55,12 +55,12 @@ auto DefenderDistanceBuf(
const bool includeUndead) -> double {
const auto &locationsToAttackMe = alCache->CachedLocations(defenderLocation, lateGame);
struct WithoutAndWith {
struct alignas(8) WithoutAndWith {
int without;
int with;
WithoutAndWith(const int a, const int b) : without(a), with(b) {}
} __attribute__((aligned(8)));
};
vector<WithoutAndWith> pointCosts{};
pointCosts.reserve(attackerUnits.size());
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 5/10/21.
//
#ifndef EAGLE0_AIDISTANCEDEBUF_HPP
#define EAGLE0_AIDISTANCEDEBUF_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_DISTANCE_DEBUF_HPP
#define EAGLE0_SHARDOK_AI_AI_DISTANCE_DEBUF_HPP
#include "AIAttackLocations.hpp"
#include "src/main/cpp/net/eagle0/shardok/ai/AICommonTypes.hpp"
@@ -29,4 +29,4 @@ auto DefenderDistanceBuf(
bool includeUndead) -> double;
} // namespace shardok
#endif // EAGLE0_AIDISTANCEDEBUF_HPP
#endif // EAGLE0_SHARDOK_AI_AI_DISTANCE_DEBUF_HPP
@@ -2,8 +2,8 @@
// Temporary AI experiment switches used by benchmark-only EXPERIMENTAL runs.
//
#ifndef EAGLE0_AI_EXPERIMENT_CONFIG_HPP
#define EAGLE0_AI_EXPERIMENT_CONFIG_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_EXPERIMENT_CONFIG_HPP
#define EAGLE0_SHARDOK_AI_AI_EXPERIMENT_CONFIG_HPP
#include <cstdlib>
#include <string>
@@ -20,4 +20,4 @@ inline auto IsAIExperiment(const int id) -> bool { return CurrentAIExperimentId(
} // namespace shardok
#endif // EAGLE0_AI_EXPERIMENT_CONFIG_HPP
#endif // EAGLE0_SHARDOK_AI_AI_EXPERIMENT_CONFIG_HPP
@@ -3,8 +3,8 @@
// Provides O(1) weights based on command type and context
//
#ifndef EAGLE0_AI_HEURISTIC_WEIGHTING_HPP
#define EAGLE0_AI_HEURISTIC_WEIGHTING_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_HEURISTIC_WEIGHTING_HPP
#define EAGLE0_SHARDOK_AI_AI_HEURISTIC_WEIGHTING_HPP
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
@@ -37,4 +37,4 @@ public:
} // namespace shardok
#endif // EAGLE0_AI_HEURISTIC_WEIGHTING_HPP
#endif // EAGLE0_SHARDOK_AI_AI_HEURISTIC_WEIGHTING_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 8/31/23.
//
#ifndef EAGLE0_AIMINIMUMDISTANCEANDTARGET_HPP
#define EAGLE0_AIMINIMUMDISTANCEANDTARGET_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_MINIMUM_DISTANCE_AND_TARGET_HPP
#define EAGLE0_SHARDOK_AI_AI_MINIMUM_DISTANCE_AND_TARGET_HPP
#include <utility>
#include <vector>
@@ -34,4 +34,4 @@ auto MinimumDistance(
} // namespace shardok
#endif // EAGLE0_AIMINIMUMDISTANCEANDTARGET_HPP
#endif // EAGLE0_SHARDOK_AI_AI_MINIMUM_DISTANCE_AND_TARGET_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/7/21.
//
#ifndef EAGLE0_AISCOREUTILITIES_HPP
#define EAGLE0_AISCOREUTILITIES_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_SCORE_UTILITIES_HPP
#define EAGLE0_SHARDOK_AI_AI_SCORE_UTILITIES_HPP
#include <vector>
@@ -31,4 +31,4 @@ auto PlayerInfoForPid(const GameStateW &, PlayerId pid) -> const PlayerInfo *;
} // namespace shardok
#endif // EAGLE0_AISCOREUTILITIES_HPP
#endif // EAGLE0_SHARDOK_AI_AI_SCORE_UTILITIES_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 1/10/22.
//
#ifndef EAGLE0_AISTRATEGY_HPP
#define EAGLE0_AISTRATEGY_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_STRATEGY_HPP
#define EAGLE0_SHARDOK_AI_AI_STRATEGY_HPP
#include "src/main/cpp/net/eagle0/shardok/ai/AIAttackGroups.hpp"
@@ -34,4 +34,4 @@ auto CrossRiversStrategy(const CoordsSet& targetLocations) -> AIStrategy;
} // namespace shardok
#endif // EAGLE0_AISTRATEGY_HPP
#endif // EAGLE0_SHARDOK_AI_AI_STRATEGY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 07/04/25.
//
#ifndef EAGLE0_AITIMEBUDGET_HPP
#define EAGLE0_AITIMEBUDGET_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_TIME_BUDGET_HPP
#define EAGLE0_SHARDOK_AI_AI_TIME_BUDGET_HPP
#include <atomic>
#include <chrono>
@@ -48,4 +48,4 @@ auto CalculateTimeBudget(
} // namespace shardok
#endif // EAGLE0_AITIMEBUDGET_HPP
#endif // EAGLE0_SHARDOK_AI_AI_TIME_BUDGET_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/7/21.
//
#ifndef EAGLE0_AIUNITSCORECALCULATOR_HPP
#define EAGLE0_AIUNITSCORECALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_UNIT_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_AI_UNIT_SCORE_CALCULATOR_HPP
#include "src/main/cpp/net/eagle0/shardok/library/action_point_distances/ActionPointDistances.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/CoordsSet.hpp"
@@ -53,4 +53,4 @@ auto UnitValue(
} // namespace shardok
#endif // EAGLE0_AIUNITSCORECALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_AI_UNIT_SCORE_CALCULATOR_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 12/29/21.
//
#ifndef EAGLE0_AIWATERCROSSINGCALCULATOR_HPP
#define EAGLE0_AIWATERCROSSINGCALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_CALCULATOR_HPP
#include "src/main/cpp/net/eagle0/shardok/ai/AICommonTypes.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
@@ -23,7 +23,8 @@ static inline void AssertValid(const Coords& c, const HexMap* hexMap) {
if (!valid) {
std::stringstream str;
str << "Invalid coords " << (int)c.row() << ", " << (int)c.column();
str << "Invalid coords " << static_cast<int>(c.row()) << ", "
<< static_cast<int>(c.column());
throw ShardokInternalErrorException(str.str());
}
@@ -85,4 +86,4 @@ auto WaterCrossingScore(
} // namespace shardok
#endif // EAGLE0_AIWATERCROSSINGCALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_CALCULATOR_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 1/5/22.
//
#ifndef EAGLE0_AIWATERCROSSINGCOMMANDCHOOSER_HPP
#define EAGLE0_AIWATERCROSSINGCOMMANDCHOOSER_HPP
#ifndef EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_COMMAND_CHOOSER_HPP
#define EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_COMMAND_CHOOSER_HPP
#include <utility>
@@ -44,4 +44,4 @@ public:
} // namespace shardok
#endif // EAGLE0_AIWATERCROSSINGCOMMANDCHOOSER_HPP
#endif // EAGLE0_SHARDOK_AI_AI_WATER_CROSSING_COMMAND_CHOOSER_HPP
@@ -19,7 +19,7 @@
namespace shardok {
#define DEBUG_ITERATIVE_DEEPENING_TIMINGS 1
constexpr bool kDebugIterativeDeepeningTimings = true;
IterativeDeepeningAI::IterativeDeepeningAI(
const PlayerId playerId,
@@ -54,9 +54,9 @@ auto IterativeDeepeningAI::IterativeSearch(
// DEBUG: Clear TT to see if that's causing the suspicious depth reaching
// g_transpositionTable.clear(); // Uncomment to test without cross-search caching
if (commands->empty()) {
#if DEBUG_ITERATIVE_DEEPENING_TIMINGS
printf("ID AI: Commands are empty, returning early\n");
#endif
if (kDebugIterativeDeepeningTimings) {
printf("ID AI: Commands are empty, returning early\n");
}
result.searchCompleted = true;
return result;
}
@@ -168,23 +168,23 @@ auto IterativeDeepeningAI::IterativeSearch(
// Log if best command changed from previous depth
if (currentDepth > 1 && currentBestCommand != previousBestCommand) {
#if DEBUG_ITERATIVE_DEEPENING_TIMINGS
printf("ID AI: Best command changed at depth %lu:\n", currentDepth);
printf(" Depth %lu best: command %zu (score %.2f) - type: %s\n",
currentDepth - 1,
previousBestCommand,
scoresByDepth[previousBestCommand][currentDepth - 1],
net::eagle0::shardok::common::CommandType_Name(
(*commands)[previousBestCommand]->GetCommandType())
.c_str());
printf(" Depth %lu best: command %zu (score %.2f) - type: %s\n",
currentDepth,
currentBestCommand,
currentBestScore,
net::eagle0::shardok::common::CommandType_Name(
(*commands)[currentBestCommand]->GetCommandType())
.c_str());
#endif
if (kDebugIterativeDeepeningTimings) {
printf("ID AI: Best command changed at depth %lu:\n", currentDepth);
printf(" Depth %lu best: command %zu (score %.2f) - type: %s\n",
currentDepth - 1,
previousBestCommand,
scoresByDepth[previousBestCommand][currentDepth - 1],
net::eagle0::shardok::common::CommandType_Name(
(*commands)[previousBestCommand]->GetCommandType())
.c_str());
printf(" Depth %lu best: command %zu (score %.2f) - type: %s\n",
currentDepth,
currentBestCommand,
currentBestScore,
net::eagle0::shardok::common::CommandType_Name(
(*commands)[currentBestCommand]->GetCommandType())
.c_str());
}
}
previousBestCommand = currentBestCommand;
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 07/04/25.
//
#ifndef EAGLE0_ITERATIVEDEEPENINGAI_HPP
#define EAGLE0_ITERATIVEDEEPENINGAI_HPP
#ifndef EAGLE0_SHARDOK_AI_ITERATIVE_DEEPENING_AI_HPP
#define EAGLE0_SHARDOK_AI_ITERATIVE_DEEPENING_AI_HPP
#include <chrono>
#include <future>
@@ -111,4 +111,4 @@ private:
} // namespace shardok
#endif // EAGLE0_ITERATIVEDEEPENINGAI_HPP
#endif // EAGLE0_SHARDOK_AI_ITERATIVE_DEEPENING_AI_HPP
@@ -8,8 +8,6 @@
#include "ShardokAIClient.hpp"
#define DEBUG_FLEE_DECISIONS
// Enable to dump game state and debug tree to /tmp for debugging
// #define ENABLE_MCTS_DEBUG_DUMP
@@ -43,6 +41,7 @@ using net::eagle0::shardok::api::ActionResultView;
using net::eagle0::shardok::api::GameStateView;
static constexpr bool kPerformanceLogging = true;
static constexpr bool kDebugFleeDecisions = true;
void ApplyUpdate(GameStateView & /*currentView*/, const ActionResultView & /*update*/) {}
@@ -468,12 +467,7 @@ auto ShardokAIClient::FinalRoundAttackerChooseCommandIndex(
maxRounds,
minimumFleeOddsThreshold,
desperateFleeThreshold,
#ifdef DEBUG_FLEE_DECISIONS
true // Enable debug logging
#else
false
#endif
);
kDebugFleeDecisions);
if (fleeDecision.shouldFlee) {
CommandChoiceResults results{};
@@ -2,8 +2,8 @@
// TranspositionTable.hpp - Cache for game state evaluations to avoid redundant calculations
//
#ifndef EAGLE0_TRANSPOSITIONTABLE_HPP
#define EAGLE0_TRANSPOSITIONTABLE_HPP
#ifndef EAGLE0_SHARDOK_AI_TRANSPOSITION_TABLE_HPP
#define EAGLE0_SHARDOK_AI_TRANSPOSITION_TABLE_HPP
#include <atomic>
#include <cstdint>
@@ -88,4 +88,4 @@ extern TranspositionTable g_transpositionTable;
} // namespace shardok
#endif // EAGLE0_TRANSPOSITIONTABLE_HPP
#endif // EAGLE0_SHARDOK_AI_TRANSPOSITION_TABLE_HPP
@@ -2,8 +2,8 @@
// Shardok-specific MCTS AI that wraps the abstract implementation
//
#ifndef EAGLE0_SHARDOK_MCTSAI_HPP
#define EAGLE0_SHARDOK_MCTSAI_HPP
#ifndef EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP
#define EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP
#include <memory>
#include <vector>
@@ -68,4 +68,4 @@ private:
} // namespace shardok
#endif // EAGLE0_SHARDOK_MCTSAI_HPP
#endif // EAGLE0_SHARDOK_AI_MCTS_SHARDOK_MCTSAI_HPP
@@ -2,8 +2,8 @@
// Shardok-specific action adapter for MCTS
//
#ifndef EAGLE0_SHARDOK_ACTION_HPP
#define EAGLE0_SHARDOK_ACTION_HPP
#ifndef EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_ACTION_HPP
#define EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_ACTION_HPP
#include <memory>
#include <string>
@@ -58,4 +58,4 @@ private:
} // namespace shardok::mcts
#endif // EAGLE0_SHARDOK_ACTION_HPP
#endif // EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_ACTION_HPP
@@ -2,8 +2,8 @@
// Shardok-specific game engine adapter for MCTS
//
#ifndef EAGLE0_SHARDOK_GAME_ENGINE_HPP
#define EAGLE0_SHARDOK_GAME_ENGINE_HPP
#ifndef EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_ENGINE_HPP
#define EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_ENGINE_HPP
#include <atomic>
#include <functional>
@@ -141,4 +141,4 @@ public:
} // namespace mcts
} // namespace shardok
#endif // EAGLE0_SHARDOK_GAME_ENGINE_HPP
#endif // EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_ENGINE_HPP
@@ -2,8 +2,8 @@
// Shardok-specific game state adapter for MCTS
//
#ifndef EAGLE0_SHARDOK_GAME_STATE_HPP
#define EAGLE0_SHARDOK_GAME_STATE_HPP
#ifndef EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_STATE_HPP
#define EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_STATE_HPP
#include <memory>
@@ -80,4 +80,4 @@ private:
} // namespace mcts
} // namespace shardok
#endif // EAGLE0_SHARDOK_GAME_STATE_HPP
#endif // EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_GAME_STATE_HPP
@@ -2,8 +2,8 @@
// Factory for creating Shardok-specific MCTS components
//
#ifndef EAGLE0_SHARDOK_MCTS_FACTORY_HPP
#define EAGLE0_SHARDOK_MCTS_FACTORY_HPP
#ifndef EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_MCTS_FACTORY_HPP
#define EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_MCTS_FACTORY_HPP
#include <functional>
#include <memory>
@@ -67,4 +67,4 @@ public:
} // namespace mcts
} // namespace shardok
#endif // EAGLE0_SHARDOK_MCTS_FACTORY_HPP
#endif // EAGLE0_SHARDOK_AI_MCTS_ADAPTERS_SHARDOK_MCTS_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by dancrosby on 3/4/20.
//
#ifndef EAGLE0_AISCORECALCULATOR_HPP
#define EAGLE0_AISCORECALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_AI_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_SCORE_AI_SCORE_CALCULATOR_HPP
#include <future>
@@ -53,4 +53,4 @@ public:
} // namespace shardok
#endif // EAGLE0_AISCORECALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_AI_SCORE_CALCULATOR_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/11/21.
//
#ifndef EAGLE0_AIVICTORYCONDITIONSCORECALCULATOR_HPP
#define EAGLE0_AIVICTORYCONDITIONSCORECALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_AI_VICTORY_CONDITION_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_SCORE_AI_VICTORY_CONDITION_SCORE_CALCULATOR_HPP
#include <vector>
@@ -48,4 +48,4 @@ auto LastPlayerStandingVictoryScore(
} // namespace shardok
#endif // EAGLE0_AIVICTORYCONDITIONSCORECALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_AI_VICTORY_CONDITION_SCORE_CALCULATOR_HPP
@@ -3,8 +3,8 @@
// Uses bounded linear scoring tuned for MCTS exploration/exploitation balance
//
#ifndef EAGLE0_MCTSOPTIMIZEDAISCORECALCULATOR_HPP
#define EAGLE0_MCTSOPTIMIZEDAISCORECALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_MCTS_OPTIMIZED_AI_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_SCORE_MCTS_OPTIMIZED_AI_SCORE_CALCULATOR_HPP
#include <memory>
@@ -29,4 +29,4 @@ using ALCache = std::unique_ptr<AttackLocationsCache>;
} // namespace shardok
#endif // EAGLE0_MCTSOPTIMIZEDAISCORECALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_MCTS_OPTIMIZED_AI_SCORE_CALCULATOR_HPP
@@ -41,9 +41,6 @@ class StandardAIScoreCalculator;
// Anonymous namespace for helper functions that don't need access to scorer
namespace {
#define LOGGING_ 0
#define PERFORMANCE_LOGGING_ 0
// Performance logging for AttackerScoreForState
struct AttackerScorePerformanceLogger {
static constexpr int LOG_INTERVAL = 100000;
@@ -2,8 +2,8 @@
// Standard implementation of AIScoreCalculator
//
#ifndef EAGLE0_STANDARDAISCORECALCULATOR_HPP
#define EAGLE0_STANDARDAISCORECALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_STANDARD_AI_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_SCORE_STANDARD_AI_SCORE_CALCULATOR_HPP
#include <memory>
@@ -34,4 +34,4 @@ using ALCache = std::unique_ptr<AttackLocationsCache>;
} // namespace shardok
#endif // EAGLE0_STANDARDAISCORECALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_STANDARD_AI_SCORE_CALCULATOR_HPP
@@ -3,8 +3,8 @@
// This file is private to the ai/score package
//
#ifndef EAGLE0_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
#define EAGLE0_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_PRIVATE_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
#define EAGLE0_SHARDOK_AI_SCORE_PRIVATE_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
#include <vector>
@@ -92,4 +92,4 @@ auto AttackerMultiplierForTargetDistance(
} // namespace score_calculator_internal
} // namespace shardok
#endif // EAGLE0_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_PRIVATE_AI_SCORE_CALCULATOR_SHARED_UTILITIES_HPP
@@ -3,8 +3,8 @@
// This file is private to the ai/score package
//
#ifndef EAGLE0_ABSTRACT_AI_SCORE_CALCULATOR_HPP
#define EAGLE0_ABSTRACT_AI_SCORE_CALCULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_SCORE_PRIVATE_ABSTRACT_AI_SCORE_CALCULATOR_HPP
#define EAGLE0_SHARDOK_AI_SCORE_PRIVATE_ABSTRACT_AI_SCORE_CALCULATOR_HPP
#include <memory>
#include <unordered_map>
@@ -178,4 +178,4 @@ private:
} // namespace shardok
#endif // EAGLE0_ABSTRACT_AI_SCORE_CALCULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_SCORE_PRIVATE_ABSTRACT_AI_SCORE_CALCULATOR_HPP
@@ -21,7 +21,7 @@ std::unique_ptr<BattleConfigProto> AiBattleConfigLoader::LoadFromJsonFile(
const std::string& filepath) {
std::ifstream file(filepath);
if (!file.is_open()) {
std::cerr << "Failed to open config file: " << filepath << std::endl;
std::cerr << "Failed to open config file: " << filepath << '\n';
return nullptr;
}
@@ -41,7 +41,7 @@ std::unique_ptr<BattleConfigProto> AiBattleConfigLoader::LoadFromJsonString(
google::protobuf::util::JsonStringToMessage(jsonString, config.get(), options);
if (!status.ok()) {
std::cerr << "Failed to parse JSON config: " << status.message() << std::endl;
std::cerr << "Failed to parse JSON config: " << status.message() << '\n';
return nullptr;
}
@@ -103,7 +103,7 @@ std::string AiBattleConfigLoader::ToJsonString(const BattleConfigProto& config)
const auto status = google::protobuf::util::MessageToJsonString(config, &jsonString, options);
if (!status.ok()) {
std::cerr << "Failed to convert config to JSON: " << status.message() << std::endl;
std::cerr << "Failed to convert config to JSON: " << status.message() << '\n';
return "";
}
@@ -2,8 +2,8 @@
// AI Battle Simulator Configuration Loader
//
#ifndef EAGLE0_AI_BATTLE_CONFIG_HPP
#define EAGLE0_AI_BATTLE_CONFIG_HPP
#ifndef EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP
#define EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP
#include <memory>
#include <string>
@@ -44,4 +44,4 @@ public:
} // namespace ai_battle_simulator
} // namespace shardok
#endif // EAGLE0_AI_BATTLE_CONFIG_HPP
#endif // EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_CONFIG_HPP
@@ -744,7 +744,8 @@ BattleResult AiBattleSimulator::RunBattlePhase(
auto availableCommands = engine.GetAvailableCommandProtos(currentPlayer, false);
if (availableCommands.empty()) {
std::cout << "No commands available for player " << (int)currentPlayer << "\n";
std::cout << "No commands available for player " << static_cast<int>(currentPlayer)
<< "\n";
break;
}
@@ -2,8 +2,8 @@
// AI Battle Simulator - Runs AI vs AI battles to completion
//
#ifndef EAGLE0_AI_BATTLE_SIMULATOR_HPP
#define EAGLE0_AI_BATTLE_SIMULATOR_HPP
#ifndef EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_SIMULATOR_HPP
#define EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_SIMULATOR_HPP
#include <memory>
#include <optional>
@@ -149,4 +149,4 @@ private:
} // namespace ai_battle_simulator
} // namespace shardok
#endif // EAGLE0_AI_BATTLE_SIMULATOR_HPP
#endif // EAGLE0_SHARDOK_AI_BATTLE_SIMULATOR_AI_BATTLE_SIMULATOR_HPP
@@ -78,7 +78,7 @@ auto ParseCommandLineArgs(int argc, char* argv[]) -> PerformanceTestConfig {
} // namespace
int main(int argc, char* argv[]) {
std::cout << "Starting AI Performance Runner..." << std::endl;
std::cout << "Starting AI Performance Runner..." << '\n';
// Set exec path so FilesystemUtils can find resource files
FilesystemUtils::SetExecPath(argv[0]);
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2025-01-15.
//
#ifndef EAGLE0_AIPERFORMANCERUNNER_HPP
#define EAGLE0_AIPERFORMANCERUNNER_HPP
#ifndef EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_AI_PERFORMANCE_RUNNER_HPP
#define EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_AI_PERFORMANCE_RUNNER_HPP
#include <chrono>
#include <map>
@@ -52,4 +52,4 @@ struct PerformanceTestConfig {
} // namespace shardok
#endif // EAGLE0_AIPERFORMANCERUNNER_HPP
#endif // EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_AI_PERFORMANCE_RUNNER_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2025-01-15.
//
#ifndef EAGLE0_PERFORMANCETESTGAMESTATEBUILDER_HPP
#define EAGLE0_PERFORMANCETESTGAMESTATEBUILDER_HPP
#ifndef EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_PERFORMANCE_TEST_GAME_STATE_BUILDER_HPP
#define EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_PERFORMANCE_TEST_GAME_STATE_BUILDER_HPP
#include <flatbuffers/flatbuffers.h>
@@ -85,4 +85,4 @@ private:
} // namespace shardok
#endif // EAGLE0_PERFORMANCETESTGAMESTATEBUILDER_HPP
#endif // EAGLE0_SHARDOK_AI_PERFORMANCE_RUNNER_PERFORMANCE_TEST_GAME_STATE_BUILDER_HPP
@@ -3,8 +3,8 @@
// Used by both AI Performance Runner and AI Battle Simulator
//
#ifndef EAGLE0_AI_CLIENT_FACTORY_HPP
#define EAGLE0_AI_CLIENT_FACTORY_HPP
#ifndef EAGLE0_SHARDOK_AI_TESTING_COMMON_AI_CLIENT_FACTORY_HPP
#define EAGLE0_SHARDOK_AI_TESTING_COMMON_AI_CLIENT_FACTORY_HPP
#include <memory>
@@ -68,4 +68,4 @@ public:
} // namespace ai_testing_common
} // namespace shardok
#endif // EAGLE0_AI_CLIENT_FACTORY_HPP
#endif // EAGLE0_SHARDOK_AI_TESTING_COMMON_AI_CLIENT_FACTORY_HPP
@@ -3,8 +3,8 @@
// Used by both AI Performance Runner and AI Battle Simulator
//
#ifndef EAGLE0_GAME_PHASE_RUNNER_HPP
#define EAGLE0_GAME_PHASE_RUNNER_HPP
#ifndef EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_PHASE_RUNNER_HPP
#define EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_PHASE_RUNNER_HPP
#include <functional>
@@ -61,4 +61,4 @@ public:
} // namespace ai_testing_common
} // namespace shardok
#endif // EAGLE0_GAME_PHASE_RUNNER_HPP
#endif // EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_PHASE_RUNNER_HPP
@@ -3,8 +3,8 @@
// Used by both AI Performance Runner and AI Battle Simulator
//
#ifndef EAGLE0_GAME_SETTINGS_FACTORY_HPP
#define EAGLE0_GAME_SETTINGS_FACTORY_HPP
#ifndef EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_SETTINGS_FACTORY_HPP
#define EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_SETTINGS_FACTORY_HPP
#include <memory>
@@ -36,4 +36,4 @@ public:
} // namespace ai_testing_common
} // namespace shardok
#endif // EAGLE0_GAME_SETTINGS_FACTORY_HPP
#endif // EAGLE0_SHARDOK_AI_TESTING_COMMON_GAME_SETTINGS_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/6/21.
//
#ifndef EAGLE0_GAMEUPDATERECEIVER_HPP
#define EAGLE0_GAMEUPDATERECEIVER_HPP
#ifndef EAGLE0_SHARDOK_CONTROLLER_GAME_UPDATE_RECEIVER_HPP
#define EAGLE0_SHARDOK_CONTROLLER_GAME_UPDATE_RECEIVER_HPP
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
@@ -31,4 +31,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_GAMEUPDATERECEIVER_HPP
#endif // EAGLE0_SHARDOK_CONTROLLER_GAME_UPDATE_RECEIVER_HPP
@@ -11,6 +11,7 @@
#include <execinfo.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <ranges>
#include <string>
@@ -115,8 +116,8 @@ auto ShardokGameController::LockedAIClientForPid(PlayerId pid) const
}
void ShardokGameController::DoAIThread() {
printf("Entering AI thread.\n");
if (aiClients.empty()) { printf("No AI players, exiting AI thread.\n"); }
std::cout << "Entering AI thread." << '\n';
if (aiClients.empty()) { std::cout << "No AI players, exiting AI thread." << '\n'; }
while (aiThreadKeepGoing) {
// Phase 1: Gather data for AI decision (brief lock)
@@ -154,7 +155,7 @@ void ShardokGameController::DoAIThread() {
// Lock released - polls can now get through
if (availableCommands->empty()) {
printf("no commands for player %d\n", playerId);
std::cout << "no commands for player " << playerId << '\n';
continue;
}
@@ -177,7 +178,7 @@ void ShardokGameController::DoAIThread() {
// Verify state hasn't changed while we were thinking
if (engine->GetUnfilteredHistoryCount() != expectedHistoryCount) {
// State changed (e.g., human posted command) - re-evaluate
printf("AI: State changed while thinking, re-evaluating\n");
std::cout << "AI: State changed while thinking, re-evaluating" << '\n';
continue;
}
@@ -208,12 +209,8 @@ void ShardokGameController::DoAIThread() {
aiThreadKeepGoing = !engine->GameIsOver();
}
} catch (const std::exception &e) {
fprintf(stderr,
"AI thread exception in game %s, player %d, round %d: %s\n",
cachedGameId.c_str(),
playerId,
gsv.current_round(),
e.what());
std::cerr << "AI thread exception in game " << cachedGameId << ", player " << playerId
<< ", round " << gsv.current_round() << ": " << e.what() << '\n';
void *backtraceArray[20];
const int backtraceSize = backtrace(backtraceArray, 20);
@@ -227,7 +224,7 @@ void ShardokGameController::DoAIThread() {
break;
}
}
printf("Exiting AI thread.\n");
std::cout << "Exiting AI thread." << '\n';
}
ShardokGameController::~ShardokGameController() {
@@ -274,7 +271,7 @@ void ShardokGameController::PostCommand(
const auto expectedToken = static_cast<int64_t>(engine->GetUnfilteredHistoryCount());
if (token < expectedToken) {
printf("Double token in postCommand\n");
std::cout << "Double token in postCommand" << '\n';
// The client is missing some updates; probably it's a double-submit
// Let's just ignore and see how it goes
} else if (token > expectedToken) {
@@ -322,7 +319,7 @@ void ShardokGameController::PostPlacementCommands(
const auto expectedToken = static_cast<int64_t>(engine->GetUnfilteredHistoryCount());
if (token < expectedToken) {
printf("Double token in postPlacementCommands\n");
std::cout << "Double token in postPlacementCommands" << '\n';
// The client is missing some updates; probably it's a double-submit
// Let's just ignore and see how it goes
} else if (token > expectedToken) {
@@ -2,8 +2,8 @@
// Created by dancrosby on 3/22/20.
//
#ifndef EAGLE0_ACTIONCOST_HPP
#define EAGLE0_ACTIONCOST_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_COST_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_COST_HPP
#include <cstdint>
@@ -52,4 +52,4 @@ inline constexpr ActionCost IMPOSSIBLE_ACTION_COST{ActionCost::impossible, 0};
} // namespace shardok
#endif // EAGLE0_ACTIONCOST_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_COST_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2025-01-15.
//
#ifndef EAGLE0_GAMESTATEW_HPP
#define EAGLE0_GAMESTATEW_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_GAME_STATE_W_HPP
#define EAGLE0_SHARDOK_LIBRARY_GAME_STATE_W_HPP
#include <cstdint>
@@ -108,4 +108,4 @@ public:
} // namespace shardok
#endif // EAGLE0_GAMESTATEW_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_GAME_STATE_W_HPP
@@ -30,7 +30,7 @@ class IllegalActionException : public ShardokException {
std::string description;
public:
explicit IllegalActionException(const std::string& d) : ShardokException(d){};
explicit IllegalActionException(const std::string& d) : ShardokException(d) {}
};
// Encapsulates any action that changes game state
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/4/20.
//
#ifndef EAGLE0_SHARDOKCOMMAND_HPP
#define EAGLE0_SHARDOKCOMMAND_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_SHARDOK_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_SHARDOK_COMMAND_HPP
#include <memory>
#include <vector>
@@ -26,7 +26,7 @@ private:
const PlayerId playerId;
protected:
explicit ShardokCommand(const PlayerId pid) : playerId(pid){};
explicit ShardokCommand(const PlayerId pid) : playerId(pid) {}
public:
[[nodiscard]] virtual auto GetCommandType() const -> CommandType = 0;
@@ -63,4 +63,4 @@ using CommandListSPtr = shared_ptr<const CommandList>;
} // namespace shardok
#endif // EAGLE0_SHARDOKCOMMAND_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_SHARDOK_COMMAND_HPP
@@ -712,7 +712,7 @@ auto SecuredByPlayerByUnitIdFromHistory(
continue;
}
if (!resolvedUnit.has_secured_by_player()) { continue; }
const auto *unit = (Unit *)resolvedUnit.unit_bytes().data();
const auto *unit = reinterpret_cast<const Unit *>(resolvedUnit.unit_bytes().data());
securedByPlayerByUnitId[unit->unit_id()] = resolvedUnit.secured_by_player().value();
}
}
@@ -19,7 +19,7 @@ using std::string;
class ShardokException : public std::exception {
protected:
string description;
explicit ShardokException(string desc) : description(std::move(desc)){};
explicit ShardokException(string desc) : description(std::move(desc)) {}
public:
[[nodiscard]] auto what() const noexcept -> const char* override {
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 1/11/21.
//
#ifndef EAGLE0_UNITPLACEMENTINFO_HPP
#define EAGLE0_UNITPLACEMENTINFO_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_UNIT_PLACEMENT_INFO_HPP
#define EAGLE0_SHARDOK_LIBRARY_UNIT_PLACEMENT_INFO_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCTypes.h"
@@ -20,4 +20,4 @@ struct UnitPlacementInfo {
} // namespace shardok
#endif // EAGLE0_UNITPLACEMENTINFO_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_UNIT_PLACEMENT_INFO_HPP
@@ -27,11 +27,12 @@ auto FireSpreadActionFactory::MakeFireSpreadAction(
const int16_t weatherFactor =
settings.GetFirePropensityByWeatherConditions(weather->conditions());
int relativeWindDirection = (int)weather->wind().direction() - (int)direction;
int relativeWindDirection =
static_cast<int>(weather->wind().direction()) - static_cast<int>(direction);
if (relativeWindDirection < 0) relativeWindDirection += 6;
const int windIntensity =
(int)(weather->wind().speed_in_mph() *
settings.Backing().fire_propensity_wind_speed_multiplier());
const int windIntensity = static_cast<int>(
weather->wind().speed_in_mph() *
settings.Backing().fire_propensity_wind_speed_multiplier());
int16_t windFactor;
switch (relativeWindDirection) {
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2/16/21.
//
#ifndef EAGLE0_ICEANDSNOWADJUSTMENTACTIONFACTORY_HPP
#define EAGLE0_ICEANDSNOWADJUSTMENTACTIONFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_ICE_AND_SNOW_ADJUSTMENT_ACTION_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_ICE_AND_SNOW_ADJUSTMENT_ACTION_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -49,4 +49,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_ICEANDSNOWADJUSTMENTACTIONFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_ICE_AND_SNOW_ADJUSTMENT_ACTION_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 11/29/20.
//
#ifndef EAGLE0_PLAYERSETUPCOMMANDFACTORY_HPP
#define EAGLE0_PLAYERSETUPCOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_PLAYER_SETUP_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_PLAYER_SETUP_COMMAND_FACTORY_HPP
#include <optional>
#include <vector>
@@ -22,7 +22,7 @@ private:
const SettingsGetter settings;
public:
explicit PlayerSetupCommandFactory(const SettingsGetter& getter) : settings(getter){};
explicit PlayerSetupCommandFactory(const SettingsGetter& getter) : settings(getter) {}
auto AddAvailablePlaceAndHideUnitCommandsForOneUnit(
CommandList& existingCommands,
@@ -40,4 +40,4 @@ public:
} // namespace shardok
#endif // EAGLE0_PLAYERSETUPCOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_PLAYER_SETUP_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/8/21.
//
#ifndef EAGLE0_UNDEADCHANGEACTIONFACTORY_HPP
#define EAGLE0_UNDEADCHANGEACTIONFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_UNDEAD_CHANGE_ACTION_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_UNDEAD_CHANGE_ACTION_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
@@ -16,10 +16,10 @@ private:
const SettingsGetter settings;
public:
explicit UndeadChangeActionFactory(const SettingsGetter &getter) : settings(getter){};
explicit UndeadChangeActionFactory(const SettingsGetter &getter) : settings(getter) {}
[[nodiscard]] auto MakeUndeadChangeAction(const GameStateW &gameState) const -> ActionSPtr;
};
} // namespace shardok
#endif // EAGLE0_UNDEADCHANGEACTIONFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_FACTORIES_UNDEAD_CHANGE_ACTION_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 9/6/20.
//
#ifndef EAGLE0_ACTIONPOINTDISTANCES_HPP
#define EAGLE0_ACTIONPOINTDISTANCES_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_HPP
#include <future>
#include <optional>
@@ -101,4 +101,4 @@ public:
} // namespace shardok
#endif // EAGLE0_ACTIONPOINTDISTANCES_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_HPP
@@ -12,15 +12,14 @@
#include "src/main/cpp/net/eagle0/shardok/library/fb_helpers/HexMapHelpers.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/HexMapHasher.hpp"
#define CACHE_STATS_LOGGING_ false
#define CACHE_STATS_FREQUENCY_SECONDS_ 1
namespace shardok {
constexpr bool kCacheStatsLogging = false;
constexpr int kCacheStatsFrequencySeconds = 1;
// Thread-local cache definition - stores raw pointers for zero overhead access
thread_local ActionPointDistancesCache::TLSCache ActionPointDistancesCache::tlsCache;
#if CACHE_STATS_LOGGING_
// Thread-local statistics for performance monitoring
thread_local struct {
int persistentHits = 0;
@@ -36,7 +35,7 @@ thread_local struct {
static void MaybePrintCacheStats() {
auto now = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::seconds>(now - cacheStats.lastReportTime).count() >=
CACHE_STATS_FREQUENCY_SECONDS_) {
kCacheStatsFrequencySeconds) {
printf("Thread cache stats: %d persistent hits, %d persistent misses, %d local hits, "
"%d local misses, %d shared accesses, %d eviction events\n",
cacheStats.persistentHits,
@@ -48,7 +47,6 @@ static void MaybePrintCacheStats() {
cacheStats.lastReportTime = now;
}
}
#endif
class BadHashException final : public std::exception {
public:
@@ -133,45 +131,37 @@ auto ActionPointDistancesCache::GetRaw(
// Check the persistent map first
if (auto it = persistentCache.find(cacheKey); it != persistentCache.end()) {
#if CACHE_STATS_LOGGING_
cacheStats.persistentHits++;
MaybePrintCacheStats();
#endif
if (kCacheStatsLogging) {
cacheStats.persistentHits++;
MaybePrintCacheStats();
}
// Return directly from persistent cache without TLS insertion
// This avoids the overhead of thread-local storage operations on hot path
return it->second.sharedPtr.get();
}
#if CACHE_STATS_LOGGING_
cacheStats.persistentMisses++;
#endif
if (kCacheStatsLogging) { cacheStats.persistentMisses++; }
// Check thread-local cache (no locks needed!)
if (auto it = tlsCache.find(cacheKey); it != tlsCache.end()) {
#if CACHE_STATS_LOGGING_
cacheStats.localHits++;
MaybePrintCacheStats();
#endif
if (kCacheStatsLogging) {
cacheStats.localHits++;
MaybePrintCacheStats();
}
return it->second.sharedPtr.get(); // Compute raw pointer on demand
}
#if CACHE_STATS_LOGGING_
cacheStats.localMisses++;
#endif
if (kCacheStatsLogging) { cacheStats.localMisses++; }
// Check shared cache before expensive ice-clearing operation
shared_ptr<ActionPointDistances> sharedResult;
if (sharedDistances.if_contains(cacheKey, [&sharedResult](const auto& kv) {
sharedResult = kv.second;
})) {
#if CACHE_STATS_LOGGING_
cacheStats.sharedAccesses++;
#endif
if (kCacheStatsLogging) { cacheStats.sharedAccesses++; }
// Cache hit in shared cache - store in thread-local cache and return
tlsCache.emplace(cacheKey, CacheEntry(sharedResult));
#if CACHE_STATS_LOGGING_
MaybePrintCacheStats();
#endif
if (kCacheStatsLogging) { MaybePrintCacheStats(); }
return sharedResult.get();
}
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 10/5/20.
//
#ifndef EAGLE0_ACTIONPOINTDISTANCESCACHE_HPP
#define EAGLE0_ACTIONPOINTDISTANCESCACHE_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_CACHE_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_CACHE_HPP
#include <shared_mutex>
#include <unordered_map>
@@ -123,4 +123,4 @@ using APDCache = shared_ptr<ActionPointDistancesCache>;
} // namespace shardok
#endif // EAGLE0_ACTIONPOINTDISTANCESCACHE_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_ACTION_POINT_DISTANCES_CACHE_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 10/13/22.
//
#ifndef EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP
#define EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_FIXED_ACTION_POINT_DISTANCES_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_FIXED_ACTION_POINT_DISTANCES_HPP
#include <utility>
#include <vector>
@@ -44,4 +44,4 @@ public:
} // namespace shardok
#endif // EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_POINT_DISTANCES_FIXED_ACTION_POINT_DISTANCES_HPP
@@ -44,5 +44,5 @@ auto main(int argc, char** argv) -> int {
}
const auto end = system_clock::now();
std::cerr << duration_cast<microseconds>(end - start).count() << " µs" << std::endl;
std::cerr << duration_cast<microseconds>(end - start).count() << " µs" << '\n';
}
@@ -8,6 +8,8 @@
#include "src/main/cpp/net/eagle0/shardok/library/action_result_applier/ActionResultApplier.hpp"
#include <string>
#include "src/main/cpp/net/eagle0/shardok/library/action_result_applier/GameStateCopier.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_result_applier/UnitHelpers.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/HexMapHasher.hpp"
@@ -29,6 +31,11 @@ using Unit = net::eagle0::shardok::storage::fb::Unit;
inline auto GetMutableUnit(GameState *state, UnitId unitId) -> Unit * {
return const_cast<Unit *>(state->mutable_units()->GetMutableObject(unitId));
}
inline auto UnitFromBytes(const std::string &unitBytes) -> const Unit & {
return *reinterpret_cast<const Unit *>(unitBytes.data());
}
using net::eagle0::shardok::storage::fb::VictoryCondition;
using net::eagle0::shardok::storage::fb::VictoryType;
@@ -86,7 +93,7 @@ void ApplyResolvedUnit(
const SettingsGetter &settingsGetter) {
ApplyResolvedUnit(
inoutState,
*((Unit *)resolvedUnit.unit_bytes().data()),
UnitFromBytes(resolvedUnit.unit_bytes()),
static_cast<net::eagle0::shardok::storage::fb::UnitStatus>(resolvedUnit.status()),
vipCapturedMoraleAdjustment,
settingsGetter);
@@ -96,7 +103,7 @@ void ApplyResolvedUnit(
GameStateT &inoutState,
const ResolvedUnitProto &resolvedUnit,
const double vipCapturedMoraleAdjustment) {
const Unit &unit = *((Unit *)resolvedUnit.unit_bytes().data());
const Unit &unit = UnitFromBytes(resolvedUnit.unit_bytes());
UnitId unitId = unit.unit_id();
if (unit.has_attached_hero() &&
@@ -139,7 +146,7 @@ void ApplyResolvedUnit(
std::erase_if(inoutState.units, [unitId](const auto &unit) {
return unit.unit_id() == unitId;
});
inoutState.units[unitId] = *((Unit *)resolvedUnit.unit_bytes().data());
inoutState.units[unitId] = UnitFromBytes(resolvedUnit.unit_bytes());
inoutState.units[unitId].mutate_status(
static_cast<net::eagle0::shardok::storage::fb::UnitStatus>(resolvedUnit.status()));
}
@@ -164,7 +171,7 @@ void MutatingAddUnits(GameStateW &mutatingState, const ActionResultProto &result
// First pass: check what kind of modifications we need
for (const auto &unitBytes : result.changed_units_fb()) {
const auto *unit = (Unit *)unitBytes.data();
const auto *unit = &UnitFromBytes(unitBytes);
maxChangedUnitId = std::max(maxChangedUnitId, unit->unit_id());
if (static_cast<unsigned int>(unit->unit_id()) >= mutatingState->units()->size()) {
@@ -194,7 +201,7 @@ void MutatingAddUnits(GameStateW &mutatingState, const ActionResultProto &result
// Convert reserved slots to real units in place
// We only need to process the units that are being changed
for (const auto &unitBytes : result.changed_units_fb()) {
const auto *unit = (Unit *)unitBytes.data();
const auto *unit = &UnitFromBytes(unitBytes);
auto *mutableUnit = GetMutableUnit(mutatingState.Get(), unit->unit_id());
if (mutableUnit->status() ==
net::eagle0::shardok::storage::fb::UnitStatus_RESERVED_SLOT) {
@@ -293,7 +300,7 @@ void MutatingApplyResult(
const double vipCapturedMoraleAdjustment = settings.Backing().vip_captured_morale_adjustment();
for (const auto &changedUnitBytes : result.changed_units_fb()) {
const Unit *changedUnit = (Unit *)changedUnitBytes.data();
const Unit *changedUnit = &UnitFromBytes(changedUnitBytes);
if (changedUnit->battalion().type() ==
net::eagle0::shardok::storage::fb::BattalionTypeId_UNDEAD &&
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 11/9/22.
//
#ifndef EAGLE0_GAMESTATECOPIER_HPP
#define EAGLE0_GAMESTATECOPIER_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_GAME_STATE_COPIER_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_GAME_STATE_COPIER_HPP
#include "src/main/cpp/net/eagle0/shardok/library/GameStateW.hpp"
@@ -13,4 +13,4 @@ auto CopyWithExtraUnits(const GameStateW& original, int additionalCount) -> Game
} // namespace shardok
#endif // EAGLE0_GAMESTATECOPIER_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_GAME_STATE_COPIER_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 11/4/21.
//
#ifndef EAGLE0_UNITHELPERS_HPP
#define EAGLE0_UNITHELPERS_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_UNIT_HELPERS_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_UNIT_HELPERS_HPP
#include "src/main/flatbuffer/net/eagle0/shardok/storage/unit.hpp"
@@ -18,4 +18,4 @@ auto ApplyUnit(
} // namespace shardok::fb
#endif // EAGLE0_UNITHELPERS_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTION_RESULT_APPLIER_UNIT_HELPERS_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 5/17/20.
//
#ifndef EAGLE0_ACTIONREQUIRESHEROEXCEPTION_HPP
#define EAGLE0_ACTIONREQUIRESHEROEXCEPTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_ACTION_REQUIRES_HERO_EXCEPTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_ACTION_REQUIRES_HERO_EXCEPTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokException.hpp"
@@ -17,4 +17,4 @@ public:
} // namespace shardok
#endif // EAGLE0_ACTIONREQUIRESHEROEXCEPTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_ACTION_REQUIRES_HERO_EXCEPTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/14/20.
//
#ifndef EAGLE0_DEFENSIVEAMBUSHACTION_HPP
#define EAGLE0_DEFENSIVEAMBUSHACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_DEFENSIVE_AMBUSH_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_DEFENSIVE_AMBUSH_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/util/CombatUtils.hpp"
@@ -31,4 +31,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_DEFENSIVEAMBUSHACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_DEFENSIVE_AMBUSH_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 11/25/20.
//
#ifndef EAGLE0_ENDPLAYERSETUPCOMMAND_HPP
#define EAGLE0_ENDPLAYERSETUPCOMMAND_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_END_PLAYER_SETUP_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_END_PLAYER_SETUP_COMMAND_HPP
#include <optional>
#include <utility>
@@ -35,7 +35,7 @@ public:
: ShardokCommand(playerId),
nextPid(nextPid),
gameState(gameState),
settings(settingsGetter){};
settings(settingsGetter) {}
~EndPlayerSetupCommand() override = default;
@@ -47,4 +47,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_ENDPLAYERSETUPCOMMAND_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_END_PLAYER_SETUP_COMMAND_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2/16/21.
//
#ifndef EAGLE0_ICEADJUSTMENTACTION_HPP
#define EAGLE0_ICEADJUSTMENTACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_ICE_ADJUSTMENT_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_ICE_ADJUSTMENT_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -38,4 +38,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_ICEADJUSTMENTACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_ICE_ADJUSTMENT_ACTION_HPP
@@ -67,7 +67,7 @@ private:
public:
MeteorCastAction(vector<UnitId> actors, const SettingsGetter& settings)
: actorIds(std::move(actors)),
settings(settings){};
settings(settings) {}
};
} // namespace shardok
@@ -29,7 +29,7 @@ NewRoundAction::NewRoundAction(
iceAdjustmentActionFactory(
iceAdjustFact ?: std::make_shared<IceAndSnowAdjustmentActionFactory>(settings)),
undeadGrewActionFactory(
undeadGrewFact ?: std::make_shared<UndeadChangeActionFactory>(settings)){};
undeadGrewFact ?: std::make_shared<UndeadChangeActionFactory>(settings)) {}
auto ConditionsByMonth(
const net::eagle0::shardok::storage::fb::MonthlyWeather &monthlyWeather,
@@ -230,4 +230,4 @@ auto NewRoundAction::InternalExecute(
return results;
}
} // namespace shardok
} // namespace shardok
@@ -6,8 +6,8 @@
// Copyright © 2020 Dan Crosby. All rights reserved.
//
#ifndef NEW_ROUND_ACTION_HPP
#define NEW_ROUND_ACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_NEW_ROUND_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_NEW_ROUND_ACTION_HPP
#include <utility>
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/4/20.
//
#ifndef EAGLE0_PERFORMUNDEADCOMMANDSACTION_HPP
#define EAGLE0_PERFORMUNDEADCOMMANDSACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_PERFORM_UNDEAD_COMMANDS_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_PERFORM_UNDEAD_COMMANDS_ACTION_HPP
#include <utility>
@@ -29,8 +29,8 @@ public:
: startingGameState(gameState),
settings(settingsGetter),
availableCommandsFactory(
AvailableCommandsFactory::MakeAvailableCommandsFactory(settingsGetter)){};
AvailableCommandsFactory::MakeAvailableCommandsFactory(settingsGetter)) {}
};
} // namespace shardok
#endif // EAGLE0_PERFORMUNDEADCOMMANDSACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_PERFORM_UNDEAD_COMMANDS_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 5/30/20.
//
#ifndef EAGLE0_PLACEHIDDENUNITCOMMAND_HPP
#define EAGLE0_PLACEHIDDENUNITCOMMAND_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_HIDDEN_UNIT_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_HIDDEN_UNIT_COMMAND_HPP
#include <optional>
#include <utility>
@@ -36,7 +36,7 @@ public:
: ShardokCommand(playerId),
actorId(actorId),
target(target),
minimumKnowledge(minimumKnowledge){};
minimumKnowledge(minimumKnowledge) {}
~PlaceHiddenUnitCommand() override = default;
@@ -52,4 +52,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_PLACEHIDDENUNITCOMMAND_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_HIDDEN_UNIT_COMMAND_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 5/30/20.
//
#ifndef EAGLE0_PLACEUNITCOMMAND_HPP
#define EAGLE0_PLACEUNITCOMMAND_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_UNIT_COMMAND_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_UNIT_COMMAND_HPP
#include <utility>
@@ -29,7 +29,7 @@ public:
PlaceUnitCommand(const Unit* actor, const Coords target)
: ShardokCommand(actor->player_id()),
actor(actor),
target(target){};
target(target) {}
~PlaceUnitCommand() override = default;
@@ -45,4 +45,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_PLACEUNITCOMMAND_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_PLACE_UNIT_COMMAND_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 2/23/21.
//
#ifndef EAGLE0_SNOWADJUSTMENTACTION_HPP
#define EAGLE0_SNOWADJUSTMENTACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_SNOW_ADJUSTMENT_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_SNOW_ADJUSTMENT_ACTION_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokAction.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -39,4 +39,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_SNOWADJUSTMENTACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_SNOW_ADJUSTMENT_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/4/20.
//
#ifndef EAGLE0_STARTPLAYERTURNACTION_HPP
#define EAGLE0_STARTPLAYERTURNACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_START_PLAYER_TURN_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_START_PLAYER_TURN_ACTION_HPP
#include <utility>
@@ -35,4 +35,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_STARTPLAYERTURNACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_START_PLAYER_TURN_ACTION_HPP
@@ -15,7 +15,8 @@ auto UndeadChangeAction::InternalExecute(
const std::shared_ptr<RandomGenerator>& /*generator*/) const -> vector<ActionResult> {
if (undeadUnitIds.empty()) return {};
const int maxGrowthPer = (int)(reinforceRate * bodyCount / (double)undeadUnitIds.size());
const int maxGrowthPer =
static_cast<int>(reinforceRate * bodyCount / static_cast<double>(undeadUnitIds.size()));
ActionResult result{};
result.set_type(net::eagle0::shardok::common::UNDEAD_GREW);
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/8/21.
//
#ifndef EAGLE0_UNDEADCHANGEACTION_HPP
#define EAGLE0_UNDEADCHANGEACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_CHANGE_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_CHANGE_ACTION_HPP
#include <utility>
@@ -50,4 +50,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_UNDEADCHANGEACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_CHANGE_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/21/21.
//
#ifndef EAGLE0_UNDEADFROZENACTION_HPP
#define EAGLE0_UNDEADFROZENACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_FROZEN_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_FROZEN_ACTION_HPP
#include <utility>
@@ -26,8 +26,8 @@ private:
const Unit* occupant;
public:
explicit UndeadFrozenAction(const Unit* occupant) : occupant(occupant){};
explicit UndeadFrozenAction(const Unit* occupant) : occupant(occupant) {}
};
} // namespace shardok
#endif // EAGLE0_UNDEADFROZENACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_UNDEAD_FROZEN_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/3/20.
//
#ifndef EAGLE0_UPDATEGAMESTATUSACTION_HPP
#define EAGLE0_UPDATEGAMESTATUSACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_GAME_STATUS_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_GAME_STATUS_ACTION_HPP
#include <utility>
@@ -45,4 +45,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_UPDATEGAMESTATUSACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_GAME_STATUS_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/4/20.
//
#ifndef EAGLE0_UPDATEOPPONENTKNOWLEDGEACTION_HPP
#define EAGLE0_UPDATEOPPONENTKNOWLEDGEACTION_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_OPPONENT_KNOWLEDGE_ACTION_HPP
#define EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_OPPONENT_KNOWLEDGE_ACTION_HPP
#include <utility>
@@ -23,9 +23,9 @@ private:
const SettingsGetter settingsGetter;
public:
UpdateOpponentKnowledgeAction(const SettingsGetter& settingsGetter)
explicit UpdateOpponentKnowledgeAction(const SettingsGetter& settingsGetter)
: settingsGetter(settingsGetter) {}
};
} // namespace shardok
#endif // EAGLE0_UPDATEOPPONENTKNOWLEDGEACTION_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_ACTIONS_UPDATE_OPPONENT_KNOWLEDGE_ACTION_HPP
@@ -2,8 +2,8 @@
// Created by Claude on 3/14/26.
//
#ifndef EAGLE0_BLOWBRIDGECOMMANDFACTORY_HPP
#define EAGLE0_BLOWBRIDGECOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BLOW_BRIDGE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BLOW_BRIDGE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -18,7 +18,7 @@ private:
const SettingsGetter settings;
public:
explicit BlowBridgeCommandFactory(const SettingsGetter& getter) : settings(getter){};
explicit BlowBridgeCommandFactory(const SettingsGetter& getter) : settings(getter) {}
void AddAvailableBlowBridgeCommands(
CommandList& commands,
@@ -34,4 +34,4 @@ public:
} // namespace shardok
#endif // EAGLE0_BLOWBRIDGECOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BLOW_BRIDGE_COMMAND_FACTORY_HPP
@@ -34,9 +34,9 @@ PercentileRollOdds GetBraveWaterOdds(
default: break;
}
const int statFactor =
(int)(agility * settings.Backing().brave_water_agility_factor() +
wisdom * settings.Backing().brave_water_wisdom_factor());
const int statFactor = static_cast<int>(
agility * settings.Backing().brave_water_agility_factor() +
wisdom * settings.Backing().brave_water_wisdom_factor());
const double armamentFactor = armament * settings.Backing().brave_water_armament_factor();
auto otherFactors = vector<OtherFactor>{MakeOtherFactor(armamentFactor, "Armament")};
@@ -139,4 +139,4 @@ void BraveWaterCommandFactory::AddAvailableCommands(
params.units);
}
} // namespace shardok
} // namespace shardok
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/11/20.
//
#ifndef EAGLE0_BRAVEWATERCOMMANDFACTORY_HPP
#define EAGLE0_BRAVEWATERCOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BRAVE_WATER_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BRAVE_WATER_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -40,4 +40,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_BRAVEWATERCOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BRAVE_WATER_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/8/21.
//
#ifndef EAGLE0_BUILDBRIDGECOMMANDFACTORY_HPP
#define EAGLE0_BUILDBRIDGECOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BUILD_BRIDGE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BUILD_BRIDGE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -18,7 +18,7 @@ private:
const SettingsGetter settings;
public:
explicit BuildBridgeCommandFactory(const SettingsGetter& getter) : settings(getter){};
explicit BuildBridgeCommandFactory(const SettingsGetter& getter) : settings(getter) {}
void AddAvailableBuildBridgeCommands(
CommandList& commands,
@@ -34,4 +34,4 @@ public:
} // namespace shardok
#endif // EAGLE0_BUILDBRIDGECOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_BUILD_BRIDGE_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 4/10/20.
//
#ifndef EAGLE0_CHALLENGEDUELCOMMANDFACTORY_HPP
#define EAGLE0_CHALLENGEDUELCOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHALLENGE_DUEL_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHALLENGE_DUEL_COMMAND_FACTORY_HPP
#include <utility>
#include <vector>
@@ -23,7 +23,7 @@ private:
const SettingsGetter settings;
public:
explicit ChallengeDuelCommandFactory(const SettingsGetter &getter) : settings(getter){};
explicit ChallengeDuelCommandFactory(const SettingsGetter &getter) : settings(getter) {}
void AddAvailableChallengeDuelCommands(
CommandList &existingCommands,
@@ -38,4 +38,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_CHALLENGEDUELCOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CHALLENGE_DUEL_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/14/21.
//
#ifndef EAGLE0_COMMANDFACTORIESLIST_HPP
#define EAGLE0_COMMANDFACTORIESLIST_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORIES_LIST_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORIES_LIST_HPP
#include <memory>
#include <vector>
@@ -26,4 +26,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_COMMANDFACTORIESLIST_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORIES_LIST_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/14/21.
//
#ifndef EAGLE0_COMMANDFACTORY_HPP
#define EAGLE0_COMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"
@@ -45,4 +45,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_COMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 6/30/20.
//
#ifndef EAGLE0_CONTROLCOMMANDFACTORY_HPP
#define EAGLE0_CONTROLCOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CONTROL_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CONTROL_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -16,7 +16,7 @@ private:
const SettingsGetter settings;
public:
explicit ControlCommandFactory(const SettingsGetter &getter) : settings(getter){};
explicit ControlCommandFactory(const SettingsGetter &getter) : settings(getter) {}
void AddAvailableCommands(CommandList &commands, const CommandParams &params) const override;
@@ -30,4 +30,4 @@ public:
} // namespace shardok
#endif // EAGLE0_CONTROLCOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_CONTROL_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 5/27/20.
//
#ifndef EAGLE0_EXTINGUISHFIRECOMMANDFACTORY_HPP
#define EAGLE0_EXTINGUISHFIRECOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EXTINGUISH_FIRE_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EXTINGUISH_FIRE_COMMAND_FACTORY_HPP
#include "src/main/cpp/net/eagle0/shardok/library/ShardokCommand.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/command_factories/CommandFactory.hpp"
@@ -17,7 +17,7 @@ private:
const SettingsGetter settings;
public:
explicit ExtinguishFireCommandFactory(const SettingsGetter &getter) : settings(getter){};
explicit ExtinguishFireCommandFactory(const SettingsGetter &getter) : settings(getter) {}
auto AddAvailableExtinguishFireCommands(
CommandList &existingCommands,
@@ -32,4 +32,4 @@ public:
} // namespace shardok
#endif // EAGLE0_EXTINGUISHFIRECOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_EXTINGUISH_FIRE_COMMAND_FACTORY_HPP
@@ -2,8 +2,8 @@
// Created by Dan Crosby on 3/13/21.
//
#ifndef EAGLE0_FEARCOMMANDFACTORY_HPP
#define EAGLE0_FEARCOMMANDFACTORY_HPP
#ifndef EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FEAR_COMMAND_FACTORY_HPP
#define EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FEAR_COMMAND_FACTORY_HPP
#include <utility>
#include <vector>
@@ -22,7 +22,7 @@ private:
const SettingsGetter settings;
public:
explicit FearCommandFactory(const SettingsGetter &getter) : settings(getter){};
explicit FearCommandFactory(const SettingsGetter &getter) : settings(getter) {}
void AddAvailableFearCommands(
CommandList &commands,
@@ -37,4 +37,4 @@ public:
};
} // namespace shardok
#endif // EAGLE0_FEARCOMMANDFACTORY_HPP
#endif // EAGLE0_SHARDOK_LIBRARY_COMMAND_FACTORIES_FEAR_COMMAND_FACTORY_HPP

Some files were not shown because too many files have changed in this diff Show More