/*public void wypisz() * { * for(int i=0; i<osobnicy.Count(); i++) * { * Console.WriteLine(osobnicy.ElementAt(i).parametry[0].ToString()+ osobnicy.ElementAt(i).parametry[1].ToString() + osobnicy.ElementAt(i).parametry[2].ToString()+ osobnicy.ElementAt(i).parametry[3].ToString() + osobnicy.ElementAt(i).parametry[4].ToString()+ " "+osobnicy.ElementAt(i).mutant.ToString()); * * } * Console.WriteLine(srednia_ocena()); * }*/ public void reproduce() { //Random random = new Random(); List <osobnik> pokolenie2 = osobnicy; int temp = pokolenie2.Count(); for (int i = 0; i < (20 - temp); i++) { osobnik mama = osobnicy.ElementAt(random.Next(0, osobnicy.Count())); osobnik tata = osobnicy.ElementAt(random.Next(0, osobnicy.Count())); osobnik potomek; if (i % 2 == 0) { potomek = new osobnik(tata, mama); } else { potomek = new osobnik(mama, tata); } potomek.mutacja(); pokolenie2.Add(potomek); } //for (int i = 0; i < pokolenie2.Count(); i++) pokolenie2.ElementAt(i).ocena = 0; osobnicy = pokolenie2; }
public osobnik(osobnik tata, osobnik mama) { this.ocena = 0; this.parametry = new Items[3]; this.parametry[0] = tata.parametry[0]; this.parametry[1] = tata.parametry[1]; this.parametry[2] = mama.parametry[2]; }