Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GA1: GenomeComparer class
namespace GeneticAlgorithm
{
/// <summary>
/// Compares genomes by fitness
/// </summary>
public sealed class GenomeComparer : IComparer<Genome>
{
public int Compare(Genome x, Genome y)
{
if (x.Fitness > y.Fitness)
return 1;
else if (x.Fitness == y.Fitness)
return 0;
else
return -1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment