| 429 | } |
| 430 | |
| 431 | bool compareInsertMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after) |
| 432 | { |
| 433 | auto beforeGenome = GenomeDescriptionService::get().convertBytesToDescription(before); |
| 434 | auto afterGenome = GenomeDescriptionService::get().convertBytesToDescription(after); |
| 435 | if (afterGenome.header != beforeGenome.header) { |
| 436 | return false; |
| 437 | } |
| 438 | std::set<CellGenomeDescription> afterGenomeRollout; |
| 439 | rollout(afterGenome, afterGenomeRollout); |
| 440 | for (auto const& cell : afterGenomeRollout) { |
| 441 | if (std::ranges::find(genomeCellColors, cell.color) == genomeCellColors.end()) { |
| 442 | return false; |
| 443 | } |
| 444 | } |
| 445 | for (auto const& beforeCell : beforeGenome.cells) { |
| 446 | auto matchingAfterCells = afterGenome.cells | std::views::filter([&beforeCell](auto const& afterCell) { |
| 447 | auto beforeCellClone = beforeCell; |
| 448 | auto afterCellClone = afterCell; |
| 449 | beforeCellClone.cellFunction.reset(); |
| 450 | afterCellClone.cellFunction.reset(); |
| 451 | return beforeCellClone == afterCellClone; |
| 452 | }); |
| 453 | if (matchingAfterCells.empty()) { |
| 454 | return false; |
| 455 | } |
| 456 | if (beforeCell.getCellFunctionType() == CellFunction_Constructor || beforeCell.getCellFunctionType() == CellFunction_Injector) { |
| 457 | auto matches = false; |
| 458 | auto beforeSubGenome = beforeCell.getGenome(); |
| 459 | auto beforeIsMakeCopyGenome = beforeCell.isMakeGenomeCopy(); |
| 460 | for (auto const& afterCell : matchingAfterCells) { |
| 461 | auto afterIsMakeCopyGenome = afterCell.isMakeGenomeCopy(); |
| 462 | if (beforeIsMakeCopyGenome && *beforeIsMakeCopyGenome && afterIsMakeCopyGenome && *afterIsMakeCopyGenome) { |
| 463 | matches = true; |
| 464 | break; |
| 465 | } |
| 466 | auto afterSubGenome = afterCell.getGenome(); |
| 467 | if (beforeSubGenome && afterSubGenome) { |
| 468 | matches |= compareInsertMutation(*beforeSubGenome, *afterSubGenome); |
| 469 | } |
| 470 | } |
| 471 | if (!matches) { |
| 472 | return false; |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | return true; |
| 477 | } |
| 478 | |
| 479 | bool compareDeleteMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after) |
| 480 | { |
nothing calls this directly
no test coverage detected