public void evaluateWallStick() { _wallStick = (ScanLog.enemyIsRammer()) ? RAMMER_WALL_STICK : DEFAULT_WALL_STICK; }
public void surf() { RobotState currentState = new RobotState( ScanLog.myLocation(), _robot.getHeadingRadians(), _robot.getVelocity(), _robot.getTime()); boolean goingClockwise = (_lastMovementChoice == CLOCKWISE_OPTION); double orbitCounterClockwiseDanger = checkDanger( currentState, COUNTERCLOCKWISE_OPTION, goingClockwise, FIRST_WAVE, WAVES_TO_SURF); double stopDanger = checkDanger(currentState, STOP_OPTION, goingClockwise, FIRST_WAVE, WAVES_TO_SURF); double orbitClockwiseDanger = checkDanger(currentState, CLOCKWISE_OPTION, goingClockwise, FIRST_WAVE, WAVES_TO_SURF); int goOrientation = _lastMovementChoice; Wave orbitWave = findSurfableWave(FIRST_WAVE); double orbitAbsBearing, distanceToClosestWaveSource; try { distanceToClosestWaveSource = ScanLog.myLocation().distance(orbitWave.sourceLocation); orbitAbsBearing = DUtils.absoluteBearing(orbitWave.sourceLocation, ScanLog.myLocation()); } catch (NullPointerException noSurfableWaves) { distanceToClosestWaveSource = ScanLog.getLastDistance(); orbitAbsBearing = ScanLog.getLastEnemyScan().getAbsBearingRadians(); } double goAngle, attackAngle; if (stopDanger == NO_SURFABLE_WAVES) { attackAngle = -1.047; _robot.setMaxVelocity(8); double goAngleCcw = orbitAbsBearing + (COUNTERCLOCKWISE_OPTION * ((Math.PI / 2) + attackAngle)); goAngleCcw = wallSmoothing( ScanLog.myLocation(), goAngleCcw, COUNTERCLOCKWISE_OPTION, distanceToClosestWaveSource); double goAngleCw = orbitAbsBearing + (CLOCKWISE_OPTION * ((Math.PI / 2) + attackAngle)); goAngleCw = wallSmoothing( ScanLog.myLocation(), goAngleCw, CLOCKWISE_OPTION, distanceToClosestWaveSource); if (Math.abs(Utils.normalRelativeAngle(goAngleCw - orbitAbsBearing)) < Math.abs(Utils.normalRelativeAngle(goAngleCcw - orbitAbsBearing))) { goOrientation = CLOCKWISE_OPTION; goAngle = goAngleCw; } else { goOrientation = COUNTERCLOCKWISE_OPTION; goAngle = goAngleCcw; } } else { _robot.setMaxVelocity(8); attackAngle = _currentDistancer.attackAngle(distanceToClosestWaveSource, _desiredDistance); if (ScanLog.enemyIsRammer() && ScanLog.getLastDistance() < 300 && orbitWave != NO_WAVE_FOUND) { if (Utils.normalRelativeAngle( DUtils.absoluteBearing(ScanLog.myLocation(), orbitWave.sourceLocation) - ScanLog.getLastScan().getAbsBearingRadians()) > 0) { goOrientation = -1; } else { goOrientation = 1; } } else if (stopDanger <= orbitCounterClockwiseDanger && stopDanger <= orbitClockwiseDanger && !ScanLog.enemyIsRammer()) { _robot.setMaxVelocity(0); } else { if (orbitClockwiseDanger < orbitCounterClockwiseDanger) { goOrientation = CLOCKWISE_OPTION; } else { goOrientation = COUNTERCLOCKWISE_OPTION; } } goAngle = orbitAbsBearing + (goOrientation * ((Math.PI / 2) + attackAngle)); goAngle = wallSmoothing(ScanLog.myLocation(), goAngle, goOrientation, distanceToClosestWaveSource); } DUtils.setBackAsFront(_robot, goAngle); _lastMovementChoice = goOrientation; }