Exemple #1
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;
    }
  }
Exemple #2
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();
   }
 }
  @Override
  public void onHitByBullet(HitByBulletEvent event) {
    GBulletFiredEvent wave = waves.getNearestWave();
    Point2D myPos = new Point2D.Double(getX(), getY());

    // TODO we lost a wave
    if (wave == null
        || Math.abs(
                myPos.distance(wave.getFiringPosition())
                    - (getTime() - wave.getFiringTime()) * wave.getVelocity())
            > Costants.SURFING_MAX_DISTANE_HITTED_WAVE) return;

    double firingOffset =
        org.pattern.utils.Utils.firingOffset(
            wave.getFiringPosition(), wave.getTargetPosition(), myPos);
    double gf =
        firingOffset > 0 ? firingOffset / wave.getMaxMAE() : -firingOffset / wave.getMinMAE();

    storages.get(event.getName()).visit(gf);
  }
 public void onHitByBullet(HitByBulletEvent e) {
   Hit h = new Hit();
   h.heading = e.getHeadingRadians();
   h.time = e.getTime();
   hits.add(h);
 }
Exemple #5
0
 public void onHitByBullet(HitByBulletEvent e) {
   turnLeft(90 - e.getBearing());
 }