blob: 3919914d19b7e43de7702bf96bdb22f82df2294f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include "SimFitness.hpp"
void SimFitness::updateSpecs()
{
for (auto &i : guppies)
{
i.update();
}
if (!guppieCount)
{
unsigned soul = 0;
for (auto &i : guppies)
{
population->setFitness(currentPopulation * prms.popSize + soul, (unsigned)i.fitness);
++soul;
}
++currentPopulation;
if (currentPopulation == prms.popQtty)
{
population->roulleteWheel();
currentPopulation = 0;
++currentGeneration;
}
unsigned index = 0;
for (auto &i : guppies)
{
i.clean();
i.create();
i.neuralNet->setChromosome(population->getChromosome(currentPopulation * prms.popSize + index));
++index;
}
text.currentPop.setString("Current population: " + nts(currentPopulation + 1) + " / " + nts(prms.popQtty));
text.currentGen.setString("Current generation: " + nts(currentGeneration + 1));
}
}
|