Guest User

Untitled

a guest
Oct 14th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1.         private void GetBreedParents(out Genome<T> parent1, out Genome<T> parent2)
  2.         {
  3.             parent1 = null;
  4.             parent2 = null;
  5.  
  6.             var rand = Global.RandGen.NextDouble();
  7.             if (rand <= 0.6)
  8.             {
  9.                 parent1 = this.Genomes.ElementAt(Global.RandGen.Next(0, (int)(this.Genomes.Count*0.2)));
  10.                 parent2 = this.Genomes.ElementAt(Global.RandGen.Next(0, (int)(this.Genomes.Count*0.2)));
  11.             }
  12.             else if (rand <= 0.7)
  13.             {
  14.                 parent1 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.2), (int)(this.Genomes.Count*0.5)));
  15.                 parent2 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.2), (int)(this.Genomes.Count*0.5)));              
  16.             }
  17.             else if (rand <= 0.8)
  18.             {
  19.                 parent1 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.5), (int)(this.Genomes.Count*0.8)));
  20.                 parent2 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.5), (int)(this.Genomes.Count*0.8)));                
  21.             }
  22.             else if (rand <= 0.9)
  23.             {
  24.                 parent1 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.8), (int)(this.Genomes.Count*1.0)));
  25.                 parent2 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count*0.8), (int)(this.Genomes.Count*1.0)));                
  26.             }
  27.             else
  28.             {
  29.                 parent1 = this.Genomes.ElementAt(Global.RandGen.Next(0, (int)(this.Genomes.Count * 0.2)));
  30.                 parent2 = this.Genomes.ElementAt(Global.RandGen.Next((int)(this.Genomes.Count * 0.8), (int)(this.Genomes.Count * 1.0)));
  31.             }
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment