Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## robocode
Class AdvancedRobot

    java.lang.Object
      robocode._Robot
          robocode.Robot
              robocode._AdvancedRobot
                  robocode._AdvancedRadiansRobot
                      robocode.AdvancedRobot

All Implemented Interfaces:
  java.lang.Runnable

Direct Known Subclasses:
  TeamRobot

    public class AdvancedRobot

extends _AdvancedRadiansRobot

A more advanced type of robot than Robot that allows non-blocking calls, custom events, and writes to the filesystem.

If you have not already, you should create a `Robot` first.

Author:
  Mathew A. Nelson (original), Flemming N. Larsen (contributor), Robert D. Maupin (contributor)
See Also:
  `Robot`

Field Summary

Fields inherited from class robocode.Robot
`out`

Constructor Summary
`AdvancedRobot()`

Method Summary
`void` | `addCustomEvent(Condition condition)` Registers a custom event to be called when a condition is met.
`void` | `clearAllEvents()` Clears out any pending events immediately.
`void` | `execute()` Executes any pending actions, or continues executing actions that are in process.
`java.util.Vector<Event>` | `getAllEvents()` Returns a vector containing all events currently in the robot's queue.
`java.util.Vector<BulletHitBulletEvent>` | `getBulletHitBulletEvents()` Returns a vector containing all BulletHitBulletEvents currently in the robot's queue.
`java.util.Vector<BulletHitEvent>` | `getBulletHitEvents()` Returns a vector containing all BulletHitEvents currently in the robot's queue.
`java.util.Vector<BulletMissedEvent>` | `getBulletMissedEvents()` Returns a vector containing all BulletMissedEvents currently in the robot's queue.
`java.io.File` | `getDataDirectory()` Returns a file representing a data directory for the robot, which can be written to using `RobocodeFileOutputStream` or `RobocodeFileWriter`.
`java.io.File` | `getDataFile(java.lang.String filename)` Returns a file in your data directory that you can write to using `RobocodeFileOutputStream` or `RobocodeFileWriter`.
`long` | `getDataQuotaAvailable()` Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.
`double` | `getDistanceRemaining()` Returns the distance remaining in the robot's current move measured in pixels.
`int` | `getEventPriority(java.lang.String eventClass)` Returns the current priority of a class of events.
`double` | `getGunTurnRemaining()` Returns the angle remaining in the gun's turn, in degrees.
`java.util.Vector<HitByBulletEvent>` | `getHitByBulletEvents()` Returns a vector containing all HitByBulletEvents currently in the robot's queue.
`java.util.Vector<HitRobotEvent>` | `getHitRobotEvents()` Returns a vector containing all HitRobotEvents currently in the robot's queue.
`java.util.Vector<HitWallEvent>` | `getHitWallEvents()` Returns a vector containing all HitWallEvents currently in the robot's queue.
`double` | `getRadarTurnRemaining()` Returns the angle remaining in the radar's turn, in degrees.
`java.util.Vector<RobotDeathEvent>` | `getRobotDeathEvents()` Returns a vector containing all RobotDeathEvents currently in the robot's queue.
`java.util.Vector<ScannedRobotEvent>` | `getScannedRobotEvents()` Returns a vector containing all ScannedRobotEvents currently in the robot's queue.
`double` | `getTurnRemaining()` Returns the angle remaining in the robots's turn, in degrees.
`boolean` | `isAdjustGunForRobotTurn()` Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
`boolean` | `isAdjustRadarForGunTurn()` Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn.
`boolean` | `isAdjustRadarForRobotTurn()` Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
`void` | `onCustomEvent(CustomEvent event)` This method is called when a custom condition is met.
`void` | `onDeath(DeathEvent event)` This method is called if your robot dies.
`void` | `onSkippedTurn(SkippedTurnEvent event)` This method is called if the robot is using too much time between actions.
`void` | `removeCustomEvent(Condition condition)` Removes a custom event (specified by condition).
`void` | `setAhead(double distance)` Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place.
`void` | `setBack(double distance)` Sets the robot to move back by distance measured in pixels when the next execution takes place.
`void` | `setEventPriority(java.lang.String eventClass, int priority)` Sets the priority of a class of events.
`void` | `setFire(double power)` Sets the gun to fire a bullet when the next execution takes place.
`Bullet` | `setFireBullet(double power)` Sets the gun to fire a bullet when the next execution takes place.
`void` | `setInterruptible(boolean interruptible)` Call this during an event handler to allow new events of the same priority to restart the event handler.
`void` | `setMaxTurnRate(double newMaxTurnRate)` Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than `Rules.MAX_TURN_RATE` (10 degress/turn).
`void` | `setMaxVelocity(double newMaxVelocity)` Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than `Rules.MAX_VELOCITY` (8 pixels/turn).
`void` | `setResume()` Sets the robot to resume the movement stopped by stop() or setStop(), if any.
`void` | `setStop()` This call is identical to `Robot.stop()`, but returns immediately, and will not execute until you call execute() or take an action that executes.
`void` | `setStop(boolean overwrite)` This call is identical to `Robot.stop(boolean)`, but returns immediately, and will not execute until you call execute() or take an action that executes.
`void` | `setTurnGunLeft(double degrees)` Sets the robot's gun to turn left by degrees when the next execution takes place.
`void` | `setTurnGunRight(double degrees)` Sets the robot's gun to turn right by degrees when the next execution takes place.
`void` | `setTurnLeft(double degrees)` Sets the robot's body to turn left by degrees when the next execution takes place.
`void` | `setTurnRadarLeft(double degrees)` Sets the robot's radar to turn left by degrees when the next execution takes place.
`void` | `setTurnRadarRight(double degrees)` Sets the robot's radar to turn right by degrees when the next execution takes place.
`void` | `setTurnRight(double degrees)` Sets the robot's body to turn right by degrees when the next execution takes place.
`void` | `waitFor(Condition condition)` Does not return until a `Condition.test()` returns `true`.

Methods inherited from class robocode._AdvancedRadiansRobot
`getGunHeadingRadians, getGunTurnRemainingRadians, getHeadingRadians, getRadarHeadingRadians, getRadarTurnRemainingRadians, getTurnRemainingRadians, setTurnGunLeftRadians, setTurnGunRightRadians, setTurnLeftRadians, setTurnRadarLeftRadians, setTurnRadarRightRadians, setTurnRightRadians, turnGunLeftRadians, turnGunRightRadians, turnLeftRadians, turnRadarLeftRadians, turnRadarRightRadians, turnRightRadians`

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, finalize, fire, fireBullet, getBattleFieldHeight, getBattleFieldWidth, getEnergy, getGunCoolingRate, getGunHeading, getGunHeat, getHeading, getHeight, getName, getNumRounds, getOthers, getRadarHeading, getRoundNum, getTime, getVelocity, getWidth, getX, getY, onBulletHit, onBulletHitBullet, onBulletMissed, onHitByBullet, onHitRobot, onHitWall, onPaint, onRobotDeath, onScannedRobot, onWin, resume, run, scan, setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn, setAllColors, setBodyColor, setBulletColor, setColors, setColors, 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, setPeer, setRadarImageName, setRobotImageName, uninitializedException`

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

Constructor Detail

### AdvancedRobot

    public AdvancedRobot()

Method Detail

### getDistanceRemaining

    public double getDistanceRemaining()

  Returns the distance remaining in the robot's current move measured in pixels.

  This call returns both positive and negative values. Positive values means that the robot is currently moving forwards. Negative values means that the robot is currently moving backwards.

  Returns:
    the distance remaining in the robot's current move measured in pixels.

### setAhead

    public void setAhead(double distance)

  Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place.

  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 is set to move backward instead of forward.

  Example:

         // Set the robot to move 50 pixels ahead
         setAhead(50);

         // Set the robot to move 100 pixels back
         // (overrides the previous order)
         setAhead(-100);

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

  Parameters:
    `distance` - the distance to move ahead measured in pixels. If this value is negative, the robot will move back instead of ahead.

### setBack

    public void setBack(double distance)

  Sets the robot to move back by distance measured in pixels when the next execution takes place.

  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 is set to move forward instead of backward.

  Example:

         // Set the robot to move 50 pixels back
         setBack(50);

         // Set the robot to move 100 pixels ahead
         // (overrides the previous order)
         setBack(-100);

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

  Parameters:
    `distance` - the distance to move back measured in pixels. If this value is negative, the robot will move ahead instead of back.

### setTurnLeft

    public void setTurnLeft(double degrees)

  Sets the robot's body to turn left by degrees when the next execution takes place.

  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's body is set to turn right instead of left.

  Example:

         // Set the robot to turn 180 degrees to the left
         setTurnLeft(180);

         // Set the robot to turn 90 degrees to the right instead of left
         // (overrides the previous order)
         setTurnLeft(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's body to the left If this value is negative, the robot's body is set to turn to the right

### setTurnRight

    public void setTurnRight(double degrees)

  Sets the robot's body to turn right by degrees when the next execution takes place.

  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's body is set to turn left instead of right.

  Example:

         // Set the robot to turn 180 degrees to the right
         setTurnRight(180);

         // Set the robot to turn 90 degrees to the left instead of right
         // (overrides the previous order)
         setTurnRight(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's body to the right If this value is negative, the robot's body is set to turn to the left

### setFire

    public void setFire(double power)

  Sets the gun to fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing.

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

  The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

  The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call Rules#getBulletDamage(double)} for getting the damage that a bullet with a specific bullet power will do.

  The specified bullet power should be between `Rules.MIN_BULLET_POWER` and `Rules.MAX_BULLET_POWER`.

  Note that the gun cannot fire if the gun is overheated, meaning that `Robot.getGunHeat()` returns a value > 0.

  An event is generated when the bullet hits a robot, wall, or another bullet.

  Example:

         // Fire a bullet with maximum power if the gun is ready
         if (getGunHeat() == 0) {
             setFire(Rules.MAX_BULLET_POWER);
         }
         ...
         execute();

  Parameters:
    `power` - the amount of energy given to the bullet, and subtracted from the robot's energy.
  See Also:
    `setFireBullet(double)`, `Robot.fire(double)`, `Robot.fireBullet(double)`, `Robot.getGunHeat()`, `Robot.getGunCoolingRate()`, `Robot.onBulletHit(robocode.BulletHitEvent)`, `Robot.onBulletHitBullet(robocode.BulletHitBulletEvent)`, `Robot.onBulletMissed(robocode.BulletMissedEvent)`

### setFireBullet

    public Bullet setFireBullet(double power)

  Sets the gun to fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing.

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

  The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

  The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call `Rules.getBulletDamage(double)` for getting the damage that a bullet with a specific bullet power will do.

  The specified bullet power should be between `Rules.MIN_BULLET_POWER` and `Rules.MAX_BULLET_POWER`.

  Note that the gun cannot fire if the gun is overheated, meaning that `Robot.getGunHeat()` returns a value > 0.

  An event is generated when the bullet hits a robot, wall, or another bullet.

  Example:

         // Fire a bullet with maximum power if the gun is ready
         if (getGunHeat() == 0) {
             Bullet bullet = setFireBullet(Rules.MAX_BULLET_POWER);
         }
         ...
         execute();
         ...
         // Get the velocity of the bullet
         double bulletVelocity = bullet.getVelocity();

  Parameters:
    `power` - the amount of energy given to the bullet, and subtracted from the robot's energy.
  Returns:
    a `Bullet` that contains information about the bullet if it was actually fired, which can be used for tracking the bullet after it has been fired. If the bullet was not fired, `null` is returned.
  See Also:
    `setFire(double)`, `Bullet`, `Robot.fire(double)`, `Robot.fireBullet(double)`, `Robot.getGunHeat()`, `Robot.getGunCoolingRate()`, `Robot.onBulletHit(robocode.BulletHitEvent)`, `Robot.onBulletHitBullet(robocode.BulletHitBulletEvent)`, `Robot.onBulletMissed(robocode.BulletMissedEvent)`

### addCustomEvent

    public void addCustomEvent(Condition condition)

  Registers a custom event to be called when a condition is met.

  Example:

         addCustomEvent(
             new Condition("triggerhit") {
                 public boolean test() {
                     return (getEnergy() <= trigger);
                 };
             }
         );

  Parameters:
    `condition` - The condition that must be met.
  See Also:
    `Condition`

### clearAllEvents

    public void clearAllEvents()

  Clears out any pending events immediately.

### 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 setXXX calls like e.g. `setAhead(double)`, `setFire(double)`, `setTurnLeft(double)` etc. Otherwise, these calls will never get executed.

  In this example the robot will move while turning:

         setTurnRight(90);
         setAhead(100);
         execute();

         while (getDistanceRemaining() > 0 && getTurnRemaining() > 0) {
             execute();
         }

### getAllEvents

    public java.util.Vector<Event> getAllEvents()

  Returns a vector containing all events currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (Event e : getAllEvents()) {
             if (e instanceof HitRobotEvent) {
                 // do something with e
             } else if (e instanceof HitByBulletEvent) {
                 // do something else with e
             }
         }

  Returns:
    a vector containing all events currently in the robot's queue
  See Also:
    `Event`, `ScannedRobotEvent`, `BulletHitBulletEvent`, `BulletMissedEvent`, `HitByBulletEvent`, `HitRobotEvent`, `HitWallEvent`, `SkippedTurnEvent`, `CustomEvent`, `DeathEvent`, `WinEvent`, `MessageEvent`, `Robot.onScannedRobot(robocode.ScannedRobotEvent)`, `Robot.onBulletHit(robocode.BulletHitEvent)`, `Robot.onBulletHitBullet(robocode.BulletHitBulletEvent)`, `Robot.onBulletMissed(robocode.BulletMissedEvent)`, `Robot.onHitByBullet(robocode.HitByBulletEvent)`, `Robot.onHitRobot(robocode.HitRobotEvent)`, `Robot.onHitWall(robocode.HitWallEvent)`, `onSkippedTurn(robocode.SkippedTurnEvent)`, `onCustomEvent(robocode.CustomEvent)`, `onDeath(robocode.DeathEvent)`, `Robot.onRobotDeath(robocode.RobotDeathEvent)`, `Robot.onWin(robocode.WinEvent)`, `TeamRobot.onMessageReceived(robocode.MessageEvent)`

### getBulletHitBulletEvents

    public java.util.Vector<BulletHitBulletEvent> getBulletHitBulletEvents()

  Returns a vector containing all BulletHitBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (BulletHitBulletEvent e : getBulletHitBulletEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all BulletHitBulletEvents currently in the robot's queue
  See Also:
    `Robot.onBulletHitBullet(robocode.BulletHitBulletEvent)`, `BulletHitBulletEvent`

### getBulletHitEvents

    public java.util.Vector<BulletHitEvent> getBulletHitEvents()

  Returns a vector containing all BulletHitEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (BulletHitEvent : getBulletHitEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all BulletHitEvents currently in the robot's queue
  See Also:
    `Robot.onBulletHit(robocode.BulletHitEvent)`, `BulletHitEvent`

### getBulletMissedEvents

    public java.util.Vector<BulletMissedEvent> getBulletMissedEvents()

  Returns a vector containing all BulletMissedEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (BulletMissedEvent e : getBulletMissedEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all BulletMissedEvents currently in the robot's queue
  See Also:
    `Robot.onBulletMissed(robocode.BulletMissedEvent)`, `BulletMissedEvent`

### getDataDirectory

    public java.io.File getDataDirectory()

  Returns a file representing a data directory for the robot, which can be written to using `RobocodeFileOutputStream` or `RobocodeFileWriter`.

  The system will automatically create the directory for you, so you do not need to create it by yourself.

  Returns:
    a file representing the data directory for your robot
  See Also:
    `getDataFile(java.lang.String)`, `RobocodeFileOutputStream`

### getDataFile

    public java.io.File getDataFile(java.lang.String filename)

  Returns a file in your data directory that you can write to using `RobocodeFileOutputStream` or `RobocodeFileWriter`.

  The system will automatically create the directory for you, so you do not need to create it by yourself.

  Please notice that the max. size of your data file is set to 200000 (~195 KB).

  See the sample robots for examples.

  Parameters:
    `filename` - the file name of the data file
  Returns:
    a file representing the data file for your robot
  See Also:
    `getDataDirectory()`, `RobocodeFileOutputStream`, `RobocodeFileWriter`

### getDataQuotaAvailable

    public long getDataQuotaAvailable()

  Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.

  Returns:
    the amount of bytes left in the robot's data directory
  See Also:
    `getDataDirectory()`

### getEventPriority

    public int getEventPriority(java.lang.String eventClass)

  Returns the current priority of a class of events. An event priority is a value from 0 - 99. The higher value, the higher priority. The default priority is 80.

  Example:

         int myHitRobotPriority = getEventPriority("HitRobotEvent");

  Parameters:
    `eventClass` - the name of the event class (string)
  Returns:
    the current priority of a class of events
  See Also:
    `setEventPriority(java.lang.String, int)`

### getGunTurnRemaining

    public double getGunTurnRemaining()

  Returns the angle remaining in the gun's turn, in degrees.

  This call returns both positive and negative values. Positive values means that the gun is currently turning to the right. Negative values means that the gun is currently turning to the left.

  Returns:
    the angle remaining in the gun's turn, in degrees

### getHitByBulletEvents

    public java.util.Vector<HitByBulletEvent> getHitByBulletEvents()

  Returns a vector containing all HitByBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (HitByBulletEvent e : getHitByBulletEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all HitByBulletEvents currently in the robot's queue
  See Also:
    `Robot.onHitByBullet(robocode.HitByBulletEvent)`, `HitByBulletEvent`

### getHitRobotEvents

    public java.util.Vector<HitRobotEvent> getHitRobotEvents()

  Returns a vector containing all HitRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (HitRobotEvent e : getHitRobotEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all HitRobotEvents currently in the robot's queue
  See Also:
    `Robot.onHitRobot(robocode.HitRobotEvent)`, `HitRobotEvent`

### getHitWallEvents

    public java.util.Vector<HitWallEvent> getHitWallEvents()

  Returns a vector containing all HitWallEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (HitWallEvent e : getHitWallEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all HitWallEvents currently in the robot's queue
  See Also:
    `Robot.onHitWall(robocode.HitWallEvent)`, `HitWallEvent`

### getRadarTurnRemaining

    public double getRadarTurnRemaining()

  Returns the angle remaining in the radar's turn, in degrees.

  This call returns both positive and negative values. Positive values means that the radar is currently turning to the right. Negative values means that the radar is currently turning to the left.

  Returns:
    the angle remaining in the radar's turn, in degrees

### getRobotDeathEvents

    public java.util.Vector<RobotDeathEvent> getRobotDeathEvents()

  Returns a vector containing all RobotDeathEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (RobotDeathEvent e : getRobotDeathEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all RobotDeathEvents currently in the robot's queue
  See Also:
    `Robot.onRobotDeath(robocode.RobotDeathEvent)`, `RobotDeathEvent`

### getScannedRobotEvents

    public java.util.Vector<ScannedRobotEvent> getScannedRobotEvents()

  Returns a vector containing all ScannedRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.

  Example:

         for (ScannedRobotEvent e : getScannedRobotEvents()) {
            // do something with e
         }

  Returns:
    a vector containing all ScannedRobotEvents currently in the robot's queue
  See Also:
    `Robot.onScannedRobot(robocode.ScannedRobotEvent)`, `ScannedRobotEvent`

### getTurnRemaining

    public double getTurnRemaining()

  Returns the angle remaining in the robots's turn, in degrees.

  This call returns both positive and negative values. Positive values means that the robot is currently turning to the right. Negative values means that the robot is currently turning to the left.

  Returns:
    the angle remaining in the robots's turn, in degrees

### isAdjustGunForRobotTurn

    public boolean isAdjustGunForRobotTurn()

  Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.

  This call returns `true` if the gun is set to turn independent of the turn of the robot's body. Otherwise, `false` is returned, meaning that the gun is set to turn with the robot's body turn.

  Returns:
    `true` if the gun is set to turn independent of the robot turning; `false` if the gun is set to turn with the robot turning
  See Also:
    `Robot.setAdjustGunForRobotTurn(boolean)`

### isAdjustRadarForGunTurn

    public boolean isAdjustRadarForGunTurn()

  Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn.

  This call returns `true` if the radar is set to turn independent of the turn of the gun. Otherwise, `false` is returned, meaning that the radar is set to turn with the gun's turn.

  Returns:
    `true` if the radar is set to turn independent of the gun turning; `false` if the radar is set to turn with the gun turning
  See Also:
    `Robot.setAdjustRadarForGunTurn(boolean)`

### onCustomEvent

    public void onCustomEvent(CustomEvent event)

  This method is called when a custom condition is met.

  See the sample robots for examples of use.

  Parameters:
    `event` - the custom event that occured
  See Also:
    `addCustomEvent(robocode.Condition)`, `CustomEvent`, `Event`

### removeCustomEvent

    public void removeCustomEvent(Condition condition)

  Removes a custom event (specified by condition).

  See the sample robots for examples of use.

  Parameters:
    `condition` - the custom event to remove
  See Also:
    `addCustomEvent(robocode.Condition)`

### setEventPriority

    public void setEventPriority(java.lang.String eventClass,
                                 int priority)

  Sets the priority of a class of events.

  Events are sent to the onXXX handlers in order of priority. Higher priority events can interrupt lower priority events. For events with the same priority, newer events are always sent first. Valid priorities are 0 - 99, where 100 is reserved and 80 is the default priority.

  Example:

         setEventPriority("RobotDeathEvent", 15);

  The default priorities are, from lowest to highest:

               ScannedRobotEvent:     10
               HitRobotEvent:         20
               HitWallEvent:          30
               HitByBulletEvent:      40
               BulletHitEvent:        50
               BulletHitBulletEvent:  55
               BulletMissedEvent:     60
               RobotDeathEvent:       70
               MessageEvent:          75
               CustomEvent:           80
               SkippedTurnEvent:     100 (reserved)
               WinEvent:             100 (reserved)
               DeathEvent:           100 (reserved)

  Note that you cannot change the priority for events with the special priority value 100 (reserved) as these event are system events. Also note that you cannot change the priority of CustomEvent. Instead you must change the priority of the condition(s) for your custom event(s).

  Parameters:
    `eventClass` - the name of the event class (string) to set the priority for
    `priority` - the new priority for that event class
  See Also:
    `_Robot.setInterruptible(boolean)`

### setInterruptible

    public void setInterruptible(boolean interruptible)

  Call this during an event handler to allow new events of the same priority to restart the event handler.

  Example:

         onScannedRobot(ScannedRobotEvent e) {
             fire(1);
             setInterruptible(true);
             ahead(100); // If you see a robot while moving ahead,
                         // this handler will start from the top
                         // Without setInterruptible, we wouldn't
                         // receive scan events at all!
             // We'll only get here if we don't see a robot during the move.
             out.println("Ok, I can't see anyone");
         }

  Overrides:
    `setInterruptible` in class `_Robot`
  Parameters:
    `interruptible` - `true` if the event handler should be interrupted if new events of the same priority occurs; `false` otherwise

### setMaxTurnRate

    public void setMaxTurnRate(double newMaxTurnRate)

  Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than `Rules.MAX_TURN_RATE` (10 degress/turn).

  Parameters:
    `newMaxTurnRate` - the new maximum turn rate of the robot measured in degrees. Valid values are 0 - `Rules.MAX_TURN_RATE`

### setMaxVelocity

    public void setMaxVelocity(double newMaxVelocity)

  Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than `Rules.MAX_VELOCITY` (8 pixels/turn).

  Parameters:
    `newMaxVelocity` - the new maximum turn rate of the robot measured in pixels/turn. Valid values are 0 - `Rules.MAX_VELOCITY`

### setResume

    public void setResume()

  Sets the robot to resume the movement stopped by stop() or setStop(), if any.

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

  See Also:
    `setStop()`, `Robot.stop()`

### setStop

    public void setStop()

  This call is identical to `Robot.stop()`, but returns immediately, and will not execute until you call execute() or take an action that executes.

  If there is already movement saved from a previous stop, this will have no effect.

  This call is equivalent to calling setStop(false);

  See Also:
    `setStop(boolean)`, `setResume()`, `Robot.stop()`, `Robot.resume()`

### setStop

    public void setStop(boolean overwrite)

  This call is identical to `Robot.stop(boolean)`, but returns immediately, and will not execute until you call execute() or take an action that executes.

  If there is already movement saved from a previous stop, you can overwrite it by calling setStop(true).

  Parameters:
    `overwrite` - `true` if the movement saved from a previous stop should be owerwritten; `false` otherwise
  See Also:
    `setStop()`, `setResume()`, `Robot.stop()`, `Robot.resume()`

### setTurnGunLeft

    public void setTurnGunLeft(double degrees)

  Sets the robot's gun to turn left by degrees when the next execution takes place.

  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's gun is set to turn right instead of left.

  Example:

         // Set the gun to turn 180 degrees to the left
         setTurnGunLeft(180);

         // Set the gun to turn 90 degrees to the right instead of left
         // (overrides the previous order)
         setTurnGunLeft(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's gun to the left If this value is negative, the robot's gun is set to turn to the right
  See Also:
    `Robot.setAdjustGunForRobotTurn(boolean)`

### setTurnGunRight

    public void setTurnGunRight(double degrees)

  Sets the robot's gun to turn right by degrees when the next execution takes place.

  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's gun is set to turn left instead of right.

  Example:

         // Set the gun to turn 180 degrees to the right
         setTurnGunRight(180);

         // Set the gun to turn 90 degrees to the left instead of right
         // (overrides the previous order)
         setTurnGunRight(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's gun to the right If this value is negative, the robot's gun is set to turn to the left
  See Also:
    `Robot.setAdjustGunForRobotTurn(boolean)`

### setTurnRadarLeft

    public void setTurnRadarLeft(double degrees)

  Sets the robot's radar to turn left by degrees when the next execution takes place.

  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's radar is set to turn right instead of left.

  Example:

         // Set the radar to turn 180 degrees to the left
         setTurnRadarLeft(180);

         // Set the radar to turn 90 degrees to the right instead of left
         // (overrides the previous order)
         setTurnRadarLeft(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's radar to the left If this value is negative, the robot's radar is set to turn to the right
  See Also:
    `Robot.setAdjustRadarForRobotTurn(boolean)`, `Robot.setAdjustRadarForGunTurn(boolean)`

### setTurnRadarRight

    public void setTurnRadarRight(double degrees)

  Sets the robot's radar to turn right by degrees when the next execution takes place.

  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's radar is set to turn left instead of right.

  Example:

         // Set the radar to turn 180 degrees to the right
         setTurnRadarRight(180);

         // Set the radar to turn 90 degrees to the right instead of right
         // (overrides the previous order)
         setTurnRadarRight(-90);

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

  Parameters:
    `degrees` - the amount of degrees to turn the robot's radar to the right If this value is negative, the robot's radar is set to turn to the left
  See Also:
    `Robot.setAdjustRadarForRobotTurn(boolean)`, `Robot.setAdjustRadarForGunTurn(boolean)`

### waitFor

    public void waitFor(Condition condition)

  Does not return until a `Condition.test()` returns `true`.

  This call executes immediately.

  See the example robots for usage.

  Parameters:
    `condition` - the condition that must be met before this call returns

### isAdjustRadarForRobotTurn

    public boolean isAdjustRadarForRobotTurn()

  Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.

  This call returns `true` if the radar is set to turn independent of the turn of the robot. Otherwise, `false` is returned, meaning that the radar is set to turn with the robot's turn.

  Returns:
    `true` if the radar is set to turn independent of the robot turning; `false` if the radar is set to turn with the robot turning
  See Also:
    `Robot.setAdjustRadarForRobotTurn(boolean)`

### onDeath

    public void onDeath(DeathEvent event)

  This method is called if your robot dies.

  You should override it in your robot if you want to be informed of this event. Actions will have no effect if called from this section. The intent is to allow you to perform calculations or print something out when the robot is killed.

  Overrides:
    `onDeath` in class `Robot`
  Parameters:
    `event` - the death event set by the game
  See Also:
    `DeathEvent`, `Event`

### onSkippedTurn

    public void onSkippedTurn(SkippedTurnEvent event)

  This method is called if the robot is using too much time between actions. When this event occur, the robot's turn is skipped, meaning that it cannot take action anymore in this turn.

  If you receive 30 skipped turn event, your robot will be removed from the round and loose the round.

  You will only receive this event after taking an action. So a robot in an infinite loop will not receive any events, and will simply be stopped.

  No correctly working, reasonable robot should ever receive this event.

  Parameters:
    `event` - the skipped turn event set by the game
  See Also:
    `SkippedTurnEvent`, `Event`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD