@Test public void testStraightEscapeAngleFromStop() { MovementPredictor predictor = newPredictor(); RobotState startState = RobotState.newBuilder() .setLocation(newLocation(500, 420)) .setHeading(Math.PI / 2) .setVelocity(0.0) .setTime(1L) .build(); MaxEscapeTarget meaTarget = predictor.straightPreciseEscapeAngle(1, 0, newLocation(500, 200), 1L, 11.0, startState, 0); assertFalse(meaTarget.hitWall); assertTrue(Math.asin(8.0 / 11.0) - meaTarget.angle > 0.1); }
MaxEscapeTarget straightPreciseEscapeAngle(int predictDirection, double absBearing, Point2D.Double sourceLocation, long fireTime, double bulletSpeed, RobotState startState, double attackAngle) { double straightEscapeAngle = 0; RobotState predictedState = startState; boolean hitWall = false; boolean wavePassed = false; do { predictedState = nextPerpendicularLocation( predictedState, absBearing, predictDirection, attackAngle, true); if (!_rectangle.contains(predictedState.location)) { hitWall = true; } else if (wavePassed( sourceLocation, fireTime, bulletSpeed, predictedState)) { wavePassed = true; } } while (!hitWall && !wavePassed); Point2D.Double meaLocation = _battleField.translateToField(predictedState.location); straightEscapeAngle = predictDirection * Utils.normalRelativeAngle( absoluteBearing(sourceLocation, meaLocation) - absBearing); return new MaxEscapeTarget( straightEscapeAngle, meaLocation, predictedState.time, hitWall); }
MovementPredictor { MaxEscapeTarget straightPreciseEscapeAngle(int predictDirection, double absBearing, Point2D.Double sourceLocation, long fireTime, double bulletSpeed, RobotState startState, double attackAngle) { double straightEscapeAngle = 0; RobotState predictedState = startState; boolean hitWall = false; boolean wavePassed = false; do { predictedState = nextPerpendicularLocation( predictedState, absBearing, predictDirection, attackAngle, true); if (!_rectangle.contains(predictedState.location)) { hitWall = true; } else if (wavePassed( sourceLocation, fireTime, bulletSpeed, predictedState)) { wavePassed = true; } } while (!hitWall && !wavePassed); Point2D.Double meaLocation = _battleField.translateToField(predictedState.location); straightEscapeAngle = predictDirection * Utils.normalRelativeAngle( absoluteBearing(sourceLocation, meaLocation) - absBearing); return new MaxEscapeTarget( straightEscapeAngle, meaLocation, predictedState.time, hitWall); } }
MovementPredictor { MaxEscapeTarget straightPreciseEscapeAngle(int predictDirection, double absBearing, Point2D.Double sourceLocation, long fireTime, double bulletSpeed, RobotState startState, double attackAngle) { double straightEscapeAngle = 0; RobotState predictedState = startState; boolean hitWall = false; boolean wavePassed = false; do { predictedState = nextPerpendicularLocation( predictedState, absBearing, predictDirection, attackAngle, true); if (!_rectangle.contains(predictedState.location)) { hitWall = true; } else if (wavePassed( sourceLocation, fireTime, bulletSpeed, predictedState)) { wavePassed = true; } } while (!hitWall && !wavePassed); Point2D.Double meaLocation = _battleField.translateToField(predictedState.location); straightEscapeAngle = predictDirection * Utils.normalRelativeAngle( absoluteBearing(sourceLocation, meaLocation) - absBearing); return new MaxEscapeTarget( straightEscapeAngle, meaLocation, predictedState.time, hitWall); } MovementPredictor(BattleField battleField); }
MovementPredictor { MaxEscapeTarget straightPreciseEscapeAngle(int predictDirection, double absBearing, Point2D.Double sourceLocation, long fireTime, double bulletSpeed, RobotState startState, double attackAngle) { double straightEscapeAngle = 0; RobotState predictedState = startState; boolean hitWall = false; boolean wavePassed = false; do { predictedState = nextPerpendicularLocation( predictedState, absBearing, predictDirection, attackAngle, true); if (!_rectangle.contains(predictedState.location)) { hitWall = true; } else if (wavePassed( sourceLocation, fireTime, bulletSpeed, predictedState)) { wavePassed = true; } } while (!hitWall && !wavePassed); Point2D.Double meaLocation = _battleField.translateToField(predictedState.location); straightEscapeAngle = predictDirection * Utils.normalRelativeAngle( absoluteBearing(sourceLocation, meaLocation) - absBearing); return new MaxEscapeTarget( straightEscapeAngle, meaLocation, predictedState.time, hitWall); } MovementPredictor(BattleField battleField); RobotState predict(RobotState startState, double distance, double turn,
      double maxVelocity, long ticks, boolean ignoreWalls); RobotState nextRobotState(Diamond robot); Point2D.Double nextLocation(Diamond robot); Point2D.Double nextLocation(RobotState robotState); Point2D.Double nextLocation(Point2D.Double botLocation,
      double heading, double velocity); RobotState nextPerpendicularLocation(RobotState robotState,
      double absBearing, int orientation, double attackAngle,
      boolean ignoreWallHits); RobotState nextPerpendicularWallSmoothedLocation(RobotState robotState,
      double absBearing, double maxVelocity, double attackAngle,
      int orientation, double wallStick, boolean ignoreWallHits); RobotState nextLocation(RobotState robotState, double maxVelocity,
      double goAngle, boolean ignoreWallHits); double escapeAngleRange(Point2D.Double sourceLocation,
      long fireTime, double bulletSpeed, RobotState startState,
      double wallStick); MaxEscapeTarget preciseEscapeAngle(int predictDirection,
      Point2D.Double sourceLocation, long fireTime, double bulletSpeed,
      RobotState startState, double wallStick); MaxEscapeTarget preciseEscapeAngle(int predictDirection,
      Point2D.Double sourceLocation, long fireTime, double bulletSpeed,
      RobotState startState, double attackAngle, double wallStick); }
MovementPredictor { MaxEscapeTarget straightPreciseEscapeAngle(int predictDirection, double absBearing, Point2D.Double sourceLocation, long fireTime, double bulletSpeed, RobotState startState, double attackAngle) { double straightEscapeAngle = 0; RobotState predictedState = startState; boolean hitWall = false; boolean wavePassed = false; do { predictedState = nextPerpendicularLocation( predictedState, absBearing, predictDirection, attackAngle, true); if (!_rectangle.contains(predictedState.location)) { hitWall = true; } else if (wavePassed( sourceLocation, fireTime, bulletSpeed, predictedState)) { wavePassed = true; } } while (!hitWall && !wavePassed); Point2D.Double meaLocation = _battleField.translateToField(predictedState.location); straightEscapeAngle = predictDirection * Utils.normalRelativeAngle( absoluteBearing(sourceLocation, meaLocation) - absBearing); return new MaxEscapeTarget( straightEscapeAngle, meaLocation, predictedState.time, hitWall); } MovementPredictor(BattleField battleField); RobotState predict(RobotState startState, double distance, double turn,
      double maxVelocity, long ticks, boolean ignoreWalls); RobotState nextRobotState(Diamond robot); Point2D.Double nextLocation(Diamond robot); Point2D.Double nextLocation(RobotState robotState); Point2D.Double nextLocation(Point2D.Double botLocation,
      double heading, double velocity); RobotState nextPerpendicularLocation(RobotState robotState,
      double absBearing, int orientation, double attackAngle,
      boolean ignoreWallHits); RobotState nextPerpendicularWallSmoothedLocation(RobotState robotState,
      double absBearing, double maxVelocity, double attackAngle,
      int orientation, double wallStick, boolean ignoreWallHits); RobotState nextLocation(RobotState robotState, double maxVelocity,
      double goAngle, boolean ignoreWallHits); double escapeAngleRange(Point2D.Double sourceLocation,
      long fireTime, double bulletSpeed, RobotState startState,
      double wallStick); MaxEscapeTarget preciseEscapeAngle(int predictDirection,
      Point2D.Double sourceLocation, long fireTime, double bulletSpeed,
      RobotState startState, double wallStick); MaxEscapeTarget preciseEscapeAngle(int predictDirection,
      Point2D.Double sourceLocation, long fireTime, double bulletSpeed,
      RobotState startState, double attackAngle, double wallStick);  }