+ " in generation: " + lastImprovementInGeneration + ".");
for (int i = 0; i < population.length; i++) {
env.resetEnvironment();
System.out.println(i + ": " + population[i].toString());
EvolvableBoxAgent3D agent = EvolvableBoxAgent3DGenomeHandler
.createAgentFromGenome(0, null, env,
population[i].toString());
env.addAgent(agent);
currentAgents.add(agent);
// Drop agent
env.stepPhysicalSimulationBy10Seconds();
// Start fitness measurement
agent.setFitnessRelevantStartingPosition();
// 600 steps à 2*1/60s --> 600 * 1/30s = 20s
for (int j = 0; j < numberOf60HertzSteps; j++) {
//env.stepPhysicalSimulationAt60Hertz();
env.step(simZyk);
if (j % whichStepToThinkAt == 0) {
agent.getBrain().decideAndReact(simZyk);
}
}
System.out.println("Fitness: " + agent.getFitness());
if (agent.getFitness() > highestFitnessSoFar) {
elitistGenomes.add(EvolvableBoxAgent3DGenomeHandler
.parseGenomeFromString(agent.getGenome().toString()));
highestFitnessSoFar = agent.getFitness();
lastImprovementInGeneration = simZyk.getLastTick();
}
env.removeAgent(0);
env.resetEnvironment();
}
/*
if (simZyk.getLastTick() % 20 == 0) {
EvolvableBoxAgent3DGenomeHandler.savePopulationToFile(params.getParWertInt("sameParamsId")
+ File.separator + fileName + "_" + params.getParWertInt("sameParamsId")
+ "_pop_at_" + simZyk.getLastTick(), population, params);
}*/
statistics.logToFiles(currentAgents, simZyk, highestFitnessSoFar);
if (simZyk.getLastTick() == params.getParValueLong("simulationlength")) {
EvolvableBoxAgent3DGenomeHandler.savePopulationToFile(params.getParValueInt("sameParamsId")
+ File.separator + fileName + "_" + params.getParValueString("folderName").toString()
+ "_"+ params.getParValueInt("sameParamsId")
+ "_finalpopulation", population, params);
EvolvableBoxAgent3DGenome championGenome = EvolvableBoxAgent3DGenomeHandler.parseGenomeFromString(Collections.max(currentAgents).getGenome().toString());
env.resetEnvironment();
EvolvableBoxAgent3D championAgent = EvolvableBoxAgent3DGenomeHandler
.createAgentFromGenome(0, null, env,
championGenome);
env.addAgent(championAgent);
// Drop agent
env.stepPhysicalSimulationBy10Seconds();
// Start fitness measurement
championAgent.setFitnessRelevantStartingPosition();
EvolvableBoxAgent3DTrack track = new EvolvableBoxAgent3DTrack(championAgent);
// example: 600 steps à 2*1/60s --> 600 * 1/30s = 20s
for (int j = 0; j < numberOf60HertzSteps; j++) {
track.addTrackPoint();
//env.stepPhysicalSimulationAt60Hertz();
env.step(simZyk);
if (j % whichStepToThinkAt == 0) {
championAgent.getBrain().decideAndReact(simZyk);
}
}
EvolvableBoxAgent3DLogger.saveTrackAsPng(track,params);
env.removeAgent(0);