Example #1
0
bool Simulation::solve(Population &population) {
    bool solution = population.checkForWinner();
    unsigned int p5 = config.simulationNumber / 100 * 5;
    for (; _currentGeneration < config.simulationNumber + 1 && solution == false; ++_currentGeneration) {
        population.reproduce();
        solution = population.checkForWinner();
        // print information about the current population each 5% of generation
        if (config.verbose && _currentGeneration % p5 == 0)
            printResume(population);
    }
    return solution;
}