~alexreg/darwindotnet/0.1

« back to all changes in this revision

Viewing changes to Samples/HelloWorld/Genetics.cs

  • Committer: Alex Regueiro
  • Date: 2009-03-14 15:06:18 UTC
  • Revision ID: alexreg@gmail.com-20090314150618-1fcfm2eg8lrgztsc
Made abstract Mutator class generic (added type parameter TCodon).
Minor changes to sample projects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
namespace HelloWorld
8
8
{
9
 
    public class SimpleMutator : Mutator
 
9
    public class SimpleStringMutator : Mutator<StringChromosome>
10
10
    {
11
 
        public SimpleMutator()
 
11
        public SimpleStringMutator()
12
12
            : base()
13
13
        {
14
14
            this.ProbabilityFunction = new Func<Population, double>(pop => 0.020d);
15
15
        }
16
16
 
17
 
        public override object Mutate(Chromosome chromosome, int index, object codon)
 
17
        public override object Mutate(Chromosome<StringChromosome> chromosome, int index, object codon)
18
18
        {
19
19
            return _rand.Next(StringChromosome.Chars.Length);
20
20
        }
21
21
    }
22
22
 
23
 
    public class SimpleRecombinator : Recombinator
 
23
    public class SimpleStringRecombinator : Recombinator
24
24
    {
25
 
        public SimpleRecombinator()
 
25
        public SimpleStringRecombinator()
26
26
            : base()
27
27
        {
28
28
            this.ProbabilityFunction = new Func<Population, double>(pop => 1.00d);