MCPcopy Create free account
hub / github.com/chrxh/alien / compareCellColorMutation

Method compareCellColorMutation

source/EngineTests/MutationTests.cpp:540–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

538 }
539
540 bool compareCellColorMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after, std::set<int> const& allowedColors)
541 {
542 auto beforeGenome = GenomeDescriptionService::get().convertBytesToDescription(before);
543 auto afterGenome = GenomeDescriptionService::get().convertBytesToDescription(after);
544 if (afterGenome.header != beforeGenome.header) {
545 return false;
546 }
547
548 for (auto const& [beforeCell, afterCell] : boost::combine(beforeGenome.cells, afterGenome.cells)) {
549
550 auto beforeCellClone = beforeCell;
551 auto afterCellClone = afterCell;
552 beforeCellClone.color = 0;
553 beforeCellClone.cellFunction = std::nullopt;
554 afterCellClone.color = 0;
555 afterCellClone.cellFunction = std::nullopt;
556 if (beforeCellClone != afterCellClone) {
557 return false;
558 }
559 if (!allowedColors.contains(afterCell.color)) {
560 return false;
561 }
562 if (beforeCell.getCellFunctionType() == CellFunction_Constructor || beforeCell.getCellFunctionType() == CellFunction_Injector) {
563 auto beforeSubGenome = beforeCell.getGenome();
564 auto afterSubGenome = afterCell.getGenome();
565 if (beforeSubGenome && afterSubGenome) {
566 if (!compareCellColorMutation(*beforeSubGenome, *afterSubGenome, allowedColors)) {
567 return false;
568 }
569 }
570 }
571 }
572 return true;
573 }
574
575 bool compareSubgenomeColorMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after, std::set<int> const& allowedColors)
576 {

Callers

nothing calls this directly

Calls 3

getGenomeMethod · 0.80
getCellFunctionTypeMethod · 0.45

Tested by

no test coverage detected