| 262 | } |
| 263 | |
| 264 | bool compareGeometryMutation(std::vector<uint8_t> const& expected, std::vector<uint8_t> const& actual) |
| 265 | { |
| 266 | if (expected.size() != actual.size()) { |
| 267 | return false; |
| 268 | } |
| 269 | auto expectedGenome = GenomeDescriptionService::get().convertBytesToDescription(expected); |
| 270 | auto actualGenome = GenomeDescriptionService::get().convertBytesToDescription(actual); |
| 271 | if (expectedGenome.cells.size() != actualGenome.cells.size()) { |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | auto createCompareClone = [](CellGenomeDescription const& cell) { |
| 276 | auto clone = cell; |
| 277 | clone.referenceAngle = 0; |
| 278 | clone.numRequiredAdditionalConnections = 0; |
| 279 | if (clone.getCellFunctionType() == CellFunction_Constructor) { |
| 280 | auto& constructor = std::get<ConstructorGenomeDescription>(*clone.cellFunction); |
| 281 | if (!constructor.isMakeGenomeCopy()) { |
| 282 | constructor.genome = {}; |
| 283 | } |
| 284 | } |
| 285 | if (clone.getCellFunctionType() == CellFunction_Injector) { |
| 286 | auto& injector = std::get<InjectorGenomeDescription>(*clone.cellFunction); |
| 287 | if (!injector.isMakeGenomeCopy()) { |
| 288 | injector.genome = {}; |
| 289 | } |
| 290 | } |
| 291 | return clone; |
| 292 | }; |
| 293 | |
| 294 | for (auto const& [expectedCell, actualCell] : boost::combine(expectedGenome.cells, actualGenome.cells)) { |
| 295 | if (createCompareClone(expectedCell) != createCompareClone(actualCell)) { |
| 296 | return false; |
| 297 | } |
| 298 | if (expectedCell.getCellFunctionType() == CellFunction_Constructor) { |
| 299 | auto expectedConstructor = std::get<ConstructorGenomeDescription>(*expectedCell.cellFunction); |
| 300 | auto actualConstructor = std::get<ConstructorGenomeDescription>(*actualCell.cellFunction); |
| 301 | if (expectedConstructor.isMakeGenomeCopy() != actualConstructor.isMakeGenomeCopy()) { |
| 302 | return false; |
| 303 | } |
| 304 | if (!expectedConstructor.isMakeGenomeCopy()) { |
| 305 | if (!compareGeometryMutation(expectedConstructor.getGenomeData(), actualConstructor.getGenomeData())) { |
| 306 | return false; |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | if (expectedCell.getCellFunctionType() == CellFunction_Injector) { |
| 311 | auto expectedInjector = std::get<InjectorGenomeDescription>(*expectedCell.cellFunction); |
| 312 | auto actualInjector = std::get<InjectorGenomeDescription>(*actualCell.cellFunction); |
| 313 | if (expectedInjector.isMakeGenomeCopy() != actualInjector.isMakeGenomeCopy()) { |
| 314 | return false; |
| 315 | } |
| 316 | if (!expectedInjector.isMakeGenomeCopy()) { |
| 317 | if (!compareGeometryMutation(expectedInjector.getGenomeData(), actualInjector.getGenomeData())) { |
| 318 | return false; |
| 319 | } |
| 320 | } |
| 321 | } |
nothing calls this directly
no test coverage detected