// Path: src/main/java/ch/idsia/benchmark/tasks/LearningTask.java
// public class LearningTask extends BasicTask implements Task
// {
// private static final long EVALUATION_QUOTA = 100000;
// private long currentEvaluation = 0;
// public int uid;
// 
// private String fileTimeStamp = "-uid-" + uid + "-" + GlobalOptions.getTimeStamp();
// private int fitnessEvaluations = 0;
// 
// public LearningTask(MarioAIOptions marioAIOptions)
// {
//     super(marioAIOptions);
// }
// 
// public void reset(MarioAIOptions marioAIOptions)
// {
//     options = marioAIOptions;
//     environment.reset(marioAIOptions);
// }
// 
// public int evaluate(Agent agent)
// {
//     if (currentEvaluation++ > EVALUATION_QUOTA)
//         return 0;
//     options.setAgent(agent);
//     environment.reset(options);
//     fitnessEvaluations++; // TODO : remove either or two currentEvaluation or fitnessEvaluations
//     this.runSingleEpisode(1);
//     return this.getEvaluationInfo().computeWeightedFitness();
// }
// 
// public static long getEvaluationQuota()
// {return LearningTask.EVALUATION_QUOTA;}
// 
// public void dumpFitnessEvaluation(float fitness, String fileName)
// {
//     try
//     {
//         BufferedWriter out = new BufferedWriter(new FileWriter(fileName + fileTimeStamp + ".txt", true));
//         out.write(this.fitnessEvaluations + " " + fitness + "\n");
//         out.close();
//     } catch (IOException e)
//     {
//         e.printStackTrace();
//     }
// }
// 
// }
// 
// Path: src/main/java/ch/idsia/benchmark/tasks/Task.java
// public interface Task
// {
// public int evaluate(final Agent controller);
// 
// public void setOptionsAndReset(final MarioAIOptions options);
// 
// public void setOptionsAndReset(final String options);
// 
// void reset();
// 
// void doEpisodes(final int amount, final boolean verbose, final int repetitionsOfSingleEpisode);
// 
// boolean isFinished();
// 
// public String getName();
// 
// public void printStatistics();
// }


import ch.idsia.benchmark.tasks.Task;
import ch.idsia.evolution.ea.ES;
import ch.idsia.agents.learning.MediumSRNAgent;
import ch.idsia.benchmark.mario.environments.Environment;
import ch.idsia.benchmark.tasks.LearningTask;
{
    this.currentEvaluation++;

    int localBestScore = 0;

    for (int gen = 0; gen < generations; gen++)
    {
        System.out.println(gen + " generation");
        es.nextGeneration();
        float fitn = es.getBestFitnesses()[0];

        if (fitn > bestScore)
        {
            bestScore = fitn;
            bestAgent = (Agent) es.getBests()[0];
        }
    }
}

public void giveReward(float r)
{
}

public void newEpisode()
{
    task = null;
    agent.reset();
}


// Path: src/main/java/ch/idsia/benchmark/tasks/LearningTask.java
// public class LearningTask extends BasicTask implements Task
// {
// private static final long EVALUATION_QUOTA = 100000;
// private long currentEvaluation = 0;
// public int uid;
// 
// private String fileTimeStamp = "-uid-" + uid + "-" + GlobalOptions.getTimeStamp();
// private int fitnessEvaluations = 0;
// 
// public LearningTask(MarioAIOptions marioAIOptions)
// {
//     super(marioAIOptions);
// }
// 
// public void reset(MarioAIOptions marioAIOptions)
// {
//     options = marioAIOptions;
//     environment.reset(marioAIOptions);
// }
// 
// public int evaluate(Agent agent)
// {
//     if (currentEvaluation++ > EVALUATION_QUOTA)
//         return 0;
//     options.setAgent(agent);
//     environment.reset(options);
//     fitnessEvaluations++; // TODO : remove either or two currentEvaluation or fitnessEvaluations
//     this.runSingleEpisode(1);
//     return this.getEvaluationInfo().computeWeightedFitness();
// }
// 
// public static long getEvaluationQuota()
// {return LearningTask.EVALUATION_QUOTA;}
// 
// public void dumpFitnessEvaluation(float fitness, String fileName)
// {
//     try
//     {
//         BufferedWriter out = new BufferedWriter(new FileWriter(fileName + fileTimeStamp + ".txt", true));
//         out.write(this.fitnessEvaluations + " " + fitness + "\n");
//         out.close();
//     } catch (IOException e)
//     {
//         e.printStackTrace();
//     }
// }
// 
// }
// 
// Path: src/main/java/ch/idsia/benchmark/tasks/Task.java
// public interface Task
// {
// public int evaluate(final Agent controller);
// 
// public void setOptionsAndReset(final MarioAIOptions options);
// 
// public void setOptionsAndReset(final String options);
// 
// void reset();
// 
// void doEpisodes(final int amount, final boolean verbose, final int repetitionsOfSingleEpisode);
// 
// boolean isFinished();
// 
// public String getName();
// 
// public void printStatistics();
// }


// Path: src/main/java/ch/idsia/agents/SRNESLearningAgent.java
import ch.idsia.benchmark.tasks.Task;
import ch.idsia.evolution.ea.ES;
import ch.idsia.agents.learning.MediumSRNAgent;
import ch.idsia.benchmark.mario.environments.Environment;
import ch.idsia.benchmark.tasks.LearningTask;

{
    this.currentEvaluation++;

    int localBestScore = 0;

    for (int gen = 0; gen < generations; gen++)
    {
        System.out.println(gen + " generation");
        es.nextGeneration();
        float fitn = es.getBestFitnesses()[0];

        if (fitn > bestScore)
        {
            bestScore = fitn;
            bestAgent = (Agent) es.getBests()[0];
        }
    }
}

public void giveReward(float r)
{
}

public void newEpisode()
{
    task = null;
    agent.reset();
}


public void setLearningTask(LearningTask learningTask)