@Test public void testCalculateBulletPower1v1LowEnergy() { DiamondFist gun = newGun(true, false); _shadow.energy = 0.44; mock1v1(gun, _shadow); double bulletPower = gun.calculateBulletPower(); assertTrue(bulletPower <= 0.11); }
double calculateBulletPower() { GunEnemy gunData = _gunDataManager.getClosestLivingBot(myLocation()); double bulletPower = 3; if (gunData != null) { double myEnergy = _robot.getEnergy(); if (_tcMode) { bulletPower = Math.min(myEnergy, 3); } else if (is1v1()) { bulletPower = 1.95; if (gunData.distance < 150 || gunData.isRammer()) { bulletPower = 2.95; } if (gunData.distance > 325) { double powerDownPoint = DiaUtils.limit(35, 63 + ((gunData.energy - myEnergy) * 4), 63); if (myEnergy < powerDownPoint) { bulletPower = Math.min(bulletPower, DiaUtils.cube(myEnergy / powerDownPoint) * 1.95); } } bulletPower = Math.min(bulletPower, gunData.energy / 4); bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } else { double avgEnemyEnergy = _gunDataManager.getAverageEnergy(); bulletPower = 2.999; int enemiesAlive = _robot.getOthers(); if (enemiesAlive <= 3) { bulletPower = 1.999; } if (enemiesAlive <= 5 && gunData.distance > 500) { bulletPower = 1.499; } if ((myEnergy < avgEnemyEnergy && enemiesAlive <= 5 && gunData.distance > 300) || gunData.distance > 700) { bulletPower = 0.999; } if (myEnergy < 20 && myEnergy < avgEnemyEnergy) { bulletPower = Math.min(bulletPower, 2 - ((20 - myEnergy) / 11)); } bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } } return bulletPower; }
DiamondFist implements RoboPainter { double calculateBulletPower() { GunEnemy gunData = _gunDataManager.getClosestLivingBot(myLocation()); double bulletPower = 3; if (gunData != null) { double myEnergy = _robot.getEnergy(); if (_tcMode) { bulletPower = Math.min(myEnergy, 3); } else if (is1v1()) { bulletPower = 1.95; if (gunData.distance < 150 || gunData.isRammer()) { bulletPower = 2.95; } if (gunData.distance > 325) { double powerDownPoint = DiaUtils.limit(35, 63 + ((gunData.energy - myEnergy) * 4), 63); if (myEnergy < powerDownPoint) { bulletPower = Math.min(bulletPower, DiaUtils.cube(myEnergy / powerDownPoint) * 1.95); } } bulletPower = Math.min(bulletPower, gunData.energy / 4); bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } else { double avgEnemyEnergy = _gunDataManager.getAverageEnergy(); bulletPower = 2.999; int enemiesAlive = _robot.getOthers(); if (enemiesAlive <= 3) { bulletPower = 1.999; } if (enemiesAlive <= 5 && gunData.distance > 500) { bulletPower = 1.499; } if ((myEnergy < avgEnemyEnergy && enemiesAlive <= 5 && gunData.distance > 300) || gunData.distance > 700) { bulletPower = 0.999; } if (myEnergy < 20 && myEnergy < avgEnemyEnergy) { bulletPower = Math.min(bulletPower, 2 - ((20 - myEnergy) / 11)); } bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } } return bulletPower; } }
DiamondFist implements RoboPainter { double calculateBulletPower() { GunEnemy gunData = _gunDataManager.getClosestLivingBot(myLocation()); double bulletPower = 3; if (gunData != null) { double myEnergy = _robot.getEnergy(); if (_tcMode) { bulletPower = Math.min(myEnergy, 3); } else if (is1v1()) { bulletPower = 1.95; if (gunData.distance < 150 || gunData.isRammer()) { bulletPower = 2.95; } if (gunData.distance > 325) { double powerDownPoint = DiaUtils.limit(35, 63 + ((gunData.energy - myEnergy) * 4), 63); if (myEnergy < powerDownPoint) { bulletPower = Math.min(bulletPower, DiaUtils.cube(myEnergy / powerDownPoint) * 1.95); } } bulletPower = Math.min(bulletPower, gunData.energy / 4); bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } else { double avgEnemyEnergy = _gunDataManager.getAverageEnergy(); bulletPower = 2.999; int enemiesAlive = _robot.getOthers(); if (enemiesAlive <= 3) { bulletPower = 1.999; } if (enemiesAlive <= 5 && gunData.distance > 500) { bulletPower = 1.499; } if ((myEnergy < avgEnemyEnergy && enemiesAlive <= 5 && gunData.distance > 300) || gunData.distance > 700) { bulletPower = 0.999; } if (myEnergy < 20 && myEnergy < avgEnemyEnergy) { bulletPower = Math.min(bulletPower, 2 - ((20 - myEnergy) / 11)); } bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } } return bulletPower; } DiamondFist(Diamond robot, boolean isTcMode);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      Collection<RoboGraphic> renderables, OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, GunDataManager gunDataManager,
      VirtualGunsManager<TimestampedFiringAngle> virtualGunsManager,
      BattleField battleField, Collection<RoboGraphic> renderables,
      OutputStream out); }
DiamondFist implements RoboPainter { double calculateBulletPower() { GunEnemy gunData = _gunDataManager.getClosestLivingBot(myLocation()); double bulletPower = 3; if (gunData != null) { double myEnergy = _robot.getEnergy(); if (_tcMode) { bulletPower = Math.min(myEnergy, 3); } else if (is1v1()) { bulletPower = 1.95; if (gunData.distance < 150 || gunData.isRammer()) { bulletPower = 2.95; } if (gunData.distance > 325) { double powerDownPoint = DiaUtils.limit(35, 63 + ((gunData.energy - myEnergy) * 4), 63); if (myEnergy < powerDownPoint) { bulletPower = Math.min(bulletPower, DiaUtils.cube(myEnergy / powerDownPoint) * 1.95); } } bulletPower = Math.min(bulletPower, gunData.energy / 4); bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } else { double avgEnemyEnergy = _gunDataManager.getAverageEnergy(); bulletPower = 2.999; int enemiesAlive = _robot.getOthers(); if (enemiesAlive <= 3) { bulletPower = 1.999; } if (enemiesAlive <= 5 && gunData.distance > 500) { bulletPower = 1.499; } if ((myEnergy < avgEnemyEnergy && enemiesAlive <= 5 && gunData.distance > 300) || gunData.distance > 700) { bulletPower = 0.999; } if (myEnergy < 20 && myEnergy < avgEnemyEnergy) { bulletPower = Math.min(bulletPower, 2 - ((20 - myEnergy) / 11)); } bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } } return bulletPower; } DiamondFist(Diamond robot, boolean isTcMode);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      Collection<RoboGraphic> renderables, OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, GunDataManager gunDataManager,
      VirtualGunsManager<TimestampedFiringAngle> virtualGunsManager,
      BattleField battleField, Collection<RoboGraphic> renderables,
      OutputStream out); void initRound(Diamond robot); void execute(); void onScannedRobot(ScannedRobotEvent e); void onRobotDeath(RobotDeathEvent e); void onWin(WinEvent e); void onDeath(DeathEvent e); void onBulletHit(BulletHitEvent e); void onBulletHitBullet(BulletHitBulletEvent e); void onPaint(Graphics2D g); int getEnemiesAlive(); void addFireListener(FireListener listener); void paintOn(); void paintOff(); void robocodePaintOn(); void robocodePaintOff(); String paintLabel(); boolean paintStatus(); }
DiamondFist implements RoboPainter { double calculateBulletPower() { GunEnemy gunData = _gunDataManager.getClosestLivingBot(myLocation()); double bulletPower = 3; if (gunData != null) { double myEnergy = _robot.getEnergy(); if (_tcMode) { bulletPower = Math.min(myEnergy, 3); } else if (is1v1()) { bulletPower = 1.95; if (gunData.distance < 150 || gunData.isRammer()) { bulletPower = 2.95; } if (gunData.distance > 325) { double powerDownPoint = DiaUtils.limit(35, 63 + ((gunData.energy - myEnergy) * 4), 63); if (myEnergy < powerDownPoint) { bulletPower = Math.min(bulletPower, DiaUtils.cube(myEnergy / powerDownPoint) * 1.95); } } bulletPower = Math.min(bulletPower, gunData.energy / 4); bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } else { double avgEnemyEnergy = _gunDataManager.getAverageEnergy(); bulletPower = 2.999; int enemiesAlive = _robot.getOthers(); if (enemiesAlive <= 3) { bulletPower = 1.999; } if (enemiesAlive <= 5 && gunData.distance > 500) { bulletPower = 1.499; } if ((myEnergy < avgEnemyEnergy && enemiesAlive <= 5 && gunData.distance > 300) || gunData.distance > 700) { bulletPower = 0.999; } if (myEnergy < 20 && myEnergy < avgEnemyEnergy) { bulletPower = Math.min(bulletPower, 2 - ((20 - myEnergy) / 11)); } bulletPower = Math.max(bulletPower, 0.1); bulletPower = Math.min(bulletPower, myEnergy); } } return bulletPower; } DiamondFist(Diamond robot, boolean isTcMode);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      Collection<RoboGraphic> renderables, OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out);   DiamondFist(Diamond robot, boolean isTcMode, GunDataManager gunDataManager,
      VirtualGunsManager<TimestampedFiringAngle> virtualGunsManager,
      BattleField battleField, Collection<RoboGraphic> renderables,
      OutputStream out); void initRound(Diamond robot); void execute(); void onScannedRobot(ScannedRobotEvent e); void onRobotDeath(RobotDeathEvent e); void onWin(WinEvent e); void onDeath(DeathEvent e); void onBulletHit(BulletHitEvent e); void onBulletHitBullet(BulletHitBulletEvent e); void onPaint(Graphics2D g); int getEnemiesAlive(); void addFireListener(FireListener listener); void paintOn(); void paintOff(); void robocodePaintOn(); void robocodePaintOff(); String paintLabel(); boolean paintStatus();  }