public void onHitByBullet(HitByBulletEvent e) { if (fitness - getEnergy() > 15) { select++; if (select == 4) { elapsedTime[select - 1] = (int) e.getTime() - time; time = (int) e.getTime(); sortIndividuals(); for (int i = 1; i < 4; i++) if (Math.random() < 0.7) population[i] = crossover(population[0], population[i]); for (int i = 0; i < 4; i++) if (Math.random() < 0.1) population[i] = mutation(population[i]); select = 0; } fitness = (int) getEnergy(); } }
public void onHitByBullet(HitByBulletEvent e) { ScanLog.onHitByBullet(e); Wave hitWave = processBulletReturnFiringWave(e.getBullet(), e.getTime()); if (hitWave != NO_WAVE_FOUND) { double thisHit = (hitWave.targetScan.getDistance() / TYPICAL_DISTANCE) * (hitWave.escapeAngleRange() / TYPICAL_ESCAPE_RANGE); _weightedEnemyShotsHit += thisHit; _weightedEnemyShotsHitThisRound += thisHit; } }