예제 #1
0
        private Gene <char> NewRandomGene(int i)
        {
            Gene <char> rs;

            rs = new Gene <char>(i)
            {
                Val = Chars[RandomInst.Next(Chars.Length)]
            };
            return(rs);
        }
예제 #2
0
        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];
        }
예제 #3
0
 public override void MutateGene(Gene <int> targetGene)
 {
     targetGene.Val += RandomInst.Next(-MutationRange, MutationRange);
 }