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

Function initializeGeneration0

src/spawnNewGeneration.cpp:18–32  ·  view source on GitHub ↗

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 at random locations with random genomes.

Source from the content-addressed store, hash-verified

16// This will erase the grid and signal layers, then create a new population in
17// the peeps container at random locations with random genomes.
18void initializeGeneration0()
19{
20 // The grid has already been allocated, just clear and reuse it
21 grid.zeroFill();
22 grid.createBarrier(p.barrierType);
23
24 // The signal layers have already been allocated, so just reuse them
25 signals.zeroFill();
26
27 // Spawn the population. The peeps container has already been allocated,
28 // just clear and reuse it
29 for (uint16_t index = 1; index <= p.population; ++index) {
30 peeps[index].initialize(index, grid.findEmptyLocation(), makeRandomGenome());
31 }
32}
33
34
35// Requires a container with one or more parent genomes to choose from.

Callers 2

spawnNewGenerationFunction · 0.85
simulatorFunction · 0.85

Calls 5

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

Tested by

no test coverage detected