MCPcopy Create free account
hub / github.com/davidrmiller/biosim4 / initializeNewGeneration

Function initializeNewGeneration

src/spawnNewGeneration.cpp:40–54  ·  view source on GitHub ↗

Requires a container with one or more parent genomes to choose from. Called from spawnNewGeneration(). This requires that the grid, signals, and peeps containers have been allocated. This will erase the grid and signal layers, then create a new population in the peeps container with random locations and genomes derived from the container of parent genomes.

Source from the content-addressed store, hash-verified

38// layers, then create a new population in the peeps container with random
39// locations and genomes derived from the container of parent genomes.
40void initializeNewGeneration(const std::vector<Genome> &parentGenomes, unsigned generation)
41{
42 extern Genome generateChildGenome(const std::vector<Genome> &parentGenomes);
43
44 // The grid, signals, and peeps containers have already been allocated, just
45 // clear them if needed and reuse the elements
46 grid.zeroFill();
47 grid.createBarrier(p.barrierType);
48 signals.zeroFill();
49
50 // Spawn the population. This overwrites all the elements of peeps[]
51 for (uint16_t index = 1; index <= p.population; ++index) {
52 peeps[index].initialize(index, grid.findEmptyLocation(), generateChildGenome(parentGenomes));
53 }
54}
55
56
57// At this point, the deferred death queue and move queue have been processed

Callers 1

spawnNewGenerationFunction · 0.85

Calls 5

generateChildGenomeFunction · 0.85
createBarrierMethod · 0.80
findEmptyLocationMethod · 0.80
zeroFillMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected