@Override
    public void mutate() {
        Population offspring = new Population();
        for (int i = 0; i < population.getSize(); ++i){
            double r;
            synchronized (rng){
                r = rng.nextDouble();
            }
            if (r < PROBABILITY){
                HiffIndividual mutant = new HiffIndividual(population.getIndividual(i));
                int possition;
                synchronized (rng){
                    possition = Math.abs(rng.nextInt()) % mutant.getSize();
                }
                mutant.inverse(possition);
                offspring.addIndividual(mutant);
            } else {
                offspring.addIndividual(new HiffIndividual(population.getIndividual(i)));
            }
        }
        double bestOld = population.getFittest();
        double bestNew = offspring.getFittest();
        if (bestNew > bestOld){
            reward = 1;
            for (int i = 0; i < population.getSize(); ++i){
                population.setIndividual(i, offspring.getIndividual(i));
            }
        } else if (bestNew == bestOld){
//            reward = 0.5;
            reward = 0;
        } else {
            reward = 0;
        }
    }