diff --git a/source/Agents/GP/CGPAgent.hpp b/source/Agents/GP/CGPAgent.hpp index 9063c554..288617a9 100644 --- a/source/Agents/GP/CGPAgent.hpp +++ b/source/Agents/GP/CGPAgent.hpp @@ -88,7 +88,7 @@ namespace cowboys { /// @param doc The XML document to serialize to. /// @param parentElem The parent element to serialize to. /// @param fitness The fitness of this agent to write to the XML. - void Serialize(tinyxml2::XMLDocument &doc, tinyxml2::XMLElement *parentElem, double fitness = -1) override { + void SerializeGP(tinyxml2::XMLDocument &doc, tinyxml2::XMLElement *parentElem, double fitness = -1) override { auto agentElem = doc.NewElement("CGPAgent"); parentElem->InsertEndChild(agentElem); diff --git a/source/Agents/GP/GPAgentBase.hpp b/source/Agents/GP/GPAgentBase.hpp index 88825ebf..3ce9fb8d 100644 --- a/source/Agents/GP/GPAgentBase.hpp +++ b/source/Agents/GP/GPAgentBase.hpp @@ -63,7 +63,7 @@ namespace cowboys { }; - virtual void Serialize(tinyxml2::XMLDocument &doc, tinyxml2::XMLElement *parentElem, double fitness = -1) = 0; + virtual void SerializeGP(tinyxml2::XMLDocument &doc, tinyxml2::XMLElement *parentElem, double fitness = -1) = 0; /// TODO: Might have to remove it virtual std::string Export() { return ""; } @@ -71,7 +71,7 @@ namespace cowboys { virtual void Reset(bool /*hard*/ = false) { extra_state["previous_action"] = 0; }; // virtual void crossover(const GPAgentBase &other) {}; - virtual void Import(const std::string &genotype) {}; + virtual void Import(const std::string &genotype) = 0; // -- Random Number Generation -- diff --git a/source/Agents/GP/GPTrainingLoop.hpp b/source/Agents/GP/GPTrainingLoop.hpp index d18103fc..b3ddd9e3 100644 --- a/source/Agents/GP/GPTrainingLoop.hpp +++ b/source/Agents/GP/GPTrainingLoop.hpp @@ -780,7 +780,7 @@ namespace cowboys { for (size_t i = 0; i < std::min(sortedAgents.size(), topN); ++i) { auto [arenaIDX, agentIDX] = sortedAgents[i]; - agents[arenaIDX][agentIDX]->Serialize(paramDocument, generationTag, TEMPAgentFitness[arenaIDX][agentIDX]); + agents[arenaIDX][agentIDX]->SerializeGP(paramDocument, generationTag, TEMPAgentFitness[arenaIDX][agentIDX]); } diff --git a/source/Agents/GP/LGPAgent.hpp b/source/Agents/GP/LGPAgent.hpp index 5905ffeb..6b09f5b9 100644 --- a/source/Agents/GP/LGPAgent.hpp +++ b/source/Agents/GP/LGPAgent.hpp @@ -285,7 +285,7 @@ namespace cowboys /// @param doc The XML document to serialize to. /// @param parentElem The parent element to serialize to. /// @param fitness The fitness of this agent to write to the XML. - void Serialize(tinyxml2::XMLDocument & doc, tinyxml2::XMLElement* parentElem, double fitness = -1) override + void SerializeGP(tinyxml2::XMLDocument & doc, tinyxml2::XMLElement* parentElem, double fitness = -1) override { auto agentElem = doc.NewElement("LGPAgent"); parentElem->InsertEndChild(agentElem); @@ -299,7 +299,7 @@ namespace cowboys /// @brief Load in the string representation of an LGP agent and configure this agent based on it. /// @param genotype The string representation of an LGP agent. - void Import(std::string encodedLists) { + void Import(const std::string & encodedLists) override { std::vector> decodedInstructionsList = {}; std::string decodedInstruction; size_t start_pos = 0;