public override void Crossover(IChromosome pair)
{
ShortArrayChromosome p = (ShortArrayChromosome)pair;
// check for correct pair
if ((p != null) && (p.length == length))
{
// crossover point
int crossOverPoint = Generator.Random.Next(length - 1) + 1;
// length of chromosome to be crossed
int crossOverLength = length - crossOverPoint;
// temporary array
ushort[] temp = new ushort[crossOverLength];
// copy part of first (this) chromosome to temp
Array.Copy(val, crossOverPoint, temp, 0, crossOverLength);
// copy part of second (pair) chromosome to the first
Array.Copy(p.val, crossOverPoint, val, crossOverPoint, crossOverLength);
// copy temp to the second
Array.Copy(temp, 0, p.val, crossOverPoint, crossOverLength);
}
}
}