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.
| 38 | // layers, then create a new population in the peeps container with random |
| 39 | // locations and genomes derived from the container of parent genomes. |
| 40 | void 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 |
no test coverage detected