GA/Assets/Scripts/Chromosome.cs
/// <summary>
/// Returns the total length of the route between all cities.
/// </summary>
Returns the total length of the route between all cities.
Returns the total length of the route between all cities .
public float GetDistance() {
        var distance = 0f;
        for (int i = 0; i < dna.Count; i++) {
            if (i == dna.Count - 1) {
                distance += dna[i].GetDistance(dna[0]);
            } else {
                distance += dna[i].GetDistance(dna[i+1]);
            }
        }
        return distance;
    }
public float GetDistance ( ) { var distance = 0f ; for ( int i = 0 ; i < dna . Count ; i ++ ) { if ( i == dna . Count - 1 ) { distance += dna [ i ] . GetDistance ( dna [ 0 ] ) ; } else { distance += dna [ i ] . GetDistance ( dna [ i + 1 ] ) ; } } return distance ; }
Returns the total length of the route between all cities.
Returns the total length of the route between all cities .