public List<Organism> crossover(int numForAverageFitness) throws Exception {

        //find number of parents
        int N = this.getOrganisms().size();
        int nParents = (N % 2 == 0) ? N / 2 : N / 2 + 1;
        double mediane = this.findMedianFitness();

        int counter = 0;
        List<Integer> parents = new ArrayList<Integer>();
        while (counter < nParents) {
            int Min = 0, Max = N - 1;
            int randomIndex = Min + (int) (Math.random() * ((Max - Min) + 1));
            if (this.getOrganisms().get(randomIndex).getFitness() >= mediane) {
                if (parents.isEmpty()) {
                    parents.add(randomIndex);
                    counter++;
                } else if (parents.get(parents.size() - 1) != randomIndex) {
                    parents.add(randomIndex);
                    counter++;
                }

            }
        }
        List<Organism> children = new ArrayList<Organism>();
        for (int i = 0; i < parents.size() - 1; i++) {
            Organism offspring = this.makeOffspring(parents.get(i), parents.get(i + 1));
            //i++;
            offspring.countFitnessOut(numForAverageFitness);
            children.add(offspring);
        }
        return children;
    }