public void onHitByBullet(HitByBulletEvent event) {
      double angle = peer.getBodyHeading() + event.getBearingRadians();

      hitByBulletAngle = (int) (Math.toDegrees(Utils.normalAbsoluteAngle(angle)) + 0.5);
      hitByBulletBearing = (int) (event.getBearing() + 0.5);
      JuniorRobot.this.onHitByBullet();
    }
Example #2
0
  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;
    }
  }
Example #3
0
 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();
   }
 }