public static Object[] reprodukcja(ParamSpec ps, Unit[] oldpop) {
        Unit[] newpop = new Unit[oldpop.length];
        int mate1 = 0, mate2 = 0, popsize = oldpop.length;
        String s1 = null,s2 = null;    
        Object[] obj = statystyki(oldpop);
        
        oldpop = (Unit[])obj[0];
        double[] stats = (double[]) obj[1];
        
        double sumfitness = 0;
        for (int j = 0; j < popsize-1; j = j + 2) {
            sumfitness = 0;
            for (int i = 0; i < popsize; i++) {
                sumfitness += oldpop[i].getFx();
            }
            mate1 = wybierz(sumfitness, oldpop);
            s1 = oldpop[mate1].getAllel();
            mate2 = wybierz(sumfitness, oldpop);
            s2 = oldpop[mate2].getAllel();
            Random rand = new Random();
            String[] sNew = null;
            if (rand.nextDouble() < PCROSS) {
                sNew = krzyżuj(s1, s2);
            } else {
                sNew = new String[]{s1, s2};
            }
            Unit unit1 = new Unit(ps, sNew[0],fitFunction);
            Unit unit2 = new Unit(ps, sNew[1],fitFunction);
            newpop[j] = unit1;
            newpop[j + 1] = unit2;
        }
        if(licznikGen<liczbaGen){
	        sbOpis.append("\n---------- GENERACJA " + licznikGen + " ------------\n\n");    
	        for(Unit p : newpop)
	        	sbOpis.append(p.getAllel()+"\n");
        }
        licznikGen++;
        return new Object[]{newpop,stats};
    }