use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class SimpleGA method fitness.
double fitness(int[] sol) {
if (nSamples == 1)
return evaluator.evaluate(sol);
// otherwise ...
StatSummary ss = new StatSummary();
for (int i = 0; i < nSamples; i++) {
double fitness = evaluator.evaluate(sol);
ss.add(fitness);
}
return ss.mean();
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class AsteroidsSimpleTest method main.
public static void main(String[] args) throws Exception {
StatSummary ss = new StatSummary();
int nTrials = 10;
for (int i = 0; i < nTrials; i++) {
ss.add(runOnce());
System.out.println();
System.out.println("After trial: " + (i + 1));
System.out.println("Total game ticks: " + AsteroidsLinkState.totalGameTicks);
System.out.println("Total game copies: " + AsteroidsLinkState.totalGameCopies);
}
System.out.println(ss);
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class AsteroidsTest method main.
public static void main(String[] args) throws Exception {
StatSummary ss = new StatSummary();
int nTrials = 10;
for (int i = 0; i < nTrials; i++) {
ss.add(runOnce());
System.out.println();
System.out.println("After trial: " + (i + 1));
System.out.println("Total game ticks: " + AsteroidsLinkState.totalGameTicks);
System.out.println("Total game copies: " + AsteroidsLinkState.totalGameCopies);
}
System.out.println(ss);
// System.out.println(Agent.useShiftBuffer);
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class AgentOptTest method runTrial.
public static double runTrial(EvoAlg evoAlg) {
// ok, so the idea here is to modify ...
// SimpleGASearchSpace eval = new SimpleGASearchSpace();
// eval.setEvaluator(new EvalMaxM(50, 2, 0.0));
AgentEvaluator eval = new AgentEvaluator();
int[] solution = evoAlg.runTrial(eval, 10);
// int[] solution = {0, 0, 0};
System.out.println("Checking fitness");
StatSummary ss = new StatSummary("Mean fitness");
int nChecks = 5;
for (int i = 0; i < nChecks; i++) {
ss.add(eval.evaluate(solution));
}
System.out.println(ss);
System.out.println("Solution: " + Arrays.toString(solution));
System.out.println(eval.report(solution));
return ss.mean();
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class GameRunner method runTrials.
public static StatSummary runTrials(SimplePlayerInterface agent, int nTicks, int nTrials) {
StatSummary ss = new StatSummary("Score stats: " + agent.toString());
for (int i = 0; i < nTrials; i++) {
double score = runTrial(agent, nTicks);
System.out.println(i + "\t " + score);
ss.add(score);
}
return ss;
}
Aggregations