/// <summary>
        /// Determines the species in which the given genome is located.
        /// Two genomes are in the same species if their genetic distance
        /// is less than the given compatibility treshold.
        /// </summary>
        private Species GetGenomeSpecies(NEATConfig config, List <Species> species, Genome genome)
        {
            if (species == null)
            {
                return(null);
            }

            foreach (var speciesI in species)
            {
                if (speciesI.Genomes.Count == 0)
                {
                    continue;
                }
                var threshold   = config.speciesCompatibility.threshold;
                var geneticDist = Genome.GeneticDistance(config, genome, speciesI.Representative);

                if (geneticDist <= threshold)
                {
                    return(speciesI);
                }
            }

            return(null);
        }