GA/Assets/Scripts/World.cs
/// <summary>
/// Returns a chromosome chosen proportionally to its fitness
/// using roulette wheel selection. 
/// </summary>
Returns a chromosome chosen proportionally to its fitness
using roulette wheel selection.
Returns a chromosome chosen proportionally to its fitness using roulette wheel selection .
private Chromosome Select() {
        float num = Random.Range(0f, fitnessSum);
        float sum = 0f;
        for (int i = 0; i < population.Count; i++) {
            sum += population[i].fitness;
            if (sum > num) {
                return population[i];
            }
        }
        return null;
    }
private Chromosome Select ( ) { float num = Random . Range ( 0f , fitnessSum ) ; float sum = 0f ; for ( int i = 0 ; i < population . Count ; i ++ ) { sum += population [ i ] . fitness ; if ( sum > num ) { return population [ i ] ; } } return null ; }
Returns a chromosome chosen proportionally to its fitness
using roulette wheel selection.
Returns a chromosome chosen proportionally to its fitness using roulette wheel selection .