private void MakeChildren()
{
Parallel.For(
0,
this.Species.Length,
i =>
{
var temp = new List<Creature>(this.Species[i].Count << 1);
// Random parents (of same species) - for supporting different genes
this.Species[i].Shuffle();
var rnd = RandomProvider.GetThreadRandom();
for (var j = 1; j < this.Species[i].Count; j += 2)
{
var value = rnd.NextDouble();
if (value < 0.33)
{
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
}
else if (value < 0.665)
{
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
}
else
{
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
temp.Add(new Creature(this.Species[i][j - 1], this.Species[i][j]));
}
}
this.Species[i].ForEach(creature => creature.BreakRedundantConnections());
this.Species[i].Clear();
this.Species[i] = temp;
});
}