src/main/java/ch/frostnova/ai/genetic/Population.java
public void evolve() {

        List<G> nextGeneration = new ArrayList<>(population.size());

        int surviving = (int) (rulesOfLife.getSurvivingRate() * population.size());
        int reproducing = (int) (rulesOfLife.getReproducingRate() * population.size());

        // add survivors
        for (int i = 0; i < surviving; i++) {
            nextGeneration.add(population.get(i));
        }

        // reproduce until population is full again
        while (nextGeneration.size() < population.size()) {

            // pick two mates
            G first = population.get(randomGamma(0, reproducing, rulesOfLife.getMatingGamma()));
            G second = population.get(randomGamma(0, reproducing, rulesOfLife.getMatingGamma()));
            if (first != second) {
                G offspring = first.crossover(second).mutate();
                nextGeneration.add(offspring);
            }
        }

        Map<G, Double> newFitness = new HashMap<>();
        for (G genom : nextGeneration) {
            newFitness.put(genom, fitness.get(genom));
        }
        fitness = newFitness;
        population = nextGeneration;

        population.stream().parallel().forEach(genom -> fitnessOf(genom));

        population.sort(fitnessComparator);
        generation++;
    }
/**
     * Evolve the population: some members survive, some die, population number is kept constant using reproduction
     * (crossover with mutation) of the members. Survival, death and reproduction are driven by the <b>fitness</b> and
     * <b>destiny</b> (accidents and lucky incidents may happen, such are the rules of life).
     */
Evolve the population: some members survive, some die, population number is kept constant using reproduction
(crossover with mutation) of the members. Survival, death and reproduction are driven by the fitness and
destiny (accidents and lucky incidents may happen, such are the rules of life).
Evolve the population : some members survive some die population number is kept constant using reproduction ( crossover with mutation ) of the members . Survival death and reproduction are driven by the fitness and destiny ( accidents and lucky incidents may happen such are the rules of life ) .
public void evolve() {
        List<G> nextGeneration = new ArrayList<>(population.size());
        int surviving = (int) (rulesOfLife.getSurvivingRate() * population.size());
        int reproducing = (int) (rulesOfLife.getReproducingRate() * population.size());
        for (int i = 0; i < surviving; i++) {
            nextGeneration.add(population.get(i));
        }
        while (nextGeneration.size() < population.size()) {
            G first = population.get(randomGamma(0, reproducing, rulesOfLife.getMatingGamma()));
            G second = population.get(randomGamma(0, reproducing, rulesOfLife.getMatingGamma()));
            if (first != second) {
                G offspring = first.crossover(second).mutate();
                nextGeneration.add(offspring);
            }
        }
        Map<G, Double> newFitness = new HashMap<>();
        for (G genom : nextGeneration) {
            newFitness.put(genom, fitness.get(genom));
        }
        fitness = newFitness;
        population = nextGeneration;
        population.stream().parallel().forEach(genom -> fitnessOf(genom));
        population.sort(fitnessComparator);
        generation++;
    }
public void evolve ( ) { List < G > nextGeneration = new ArrayList < > ( population . size ( ) ) ; int surviving = ( int ) ( rulesOfLife . getSurvivingRate ( ) * population . size ( ) ) ; int reproducing = ( int ) ( rulesOfLife . getReproducingRate ( ) * population . size ( ) ) ; for ( int i = 0 ; i < surviving ; i ++ ) { nextGeneration . add ( population . get ( i ) ) ; } while ( nextGeneration . size ( ) < population . size ( ) ) { G first = population . get ( randomGamma ( 0 , reproducing , rulesOfLife . getMatingGamma ( ) ) ) ; G second = population . get ( randomGamma ( 0 , reproducing , rulesOfLife . getMatingGamma ( ) ) ) ; if ( first != second ) { G offspring = first . crossover ( second ) . mutate ( ) ; nextGeneration . add ( offspring ) ; } } Map < G , Double > newFitness = new HashMap < > ( ) ; for ( G genom : nextGeneration ) { newFitness . put ( genom , fitness . get ( genom ) ) ; } fitness = newFitness ; population = nextGeneration ; population . stream ( ) . parallel ( ) . forEach ( genom -> fitnessOf ( genom ) ) ; population . sort ( fitnessComparator ) ; generation ++ ; }
Evolve the population: some members survive, some die, population number is kept constant using reproduction
 (crossover with mutation) of the members.
Evolve the population : some members survive some die population number is kept constant using reproduction ( crossover with mutation ) of the members .
// add survivors // reproduce until population is full again // pick two mates