}
@Override
public synchronized void runDuringSimulation(EnvironmentEA env, Wink simZyk, ParCollection params) {
super.runDuringSimulation(env, simZyk, params);
XMLAufnLesen aufn = null;
if (simZyk.getLastTick() % Math.round(params.getParValueDouble("saveInterval")) == 0) {
if (filesFinished < storedRuns.length) {
env.removeAllAgents();
String compressedFileName = storedRuns[filesFinished].getPath();
String decompressedFileName = params.getStdDirectory() + File.separator + StaticMethods.datNamOhneHintErw(storedRuns[filesFinished].getPath());
params.log(StaticMethods.LOG_INFO, "This is Trajectory Master at time " + simZyk + ".");
StaticMethods.entpackeDatei(compressedFileName, decompressedFileName, false); // Set to true to delete compressed file.
params.log(StaticMethods.LOG_INFO, "Decompressed '" + compressedFileName + "' to '" + decompressedFileName + "'.");
aufn = new XMLAufnLesen(new File(decompressedFileName), params);
params.log(StaticMethods.LOG_INFO, "Loaded '" + decompressedFileName + "'.");
StaticMethods.deleteDAT(decompressedFileName);
params.log(StaticMethods.LOG_INFO, "Deleted temp files.");
int bestPopNum = findBestPopulationMovingAverage(aufn, 5, storedRuns[filesFinished].getName(), params);
// Starte n Generationen vor der besten Population.
bestPopNum = Math.max(0, bestPopNum - 1);
for (int i = 0; i < aufn.getPop(0).getRobSchnapp().length; i++) {
RobSnapshot robSchnapp = aufn.getPop(bestPopNum).getRobSchnapp()[i];
RobEA rob = new RobEA(i, env, params, env.getRand());
rob.erzeugeAusSequenz(0, robSchnapp.getVStdCodes()[0], null, false);
env.hinzuRobotRand(rob);
// Speichere einen beliebigen (hoffentlich representativen) Roboterautomaten.
if (i == 0) {
StaticMethods.saveAutPNG(
robSchnapp.getVStdCodes()[0],
storedRuns[filesFinished].getName() + "_simTrajTime_" + simZyk.getLastTick() + "_simOriginalTime_" + aufn.getPop(bestPopNum).getId() + ".png",
params);
rob.speichereAuts(storedRuns[filesFinished].getName() + "_simTrajTime_" + simZyk.getLastTick() + "_simOriginalTime_" + aufn.getPop(bestPopNum).getId());
}
}
filesFinished++;
} else {