System.out.println("GROESSE: " + netPop.getSize());
for (int l = 1; l < popSize; l++) {
DomPhysAgent agent = agenten.getAgent(l);
DomPhysNeuroBrain hirn = new DomPhysNeuroBrain(agent, netPop.getNet(l).getId(), env.getRand(), netPop.getNet(l));
agent.implantBrain(hirn);
}
DomPhysAgent agent = agenten.getAgent(0);
DomPhysNeuroBrain hirn = new DomPhysNeuroBrain(agent, netPop.getNet(netPop.getIndexBestesNetz()).getId(), env.getRand(), netPop.getBestesNetz());
agent.implantBrain(hirn);
System.out.println("GELADEN: " + hirn.getNet().generateGenome(new DominikEncoding1()) + " Fitness: " + netPop.getFitness(netPop.getIndexBestesNetz()) + " ID: " + hirn.getNet().getId());
for (int l = 1; l < popSize; l++) {
agent = agenten.getAgent(l);
env.removeAgent(l + 1);
}
}
/*if(simZyk.getCurrentTime() == 100) {
DomPhysAgent agent = agenten.getAgent(0);
agent.setAgentShapeBIG();
}*/
//TEST
/*if(simZyk.getCurrentTime() == 20000) {
DomPhysAgent agent = agenten.getAgent(0);
float x = 10;
float y = 10;
agent.adjustVelocity(new Vector2f(x,y));
}
if(simZyk.getCurrentTime() == 6000) {
DomPhysAgent agent = agenten.getAgent(0);
float x = 10;
float y = 10;
agent.adjustVelocity(new Vector2f(x,y));
}
if(simZyk.getCurrentTime() == 10000) {
DomPhysAgent agent = agenten.getAgent(0);
float x = 10;
float y = 10;
agent.adjustVelocity(new Vector2f(x,y));
} */
}
/*if (saveLoad == 2) {
for (int l = 1; l < popSize; l++) {
DomPhysAgent agent = agenten.getAgent(l);
agent.evaluate(simZyk);
} */
DomPhysAgent agent2 = agenten.getAgent(0);
agent2.evaluate(simZyk);
if(simZyk.getCurrentTime() % 50 == 0) {
//System.out.println("FITNESS: " + agent2.getEvaluation() + " TICK: " + simZyk.getCurrentTime());
}//System.out.println("Inputs: " + hirn.getNet().getInputs() + " Outputs: " + hirn.getNet().getOutputs());
if (saveLoad == 0 || saveLoad == 1) {
// Evaluierung jede Runde
for (int l = 1; l < popSize + 1; l++) {
DomPhysAgent agent = (DomPhysAgent) env.getAgent(l);
if (saveLoad == 0 || saveLoad == 1) {
//System.out.println(agent.getID() + "amLeben?: " + agent.getAmLeben() + "HIRN: " + agent.getBrain().getNet().getId());
agent.evaluate(simZyk);
}
// Speichern und entfernen von toten Agenten
int fitness = agent.getEvaluationInt();
Color farbe = agent.getAgentColor();
boolean lebend = agent.getAmLeben();
/*if(l == 37) {
System.out.println("Antrieb: " + agent.getActuatorWerte()[0] *80 + " / Drehung: " + agent.getActuatorWerte()[1] * 0.3);
}*/
if(!lebend) {
DomPhysSparseNet netAlt = agent.getBrain().getNet();
double minAbstand = agent.getMinAbstand();
double maxAbstand = agent.getMaxAbstand();
int geburt = agent.getGeburt();
netPop.add(netAlt, fitness, minAbstand, maxAbstand, geburt);
//System.out.println("Jetzt hinzufuegen: " + new DominikEncoding1().encode(hirn));
env.removeAgent(l);
// mutiertes Hirn
DomPhysSparseNet netNeu = (DomPhysSparseNet) this.randVerteilung(netPop.getNetze(), netPop.getFitnesswerte(), env.getRand());
DomPhysSparseNet mutNetNeu = netNeu.createMutatedOffspring(i, rand);
DomPhysNeuroBrain hirnNeu = new DomPhysNeuroBrain(agent, i, env.getRand(), mutNetNeu);
agent.implantBrain(hirnNeu);
//Erkennung
//if(i == 1131) {