private Gene <char> NewRandomGene(int i) { Gene <char> rs; rs = new Gene <char>(i) { Val = Chars[RandomInst.Next(Chars.Length)] }; return(rs); }
public override void MutateGene(Gene <char> targetGene) { int newIndex; newIndex = Chars.IndexOf(targetGene.Val); newIndex += RandomInst.Next(-MutationRange, MutationRange); if (newIndex < 0) { newIndex += Chars.Length; } else if (newIndex >= Chars.Length) { newIndex -= Chars.Length; } targetGene.Val = Chars[newIndex]; }
public override void MutateGene(Gene <int> targetGene) { targetGene.Val += RandomInst.Next(-MutationRange, MutationRange); }