Esempio n. 1
0
 public void GenerateLineGenePopulation(Engine.RunConfig runConfig)
 {
     for (int i = 0; i < this.numberOfGenes; i++)
     {
         Gene gene = new LineGene(this.targetBitmap.Width, this.targetBitmap.Height, runConfig.MutationRangeMax, runConfig.NumberOfSteps);
         gene.InitRandomly();
         this.genes.Add(gene);
     }
 }
Esempio n. 2
0
        public override Gene Crossover(Gene mate)
        {
            LineGene matePaintGene = (LineGene)mate;
            LineGene childGene     = new LineGene(this.Bitmap.Width, this.Bitmap.Height, this.MutationRangeMax, this.numberOfSeps);

            for (int i = 0; i < this.numberOfSeps; i++)
            {
                Stroke stroke = new Stroke();
                stroke.Paint =
                    Utilities.Random.Next(0, this.MutationRangeMax) == this.MutationNumber ?
                    Stroke.RandomPaint() :
                    (Utilities.Random.Next(0, 100) > 50 ? this.Strokes[i].Paint : matePaintGene.Strokes[i].Paint);
                stroke.Points =
                    Utilities.Random.Next(0, this.MutationRangeMax) == this.MutationNumber ?
                    Stroke.RandomPoints(this.Bitmap.Width, this.Bitmap.Height) :
                    (Utilities.Random.Next(0, 100) > 50 ? this.Strokes[i].Points : matePaintGene.Strokes[i].Points);

                childGene.Strokes.Add(stroke);
            }

            return(childGene);
        }