public static double testConfig( TimingAgent controller, EvaluationOptions options, int seed, int level, boolean paused) { options.setLevelDifficulty(level); options.setPauseWorld(paused); StatisticalSummary ss = test(controller, options, seed); double averageTimeTaken = controller.averageTimeTaken(); System.out.printf( "Difficulty %d score %.4f (avg time %.4f)\n", level, ss.mean(), averageTimeTaken); if (averageTimeTaken > 40) { System.out.println( "Maximum allowed average time is 40 ms per time step.\n" + "Controller disqualified"); System.exit(0); } return ss.mean(); }
public static void main(String[] args) { EvaluationOptions options = new CmdLineOptions(new String[0]); options.setNumberOfTrials(1); options.setPauseWorld(false); Evolvable initial = new SimpleMLPAgent(); // RegisterableAgent.registerAgent ((Agent) initial); options.setMaxFPS(true); options.setLevelDifficulty(0); options.setVisualization(false); ProgressTask task = new ProgressTask(options); options.setLevelRandSeed((int) (Math.random() * Integer.MAX_VALUE)); ES es = new ES(task, initial, populationSize); System.out.println("Evolving " + initial + " with task " + task); final String fileName = "evolved" + (int) (Math.random() * Integer.MAX_VALUE) + ".xml"; for (int gen = 0; gen < generations; gen++) { es.nextGeneration(); double bestResult = es.getBestFitnesses()[0]; System.out.println("Generation " + gen + " best " + bestResult); Easy.save(es.getBests()[0], fileName); } Stats.main(new String[] {fileName, "1"}); }