/// <summary> /// Mates the current instance with the provide parent <see cref="Individual"/>. /// </summary> /// <param name="selectedParent"></param> /// <param name="mutationRate"></param> /// <returns></returns> public override Individual Reproduce(Individual selectedParent, double mutationRate) { int[] childValues = new int[16]; for (int i = 0; i < 8; i++) { childValues[i] = this.Values[i]; childValues[15 - i] = ((Bug)selectedParent).Values[15 - i]; } Bug child = new Bug(); child.Values = childValues; if (_random.Next(0, 100) <= (mutationRate * 100)) { int bitToChange = _random.Next(0, 15); child.Values[bitToChange] = (child.Values[bitToChange] == 1) ? 0 : 1; } return child; }
/// <summary> /// Mates the current instance with the provide parent <see cref="Individual"/>. /// </summary> /// <param name="selectedParent"></param> /// <returns></returns> public virtual Individual Reproduce(Individual selectedParent, double mutationRate) { throw new NotImplementedException("Please implement this method on your derived instance."); }