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

Method getNumNodesRecursively

source/EngineInterface/GenomeDescriptionService.cpp:411–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411int GenomeDescriptionService::getNumNodesRecursively(std::vector<uint8_t> const& data, bool includeRepetitions, GenomeEncodingSpecification const& spec)
412{
413 auto genome = convertBytesToDescriptionIntern(data, data.size(), data.size(), spec).genome;
414 auto result = toInt(genome.cells.size());
415 for (auto const& node : genome.cells) {
416 if (auto subgenome = node.getGenome()) {
417 result += getNumNodesRecursively(*subgenome, includeRepetitions, spec);
418 }
419 }
420
421 auto numRepetitions = genome.header.numRepetitions == std::numeric_limits<int>::max() ? 1 : genome.header.numRepetitions;
422 return includeRepetitions ? result * numRepetitions * genome.header.getNumBranches() : result;
423}
424
425int GenomeDescriptionService::getNumRepetitions(std::vector<uint8_t> const& data)
426{

Callers 3

processRequestMethod · 0.80
onCreateSporeMethod · 0.80
processCellGenomeTabMethod · 0.80

Calls 5

toIntFunction · 0.85
sizeMethod · 0.80
getGenomeMethod · 0.80
getNumBranchesMethod · 0.80

Tested by 1

processCellGenomeTabMethod · 0.64