Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created February 19, 2013 10:40
Show Gist options
  • Save yetanotherchris/4984775 to your computer and use it in GitHub Desktop.
Save yetanotherchris/4984775 to your computer and use it in GitHub Desktop.
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