public static StatisticalSummary test(Agent controller, EvaluationOptions options, int seed) { StatisticalSummary ss = new StatisticalSummary(); int kills = 0; int timeLeft = 0; int marioMode = 0; float marioStatus = 0; for (int i = 0; i < numberOfTrials; i++) { options.setLevelLength(200 + (i * 128) + (seed % (i + 1))); options.setLevelType(i % 3); options.setLevelRandSeed(seed + i); controller.reset(); options.setAgent(controller); Evaluator evaluator = new Evaluator(options); EvaluationInfo result = evaluator.evaluate().get(0); ss.add(result.computeDistancePassed()); kills += result.computeKillsTotal(); timeLeft += result.timeLeft; marioMode += result.marioMode; marioStatus += result.marioStatus; } killsSum += kills; marioStatusSum += marioStatus; timeLeftSum += timeLeft; marioModeSum += marioMode; return ss; }
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(); }