@Test @SuppressWarnings("unchecked") public void testUpdateEnemyWaves() { MoveDataManager manager = newMoveDataManager(); MoveEnemy shadowData = mock(MoveEnemy.class); shadowData.wallHitDamage = new MoveEnemy.WallHitDamage(0, 0); shadowData.lastScanState = RobotState.newBuilder() .setLocation(newLocation()) .setTime(31L) .build(); manager.saveEnemy("Shadow", shadowData); shadowData.energy = 81.5; shadowData.raw1v1ShotsFired = 9; shadowData.raw1v1ShotsFiredThisRound = 3; shadowData.lastScanState = RobotState.newBuilder() .setLocation(newLocation(100, 100)) .setHeading(0) .setVelocity(8) .setTime(31L) .build(); when(shadowData.guessBulletPower(anyDouble())).thenReturn(1.5); Point2D.Double myLocation = newLocation(); manager.updateEnemyWaves( myLocation, 82.0, "Shadow", 1, 32L, 99, 1, 7.0, 2); assertEquals(10, shadowData.raw1v1ShotsFired, 0.01); assertEquals(4, shadowData.raw1v1ShotsFiredThisRound, 0.01); verify(shadowData).newMoveWave(eq(newLocation(100, 108)), eq(myLocation), anyDouble(), eq(1), eq(33L), eq(1.5), eq(99D), eq(1D), eq(7.0), anyInt(), anyDouble(), anyDouble(), anyDouble(), anyDouble(), anyLong(), anyLong()); verify(shadowData).updateImaginaryWave( eq(32L), (RobotState) any(), eq(2), (MovementPredictor) any()); verify(shadowData).updateFiringWave( eq(32L), eq(0.5), (RobotStateLog) any(), (List<FiredBullet>) any()); }
public void updateEnemyWaves(Point2D.Double myLocation, double previousEnemyEnergy, String botName, int currentRound, long currentTime, double myEnergy, double myHeading, double myVelocity, int wavesToSurf) { RobotState myRobotState = RobotState.newBuilder() .setLocation(myLocation) .setHeading(myHeading) .setVelocity(myVelocity) .setTime(currentTime) .build(); _myStateLog.addState(myRobotState); MoveEnemy moveData = getEnemyData(botName); boolean detectedEnemyBullet = false; double energyDrop = previousEnemyEnergy - moveData.energy - moveData.wallHitDamage.max; if (energyDrop > 0.0999 && energyDrop < 3.0001 && moveData.getGunHeat(currentTime) < 0.0001) { detectedEnemyBullet = true; } updateTimers(myVelocity); int velocitySign = DiaUtils.nonZeroSign( Math.abs(myVelocity) > NON_ZERO_VELOCITY_THRESHOLD ? myVelocity : _lastNonZeroVelocity); double accel = DiaUtils.limit(-Rules.DECELERATION, DiaUtils.accel(myVelocity, _previousVelocity), Rules.ACCELERATION); double dl8t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 8); double dl20t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 20); double dl40t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 40); double guessedPower = moveData.guessBulletPower(myEnergy); long fireTime = currentTime + 1; Point2D.Double enemyNextLocation = _battleField.translateToField( _predictor.nextLocation(moveData.lastScanState)); moveData.newMoveWave(enemyNextLocation, myLocation, DiaUtils.absoluteBearing(moveData.lastScanState.location, myLocation), currentRound, fireTime, guessedPower, myEnergy, myHeading, myVelocity, velocitySign, accel, dl8t, dl20t, dl40t, _timeSinceReverseDirection, _timeSinceVelocityChange); moveData.updateImaginaryWave( currentTime, myRobotState, wavesToSurf, _predictor); if (detectedEnemyBullet && currentTime > EARLIEST_FIRE_TIME) { moveData.updateFiringWave( currentTime, energyDrop, _myStateLog, _firedBullets); } }
MoveDataManager extends EnemyDataManager<MoveEnemy> { public void updateEnemyWaves(Point2D.Double myLocation, double previousEnemyEnergy, String botName, int currentRound, long currentTime, double myEnergy, double myHeading, double myVelocity, int wavesToSurf) { RobotState myRobotState = RobotState.newBuilder() .setLocation(myLocation) .setHeading(myHeading) .setVelocity(myVelocity) .setTime(currentTime) .build(); _myStateLog.addState(myRobotState); MoveEnemy moveData = getEnemyData(botName); boolean detectedEnemyBullet = false; double energyDrop = previousEnemyEnergy - moveData.energy - moveData.wallHitDamage.max; if (energyDrop > 0.0999 && energyDrop < 3.0001 && moveData.getGunHeat(currentTime) < 0.0001) { detectedEnemyBullet = true; } updateTimers(myVelocity); int velocitySign = DiaUtils.nonZeroSign( Math.abs(myVelocity) > NON_ZERO_VELOCITY_THRESHOLD ? myVelocity : _lastNonZeroVelocity); double accel = DiaUtils.limit(-Rules.DECELERATION, DiaUtils.accel(myVelocity, _previousVelocity), Rules.ACCELERATION); double dl8t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 8); double dl20t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 20); double dl40t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 40); double guessedPower = moveData.guessBulletPower(myEnergy); long fireTime = currentTime + 1; Point2D.Double enemyNextLocation = _battleField.translateToField( _predictor.nextLocation(moveData.lastScanState)); moveData.newMoveWave(enemyNextLocation, myLocation, DiaUtils.absoluteBearing(moveData.lastScanState.location, myLocation), currentRound, fireTime, guessedPower, myEnergy, myHeading, myVelocity, velocitySign, accel, dl8t, dl20t, dl40t, _timeSinceReverseDirection, _timeSinceVelocityChange); moveData.updateImaginaryWave( currentTime, myRobotState, wavesToSurf, _predictor); if (detectedEnemyBullet && currentTime > EARLIEST_FIRE_TIME) { moveData.updateFiringWave( currentTime, energyDrop, _myStateLog, _firedBullets); } } }
MoveDataManager extends EnemyDataManager<MoveEnemy> { public void updateEnemyWaves(Point2D.Double myLocation, double previousEnemyEnergy, String botName, int currentRound, long currentTime, double myEnergy, double myHeading, double myVelocity, int wavesToSurf) { RobotState myRobotState = RobotState.newBuilder() .setLocation(myLocation) .setHeading(myHeading) .setVelocity(myVelocity) .setTime(currentTime) .build(); _myStateLog.addState(myRobotState); MoveEnemy moveData = getEnemyData(botName); boolean detectedEnemyBullet = false; double energyDrop = previousEnemyEnergy - moveData.energy - moveData.wallHitDamage.max; if (energyDrop > 0.0999 && energyDrop < 3.0001 && moveData.getGunHeat(currentTime) < 0.0001) { detectedEnemyBullet = true; } updateTimers(myVelocity); int velocitySign = DiaUtils.nonZeroSign( Math.abs(myVelocity) > NON_ZERO_VELOCITY_THRESHOLD ? myVelocity : _lastNonZeroVelocity); double accel = DiaUtils.limit(-Rules.DECELERATION, DiaUtils.accel(myVelocity, _previousVelocity), Rules.ACCELERATION); double dl8t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 8); double dl20t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 20); double dl40t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 40); double guessedPower = moveData.guessBulletPower(myEnergy); long fireTime = currentTime + 1; Point2D.Double enemyNextLocation = _battleField.translateToField( _predictor.nextLocation(moveData.lastScanState)); moveData.newMoveWave(enemyNextLocation, myLocation, DiaUtils.absoluteBearing(moveData.lastScanState.location, myLocation), currentRound, fireTime, guessedPower, myEnergy, myHeading, myVelocity, velocitySign, accel, dl8t, dl20t, dl40t, _timeSinceReverseDirection, _timeSinceVelocityChange); moveData.updateImaginaryWave( currentTime, myRobotState, wavesToSurf, _predictor); if (detectedEnemyBullet && currentTime > EARLIEST_FIRE_TIME) { moveData.updateFiringWave( currentTime, energyDrop, _myStateLog, _firedBullets); } } protected  MoveDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); }
MoveDataManager extends EnemyDataManager<MoveEnemy> { public void updateEnemyWaves(Point2D.Double myLocation, double previousEnemyEnergy, String botName, int currentRound, long currentTime, double myEnergy, double myHeading, double myVelocity, int wavesToSurf) { RobotState myRobotState = RobotState.newBuilder() .setLocation(myLocation) .setHeading(myHeading) .setVelocity(myVelocity) .setTime(currentTime) .build(); _myStateLog.addState(myRobotState); MoveEnemy moveData = getEnemyData(botName); boolean detectedEnemyBullet = false; double energyDrop = previousEnemyEnergy - moveData.energy - moveData.wallHitDamage.max; if (energyDrop > 0.0999 && energyDrop < 3.0001 && moveData.getGunHeat(currentTime) < 0.0001) { detectedEnemyBullet = true; } updateTimers(myVelocity); int velocitySign = DiaUtils.nonZeroSign( Math.abs(myVelocity) > NON_ZERO_VELOCITY_THRESHOLD ? myVelocity : _lastNonZeroVelocity); double accel = DiaUtils.limit(-Rules.DECELERATION, DiaUtils.accel(myVelocity, _previousVelocity), Rules.ACCELERATION); double dl8t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 8); double dl20t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 20); double dl40t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 40); double guessedPower = moveData.guessBulletPower(myEnergy); long fireTime = currentTime + 1; Point2D.Double enemyNextLocation = _battleField.translateToField( _predictor.nextLocation(moveData.lastScanState)); moveData.newMoveWave(enemyNextLocation, myLocation, DiaUtils.absoluteBearing(moveData.lastScanState.location, myLocation), currentRound, fireTime, guessedPower, myEnergy, myHeading, myVelocity, velocitySign, accel, dl8t, dl20t, dl40t, _timeSinceReverseDirection, _timeSinceVelocityChange); moveData.updateImaginaryWave( currentTime, myRobotState, wavesToSurf, _predictor); if (detectedEnemyBullet && currentTime > EARLIEST_FIRE_TIME) { moveData.updateFiringWave( currentTime, energyDrop, _myStateLog, _firedBullets); } } protected  MoveDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); void execute(int round, long time, Point2D.Double myLocation,
      double heading, double velocity); @Override void initRound(); MoveEnemy newEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); MoveEnemy updateEnemy(ScannedRobotEvent e,
      Point2D.Double enemyLocation, double absBearing, int currentRound,
      boolean is1v1); void onHitByBullet(HitByBulletEvent e, int currentRound,
      long currentTime, boolean painting); void onBulletHitBullet(BulletHitBulletEvent e, int currentRound,
      long currentTime, boolean painting); void onBulletHit(BulletHitEvent e); void updateEnemyWaves(Point2D.Double myLocation,
      double previousEnemyEnergy, String botName, int currentRound,
      long currentTime, double myEnergy, double myHeading, double myVelocity,
      int wavesToSurf); RobotStateLog myStateLog(); void addFiredBullet(FiredBullet bullet); }
MoveDataManager extends EnemyDataManager<MoveEnemy> { public void updateEnemyWaves(Point2D.Double myLocation, double previousEnemyEnergy, String botName, int currentRound, long currentTime, double myEnergy, double myHeading, double myVelocity, int wavesToSurf) { RobotState myRobotState = RobotState.newBuilder() .setLocation(myLocation) .setHeading(myHeading) .setVelocity(myVelocity) .setTime(currentTime) .build(); _myStateLog.addState(myRobotState); MoveEnemy moveData = getEnemyData(botName); boolean detectedEnemyBullet = false; double energyDrop = previousEnemyEnergy - moveData.energy - moveData.wallHitDamage.max; if (energyDrop > 0.0999 && energyDrop < 3.0001 && moveData.getGunHeat(currentTime) < 0.0001) { detectedEnemyBullet = true; } updateTimers(myVelocity); int velocitySign = DiaUtils.nonZeroSign( Math.abs(myVelocity) > NON_ZERO_VELOCITY_THRESHOLD ? myVelocity : _lastNonZeroVelocity); double accel = DiaUtils.limit(-Rules.DECELERATION, DiaUtils.accel(myVelocity, _previousVelocity), Rules.ACCELERATION); double dl8t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 8); double dl20t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 20); double dl40t = _myStateLog.getDisplacementDistance(myLocation, currentTime, 40); double guessedPower = moveData.guessBulletPower(myEnergy); long fireTime = currentTime + 1; Point2D.Double enemyNextLocation = _battleField.translateToField( _predictor.nextLocation(moveData.lastScanState)); moveData.newMoveWave(enemyNextLocation, myLocation, DiaUtils.absoluteBearing(moveData.lastScanState.location, myLocation), currentRound, fireTime, guessedPower, myEnergy, myHeading, myVelocity, velocitySign, accel, dl8t, dl20t, dl40t, _timeSinceReverseDirection, _timeSinceVelocityChange); moveData.updateImaginaryWave( currentTime, myRobotState, wavesToSurf, _predictor); if (detectedEnemyBullet && currentTime > EARLIEST_FIRE_TIME) { moveData.updateFiringWave( currentTime, energyDrop, _myStateLog, _firedBullets); } } protected  MoveDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); void execute(int round, long time, Point2D.Double myLocation,
      double heading, double velocity); @Override void initRound(); MoveEnemy newEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); MoveEnemy updateEnemy(ScannedRobotEvent e,
      Point2D.Double enemyLocation, double absBearing, int currentRound,
      boolean is1v1); void onHitByBullet(HitByBulletEvent e, int currentRound,
      long currentTime, boolean painting); void onBulletHitBullet(BulletHitBulletEvent e, int currentRound,
      long currentTime, boolean painting); void onBulletHit(BulletHitEvent e); void updateEnemyWaves(Point2D.Double myLocation,
      double previousEnemyEnergy, String botName, int currentRound,
      long currentTime, double myEnergy, double myHeading, double myVelocity,
      int wavesToSurf); RobotStateLog myStateLog(); void addFiredBullet(FiredBullet bullet);  }