forked from peter-ch/MultiNEAT
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve serialization and its unit tests (#15)
* Improve serialization and unit tests * Remove old commented out code * Restore part of old tests
- Loading branch information
Showing
12 changed files
with
469 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "Genes.h" | ||
|
||
namespace NEAT | ||
{ | ||
|
||
bool operator==(Gene const &lhs, Gene const &rhs) | ||
{ | ||
return lhs.m_Traits == rhs.m_Traits; | ||
} | ||
|
||
std::ostream &operator<<(std::ostream &stream, Gene const &gene) | ||
{ | ||
stream << gene.Serialize(); | ||
return stream; | ||
} | ||
|
||
bool operator==(LinkGene const &lhs, LinkGene const &rhs) | ||
{ | ||
return static_cast<Gene const &>(lhs) == static_cast<Gene const &>(rhs) && | ||
lhs.m_FromNeuronID == rhs.m_FromNeuronID && | ||
lhs.m_ToNeuronID == rhs.m_ToNeuronID && | ||
lhs.m_InnovationID == rhs.m_InnovationID && | ||
lhs.m_IsRecurrent == rhs.m_IsRecurrent && | ||
lhs.m_Weight == rhs.m_Weight; | ||
} | ||
|
||
std::ostream &operator<<(std::ostream &stream, LinkGene const &gene) | ||
{ | ||
stream << gene.Serialize(); | ||
return stream; | ||
} | ||
|
||
bool operator==(NeuronGene const &lhs, NeuronGene const &rhs) | ||
{ | ||
return static_cast<Gene const &>(lhs) == static_cast<Gene const &>(rhs) && | ||
lhs.m_ID == rhs.m_ID && | ||
lhs.m_Type == rhs.m_Type && | ||
lhs.x == rhs.x && | ||
lhs.y == rhs.y && | ||
lhs.m_SplitY == rhs.m_SplitY && | ||
lhs.m_A == rhs.m_A && | ||
lhs.m_B == rhs.m_B && | ||
lhs.m_TimeConstant == rhs.m_TimeConstant && | ||
lhs.m_Bias == rhs.m_Bias && | ||
lhs.m_ActFunction == rhs.m_ActFunction; | ||
} | ||
|
||
std::ostream &operator<<(std::ostream &stream, NeuronGene const &gene) | ||
{ | ||
stream << gene.Serialize(); | ||
return stream; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.