## robocode
Class RateControlRobot

    java.lang.Object
      robocode._RobotBase
          robocode._Robot
              robocode.Robot
                  robocode._AdvancedRobot
                      robocode._AdvancedRadiansRobot
                          robocode.AdvancedRobot
                              robocode.TeamRobot
                                  robocode.RateControlRobot

All Implemented Interfaces:
  Runnable, IAdvancedEvents, IAdvancedRobot, IBasicEvents, IBasicEvents2, IBasicEvents3, IBasicRobot, IInteractiveEvents, IInteractiveRobot, IPaintEvents, IPaintRobot, ITeamEvents, ITeamRobot

    public class RateControlRobot

extends TeamRobot

This advanced robot type allows you to set a rate for each of the robot's movements.

You can set the rate for:

- velocity - pixels per turn
- robot turn - radians per turn
- gun rotation - radians per turn
- radar rotation - radians per turn

When you set a rate for one of the above movements, the movement will continue the move by specified rate for ever, until the rate is changed. In order to move ahead or right, the rate must be set to a positive value. If a negative value is used instead, the movement will go back or to the left. In order to stop the movement, the rate must be set to 0.

Note: When calling `setVelocityRate()`, `setTurnRate()`, `setGunRotationRate()`, `setRadarRotationRate()` and variants, Any previous calls to "movement" functions outside of `RateControlRobot`, such as `setAhead()`, `setTurnLeft()`, `setTurnRadarRightRadians()` and similar will be overridden when calling the `execute()` on this robot class.

Look into the source code for the `sample.VelociRobot` in order to see how to use this robot type.

Since:
  1.7.1.3
Author:
  Joshua Galecki (original), Flemming N. Larsen (contributor)
See Also:
  `JuniorRobot`, `Robot`, `AdvancedRobot`, `TeamRobot`, `Droid`

Field Summary

Fields inherited from class robocode._RobotBase
`out`

Constructor Summary
`RateControlRobot()`

Method Summary
`void` `execute()` Executes any pending actions, or continues executing actions that are in process.
`double` `getGunRotationRate()` Gets the gun's clockwise rotation per turn, in degrees.
`double` `getGunRotationRateRadians()` Gets the gun's clockwise rotation per turn, in radians.
`double` `getRadarRotationRate()` Gets the radar's clockwise rotation per turn, in degrees.
`double` `getRadarRotationRateRadians()` Gets the radar's clockwise rotation per turn, in radians.
`double` `getTurnRate()` Gets the robot's clockwise rotation per turn, in degrees.
`double` `getTurnRateRadians()` Gets the robot's clockwise rotation per turn, in radians.
`double` `getVelocityRate()` Returns the speed the robot will move, in pixels per turn.
`void` `setGunRotationRate(double gunRotationRate)` Sets the gun's clockwise (right) rotation per turn, in degrees.
`void` `setGunRotationRateRadians(double gunRotationRate)` Sets the gun's clockwise (right) rotation per turn, in radians.
`void` `setRadarRotationRate(double radarRotationRate)` Sets the radar's clockwise (right) rotation per turn, in degrees.
`void` `setRadarRotationRateRadians(double radarRotationRate)` Sets the radar's clockwise (right) rotation per turn, in radians.
`void` `setTurnRate(double turnRate)` Sets the robot's clockwise (right) rotation per turn, in degrees.
`void` `setTurnRateRadians(double turnRate)` Sets the robot's clockwise (right) rotation per turn, in radians.
`void` `setVelocityRate(double velocityRate)` Sets the speed the robot will move (forward), in pixels per turn.

Methods inherited from class robocode.TeamRobot
`broadcastMessage, getMessageEvents, getTeamEventListener, getTeammates, isTeammate, onMessageReceived, sendMessage`

Methods inherited from class robocode.AdvancedRobot

`addCustomEvent, clearAllEvents, getAdvancedEventListener, getAllEvents, getBulletHitBulletEvents, getBulletHitEvents, getBulletMissedEvents, getDataDirectory, getDataFile, getDataQuotaAvailable, getDistanceRemaining, getEventPriority, getGunHeadingRadians, getGunTurnRemaining, getGunTurnRemainingRadians, getHeadingRadians, getHitByBulletEvents, getHitRobotEvents, getHitWallEvents, getRadarHeadingRadians, getRadarTurnRemaining, getRadarTurnRemainingRadians, getRobotDeathEvents, getScannedRobotEvents, getStatusEvents, getTurnRemaining, getTurnRemainingRadians, isAdjustGunForRobotTurn, isAdjustRadarForGunTurn, isAdjustRadarForRobotTurn, onCustomEvent, onDeath, onSkippedTurn, removeCustomEvent, setAhead, setBack, setEventPriority, setFire, setFireBullet, setInterruptible, setMaxTurnRate, setMaxVelocity, setResume, setStop, setStop, setTurnGunLeft, setTurnGunLeftRadians, setTurnGunRight, setTurnGunRightRadians, setTurnLeft, setTurnLeftRadians, setTurnRadarLeft, setTurnRadarLeftRadians, setTurnRadarRight, setTurnRadarRightRadians, setTurnRight, setTurnRightRadians, turnGunLeftRadians, turnGunRightRadians, turnLeftRadians, turnRadarLeftRadians, turnRadarRightRadians, turnRightRadians, waitFor`

Methods inherited from class robocode._AdvancedRobot
`endTurn, getGunHeadingDegrees, getHeadingDegrees, getMaxWaitCount, getRadarHeadingDegrees, getWaitCount, setTurnGunLeftDegrees, setTurnGunRightDegrees, setTurnLeftDegrees, setTurnRadarLeftDegrees, setTurnRadarRightDegrees, setTurnRightDegrees, turnGunLeftDegrees, turnGunRightDegrees, turnLeftDegrees, turnRadarLeftDegrees, turnRadarRightDegrees, turnRightDegrees`

Methods inherited from class robocode.Robot

`ahead, back, doNothing, fire, fireBullet, getBasicEventListener, getBattleFieldHeight, getBattleFieldWidth, getEnergy, getGraphics, getGunCoolingRate, getGunHeading, getGunHeat, getHeading, getHeight, getInteractiveEventListener, getName, getNumRounds, getOthers, getPaintEventListener, getRadarHeading, getRobotRunnable, getRoundNum, getTime, getVelocity, getWidth, getX, getY, onBattleEnded, onBulletHit, onBulletHitBullet, onBulletMissed, onHitByBullet, onHitRobot, onHitWall, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved, onPaint, onRobotDeath, onRoundEnded, onScannedRobot, onStatus, onWin, resume, run, scan, setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn, setAllColors, setBodyColor, setBulletColor, setColors, setColors, setDebugProperty, setGunColor, setRadarColor, setScanColor, stop, stop, turnGunLeft, turnGunRight, turnLeft, turnRadarLeft, turnRadarRight, turnRight`

Methods inherited from class robocode._Robot
`getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setRadarImageName, setRobotImageName`

Methods inherited from class robocode._RobotBase
`finalize, setOut, setPeer`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface robocode.robotinterfaces.IAdvancedRobot
`getAdvancedEventListener`

Methods inherited from interface robocode.robotinterfaces.IBasicRobot
`getBasicEventListener, getRobotRunnable, setOut, setPeer`

Constructor Detail

### RateControlRobot

    public RateControlRobot()

Method Detail

### setVelocityRate

    public void setVelocityRate(double velocityRate)

  Sets the speed the robot will move (forward), in pixels per turn.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the robot will move backwards

  Example:

         // Set the robot to move forward 2 pixels per turn
         setVelocityRate(2);

         // Set the robot to move backwards 8 pixels per turn
         // (overrides the previous order)
         setVelocityRate(-8);

         ...
         // Executes the last setVelocityRate()
         execute();

  Note: This method overrules `AdvancedRobot.setAhead(double)` and `AdvancedRobot.setBack(double)`.

  Parameters:
    `velocityRate` - pixels per turn the robot will move.
  See Also:
    `getVelocityRate()`, `setTurnRate(double)`, `setGunRotationRate(double)`, `setRadarRotationRate(double)`, `AdvancedRobot.setAhead(double)`, `AdvancedRobot.setBack(double)`

### getVelocityRate

    public double getVelocityRate()

  Returns the speed the robot will move, in pixels per turn. Positive values means that the robot will move forward. Negative values means that the robot will move backwards. If the value is 0, the robot will stand still.

  Returns:
    The speed of the robot in pixels per turn
  See Also:
    `setVelocityRate(double)`

### setTurnRate

    public void setTurnRate(double turnRate)

  Sets the robot's clockwise (right) rotation per turn, in degrees.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)

  Example:

         // Set the robot to turn right 10 degrees per turn
         setTurnRate(10);

         // Set the robot to turn left 4 degrees per turn
         // (overrides the previous order)
         setTurnRate(-5);

         ...
         // Executes the last setTurnRate()
         execute();

  Parameters:
    `turnRate` - angle of the clockwise rotation, in degrees.
  See Also:
    `getTurnRate()`, `setVelocityRate(double)`, `setGunRotationRate(double)`, `setRadarRotationRate(double)`, `AdvancedRobot.setTurnRight(double)`, `AdvancedRobot.setTurnLeft(double)`

### getTurnRate

    public double getTurnRate()

  Gets the robot's clockwise rotation per turn, in degrees. Positive values means that the robot will turn to the right. Negative values means that the robot will turn to the left. If the value is 0, the robot will not turn.

  Returns:
    Angle of the clockwise rotation, in degrees.
  See Also:
    `setTurnRate(double)`

### setTurnRateRadians

    public void setTurnRateRadians(double turnRate)

  Sets the robot's clockwise (right) rotation per turn, in radians.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)

  Example:

         // Set the robot to turn right pi / 32 radians per turn
         setTurnRateRadians(Math.PI / 32);

         // Set the robot to turn left pi / 20 radians per turn
         // (overrides the previous order)
         setTurnRateRadians(-Math.PI / 20);

         ...
         // Executes the last setTurnRateRadians()
         execute();

  Parameters:
    `turnRate` - angle of the clockwise rotation, in radians.
  See Also:
    `getTurnRateRadians()()`, `setVelocityRate(double)`, `setGunRotationRateRadians(double)`, `setRadarRotationRateRadians(double)`, `AdvancedRobot.setTurnRightRadians(double)`, `AdvancedRobot.setTurnLeftRadians(double)`

### getTurnRateRadians

    public double getTurnRateRadians()

  Gets the robot's clockwise rotation per turn, in radians. Positive values means that the robot will turn to the right. Negative values means that the robot will turn to the left. If the value is 0, the robot will not turn.

  Returns:
    Angle of the clockwise rotation, in radians.
  See Also:
    `getTurnRateRadians()`

### setGunRotationRate

    public void setGunRotationRate(double gunRotationRate)

  Sets the gun's clockwise (right) rotation per turn, in degrees.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)

  Example:

         // Set the gun to turn right 15 degrees per turn
         setGunRotationRate(15);

         // Set the gun to turn left 9 degrees per turn
         // (overrides the previous order)
         setGunRotationRate(-9);

         ...
         // Executes the last setGunRotationRate()
         execute();

  Parameters:
    `gunRotationRate` - angle of the clockwise rotation, in degrees.
  See Also:
    `getGunRotationRate()`, `setVelocityRate(double)`, `setTurnRate(double)`, `setRadarRotationRate(double)`, `AdvancedRobot.setTurnGunRight(double)`, `AdvancedRobot.setTurnGunLeft(double)`

### getGunRotationRate

    public double getGunRotationRate()

  Gets the gun's clockwise rotation per turn, in degrees. Positive values means that the gun will turn to the right. Negative values means that the gun will turn to the left. If the value is 0, the gun will not turn.

  Returns:
    Angle of the clockwise rotation, in degrees.
  See Also:
    `setGunRotationRate(double)`

### setGunRotationRateRadians

    public void setGunRotationRateRadians(double gunRotationRate)

  Sets the gun's clockwise (right) rotation per turn, in radians.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)

  Example:

         // Set the gun to turn right pi / 16 radians per turn
         setGunRotationRateRadians(Math.PI / 16);

         // Set the gun to turn left pi / 12 radians per turn
         // (overrides the previous order)
         setGunRotationRateRadians(-Math.PI / 12);

         ...
         // Executes the last setGunRotationRateRadians()
         execute();

  Parameters:
    `gunRotationRate` - angle of the clockwise rotation, in radians.
  See Also:
    `getGunRotationRateRadians()`, `setVelocityRate(double)`, `setTurnRateRadians(double)`, `setRadarRotationRateRadians(double)`, `AdvancedRobot.setTurnGunRightRadians(double)`, `AdvancedRobot.setTurnGunLeftRadians(double)`

### getGunRotationRateRadians

    public double getGunRotationRateRadians()

  Gets the gun's clockwise rotation per turn, in radians. Positive values means that the gun will turn to the right. Negative values means that the gun will turn to the left. If the value is 0, the gun will not turn.

  Returns:
    Angle of the clockwise rotation, in radians.
  See Also:
    `setGunRotationRateRadians(double)`

### setRadarRotationRate

    public void setRadarRotationRate(double radarRotationRate)

  Sets the radar's clockwise (right) rotation per turn, in degrees.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)

  Example:

         // Set the radar to turn right 45 degrees per turn
         setRadarRotationRate(45);

         // Set the radar to turn left 15 degrees per turn
         // (overrides the previous order)
         setRadarRotationRate(-15);

         ...
         // Executes the last setRadarRotationRate()
         execute();

  Parameters:
    `radarRotationRate` - angle of the clockwise rotation, in degrees.
  See Also:
    `getRadarRotationRate()`, `setVelocityRate(double)`, `setTurnRate(double)`, `setGunRotationRate(double)`, `AdvancedRobot.setTurnRadarRight(double)`, `AdvancedRobot.setTurnRadarLeft(double)`

### getRadarRotationRate

    public double getRadarRotationRate()

  Gets the radar's clockwise rotation per turn, in degrees. Positive values means that the radar will turn to the right. Negative values means that the radar will turn to the left. If the value is 0, the radar will not turn.

  Returns:
    Angle of the clockwise rotation, in degrees.
  See Also:
    `setRadarRotationRate(double)`

### setRadarRotationRateRadians

    public void setRadarRotationRateRadians(double radarRotationRate)

  Sets the radar's clockwise (right) rotation per turn, in radians.

  This call returns immediately, and will not execute until you call execute() or take an action that executes.

  Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)

  Example:

         // Set the radar to turn right pi / 4 radians per turn
         setRadarRotationRateRadians(Math.PI / 4);

         // Set the radar to turn left pi / 8 radians per turn
         // (overrides the previous order)
         setRadarRotationRateRadians(-Math.PI / 8);

         ...
         // Executes the last setRadarRotationRateRadians()
         execute();

  Parameters:
    `radarRotationRate` - angle of the clockwise rotation, in radians.
  See Also:
    `getRadarRotationRateRadians()`, `setVelocityRate(double)`, `setTurnRateRadians(double)`, `setGunRotationRateRadians(double)`, `AdvancedRobot.setTurnRadarRightRadians(double)`, `AdvancedRobot.setTurnRadarLeftRadians(double)`

### getRadarRotationRateRadians

    public double getRadarRotationRateRadians()

  Gets the radar's clockwise rotation per turn, in radians. Positive values means that the radar will turn to the right. Negative values means that the radar will turn to the left. If the value is 0, the radar will not turn.

  Returns:
    Angle of the clockwise rotation, in radians.
  See Also:
    `setRadarRotationRateRadians(double)`

### execute

    public void execute()

  Executes any pending actions, or continues executing actions that are in process. This call returns after the actions have been started.

  Note that advanced robots must call this function in order to execute pending set* calls like e.g. `setVelocityRate()`, `setFire()`, `setTurnRate()` etc. Otherwise, these calls will never get executed.

  Any previous calls to "movement" functions outside of `RateControlRobot`, such as `setAhead()`, `setTurnLeft()`, `setTurnRadarLeftRadians()` etc. will be overridden when this method is called on this robot class.

  In this example the robot will move while turning:

         setVelocityRate(6);
         setTurnRate(7);

         while (true) {
             execute();
         }

  Overrides:
    `execute` in class `AdvancedRobot`

Copyright © 2013 Robocode. All Rights Reserved.