Created
February 19, 2013 10:40
-
-
Save yetanotherchris/4984775 to your computer and use it in GitHub Desktop.
GA1: GenomeComparer class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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