## robocode.robotinterfaces.peer
Interface IAdvancedRobotPeer

All Superinterfaces:
  IBasicRobotPeer, IStandardRobotPeer

All Known Subinterfaces:
  ITeamRobotPeer

    public interface IAdvancedRobotPeer

extends IStandardRobotPeer

The advanced robot peer for advanced robot types like `AdvancedRobot` and `TeamRobot`.

A robot peer is the object that deals with game mechanics and rules, and makes sure your robot abides by them.

Since:
  1.6
Author:
  Pavel Savara (original), Flemming N. Larsen (javadoc)
See Also:
  `IBasicRobotPeer`, `IStandardRobotPeer`, `ITeamRobotPeer`, `IJuniorRobotPeer`

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 in the robot's event queue immediately.
`List<Event>` `getAllEvents()` Returns a vector containing all events currently in the robot's queue.
`List<BulletHitBulletEvent>` `getBulletHitBulletEvents()` Returns a vector containing all BulletHitBulletEvents currently in the robot's queue.
`List<BulletHitEvent>` `getBulletHitEvents()` Returns a vector containing all BulletHitEvents currently in the robot's queue.
`List<BulletMissedEvent>` `getBulletMissedEvents()` Returns a vector containing all BulletMissedEvents currently in the robot's queue.
`File` `getDataDirectory()` Returns a file representing a data directory for the robot, which can be written to using `RobocodeFileOutputStream` or `RobocodeFileWriter`.
`File` `getDataFile(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.
`int` `getEventPriority(String eventClass)` Returns the current priority of a class of events.
`List<HitByBulletEvent>` `getHitByBulletEvents()` Returns a vector containing all HitByBulletEvents currently in the robot's queue.
`List<HitRobotEvent>` `getHitRobotEvents()` Returns a vector containing all HitRobotEvents currently in the robot's queue.
`List<HitWallEvent>` `getHitWallEvents()` Returns a vector containing all HitWallEvents currently in the robot's queue.
`List<RobotDeathEvent>` `getRobotDeathEvents()` Returns a vector containing all RobotDeathEvents currently in the robot's queue.
`List<ScannedRobotEvent>` `getScannedRobotEvents()` Returns a vector containing all ScannedRobotEvents currently in the robot's queue.
`boolean` `isAdjustGunForBodyTurn()` Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
`boolean` `isAdjustRadarForBodyTurn()` Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn.
`boolean` `isAdjustRadarForGunTurn()` Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
`void` `removeCustomEvent(Condition condition)` Removes a custom event that was previously added by calling `addCustomEvent(Condition)`.
`void` `setEventPriority(String eventClass, int priority)` Sets the priority of a class of events.
`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` `setMove(double distance)` Sets the robot to move forward or backward by distance measured in pixels when the next execution takes place.
`void` `setResume()` Sets the robot to resume the movement stopped by `stop(boolean)` or `setStop(boolean)`, if any.
`void` `setStop(boolean overwrite)` This call is identical to `stop(boolean)`, but returns immediately, and will not execute until you call `execute()` or take an action that executes.
`void` `setTurnBody(double radians)` Sets the robot's body to turn right or left by radians when the next execution takes place.
`void` `setTurnGun(double radians)` Sets the robot's gun to turn right or left by radians when the next execution takes place.
`void` `setTurnRadar(double radians)` Sets the robot's radar to turn right or left by radians when the next execution takes place.
`void` `waitFor(Condition condition)` Does not return until a condition is met, i.e. when a `Condition.test()` returns `true`.

Methods inherited from interface robocode.robotinterfaces.peer.IStandardRobotPeer
`rescan, resume, setAdjustGunForBodyTurn, setAdjustRadarForBodyTurn, setAdjustRadarForGunTurn, stop, turnRadar`

Methods inherited from interface robocode.robotinterfaces.peer.IBasicRobotPeer

`execute, fire, getBattleFieldHeight, getBattleFieldWidth, getBodyHeading, getBodyTurnRemaining, getCall, getDistanceRemaining, getEnergy, getGunCoolingRate, getGunHeading, getGunHeat, getGunTurnRemaining, getName, getNumRounds, getOthers, getRadarHeading, getRadarTurnRemaining, getRoundNum, getTime, getVelocity, getX, getY, move, setBodyColor, setBulletColor, setCall, setFire, setGunColor, setRadarColor, setScanColor, turnBody, turnGun`

Method Detail

### isAdjustGunForBodyTurn

    boolean isAdjustGunForBodyTurn()

  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:
    `setAdjustGunForBodyTurn(boolean)`, `isAdjustRadarForBodyTurn()`, `isAdjustRadarForGunTurn()`

### isAdjustRadarForGunTurn

    boolean isAdjustRadarForGunTurn()

  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:
    `setAdjustRadarForBodyTurn(boolean)`, `isAdjustGunForBodyTurn()`, `isAdjustRadarForGunTurn()`

### isAdjustRadarForBodyTurn

    boolean isAdjustRadarForBodyTurn()

  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:
    `setAdjustRadarForGunTurn(boolean)`, `isAdjustGunForBodyTurn()`, `isAdjustRadarForBodyTurn()`

### setStop

    void setStop(boolean overwrite)

  This call is identical to `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 overwritten; `false` otherwise.
  See Also:
    `stop(boolean)`, `resume()`, `setResume()`, `execute()`

### setResume

    void setResume()

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

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

  See Also:
    `resume()`, `stop(boolean)`, `setStop(boolean)`, `execute()`

### setMove

    void setMove(double distance)

  Sets the robot to move forward or backward 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 positive values means that the robot is set to move forward, and negative values means that the robot is set to move backward. If 0 is given as input, the robot will stop its movement, but will have to decelerate till it stands still, and will thus not be able to stop its movement immediately, but eventually.

  Example:

         // Set the robot to move 50 pixels forward
         setMove(50);

         // Set the robot to move 100 pixels backward
         // (overrides the previous order)
         setMove(-100);

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

  Parameters:
    `distance` - the distance to move measured in pixels. If `distance` > 0 the robot is set to move forward. If `distance` < 0 the robot is set to move backward. If `distance` = 0 the robot is set to stop its movement.
  See Also:
    `move(double)`, `setMaxVelocity(double)`, `setTurnBody(double)`, `setTurnGun(double)`, `setTurnRadar(double)`

### setTurnBody

    void setTurnBody(double radians)

  Sets the robot's body to turn right or left by radians 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 positive values means that the robot's body is set to turn right, and negative values means that the robot's body is set to turn left. If 0 is given as input, the robot's body will stop turning.

  Example:

         // Set the robot's body to turn 180 degrees to the right
         setTurnBody(Math.PI);

         // Set the robot's body to turn 90 degrees to the left instead of right
         // (overrides the previous order)
         setTurnBody(-Math.PI / 2);

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

  Parameters:
    `radians` - the amount of radians to turn the robot's body. If `radians` > 0 the robot's body is set to turn right. If `radians` < 0 the robot's body is set to turn left. If `radians` = 0 the robot's body is set to stop turning.
  See Also:
    `turnBody(double)`, `setTurnGun(double)`, `setTurnRadar(double)`, `setMaxTurnRate(double)`, `setMove(double)`

### setTurnGun

    void setTurnGun(double radians)

  Sets the robot's gun to turn right or left by radians 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 positive values means that the robot's gun is set to turn right, and negative values means that the robot's gun is set to turn left. If 0 is given as input, the robot's gun will stop turning.

  Example:

         // Set the robot's gun to turn 180 degrees to the right
         setTurnGun(Math.PI);

         // Set the robot's gun to turn 90 degrees to the left instead of right
         // (overrides the previous order)
         setTurnGun(-Math.PI / 2);

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

  Parameters:
    `radians` - the amount of radians to turn the robot's gun. If `radians` > 0 the robot's gun is set to turn right. If `radians` < 0 the robot's gun is set to turn left. If `radians` = 0 the robot's gun is set to stop turning.
  See Also:
    `turnGun(double)`, `setTurnBody(double)`, `setTurnRadar(double)`, `setMove(double)`

### setTurnRadar

    void setTurnRadar(double radians)

  Sets the robot's radar to turn right or left by radians 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 positive values means that the robot's radar is set to turn right, and negative values means that the robot's radar is set to turn left. If 0 is given as input, the robot's radar will stop turning.

  Example:

         // Set the robot's radar to turn 180 degrees to the right
         setTurnRadar(Math.PI);

         // Set the robot's radar to turn 90 degrees to the left instead of right
         // (overrides the previous order)
         setTurnRadar(-Math.PI / 2);

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

  Parameters:
    `radians` - the amount of radians to turn the robot's radar. If `radians` > 0 the robot's radar is set to turn right. If `radians` < 0 the robot's radar is set to turn left. If `radians` = 0 the robot's radar is set to stop turning.
  See Also:
    `turnRadar(double)`, `setTurnBody(double)`, `setTurnGun(double)`, `setMove(double)`

### setMaxTurnRate

    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`
  See Also:
    `turnBody(double)`, `setTurnBody(double)`, `setMaxVelocity(double)`

### setMaxVelocity

    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`
  See Also:
    `move(double)`, `setMove(double)`, `setMaxTurnRate(double)`

### waitFor

    void waitFor(Condition condition)

  Does not return until a condition is met, i.e. when a `Condition.test()` returns `true`.

  This call executes immediately.

  See the `sample.Crazy` robot for how this method can be used.

  Parameters:
    `condition` - the condition that must be met before this call returns
  See Also:
    `Condition`, `Condition.test()`

### setInterruptible

    void setInterruptible(boolean interruptible)

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

  Example:

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

  Parameters:
    `interruptible` - `true` if the event handler should be interrupted if new events of the same priority occurs; `false` otherwise
  See Also:
    `setEventPriority(String, int)`, `onScannedRobot(ScannedRobotEvent)`

### setEventPriority

    void setEventPriority(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 highest to lowest:

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

  Note that you cannot change the priority for events with the special priority value -1 or 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
  Since:
    1.5, the priority of DeathEvent was changed from 100 to -1 in order to let robots process pending events on its event queue before it dies. When the robot dies, it will not be able to process events.
  See Also:
    `getEventPriority(String)`, `setInterruptible(boolean)`

### getEventPriority

    int getEventPriority(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(String, int)`

### addCustomEvent

    void addCustomEvent(Condition condition)

  Registers a custom event to be called when a condition is met. When you are finished with your condition or just want to remove it you must call `removeCustomEvent(Condition)`.

  Example:

         // Create the condition for our custom event
         Condition triggerHitCondition = new Condition("triggerhit") {
             public boolean test() {
                 return (getEnergy() <= trigger);
             };
         }

         // Add our custom event based on our condition
         addCustomEvent(triggerHitCondition);

  Parameters:
    `condition` - the condition that must be met.
  Throws:
    `NullPointerException` - if the condition parameter has been set to `null`.
  See Also:
    `Condition`, `removeCustomEvent(Condition)`

### removeCustomEvent

    void removeCustomEvent(Condition condition)

  Removes a custom event that was previously added by calling `addCustomEvent(Condition)`.

  Example:

         // Create the condition for our custom event
         Condition triggerHitCondition = new Condition("triggerhit") {
             public boolean test() {
                 return (getEnergy() <= trigger);
             };
         }

         // Add our custom event based on our condition
         addCustomEvent(triggerHitCondition);
         ...
         do something with your robot
         ...
         // Remove the custom event based on our condition
         removeCustomEvent(triggerHitCondition);

  Parameters:
    `condition` - the condition that was previous added and that must be removed now.
  Throws:
    `NullPointerException` - if the condition parameter has been set to `null`.
  See Also:
    `Condition`, `addCustomEvent(Condition)`

### clearAllEvents

    void clearAllEvents()

  Clears out any pending events in the robot's event queue immediately.

  See Also:
    `getAllEvents()`

### getAllEvents

    List<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 event : getAllEvents()) {
             if (event instanceof HitRobotEvent) {
                 // do something with the event
             } else if (event instanceof HitByBulletEvent) {
                 // do something with the event
             }
         }

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

### getBulletMissedEvents

    List<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 event : getBulletMissedEvents()) {
             // do something with the event
         }

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

### getBulletHitBulletEvents

    List<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 event : getBulletHitBulletEvents()) {
             // do something with the event
         }

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

### getBulletHitEvents

    List<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 event: getBulletHitEvents()) {
             // do something with the event
         }

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

### getHitByBulletEvents

    List<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 event : getHitByBulletEvents()) {
             // do something with the event
         }

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

### getHitRobotEvents

    List<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 event : getHitRobotEvents()) {
             // do something with the event
         }

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

### getHitWallEvents

    List<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 event : getHitWallEvents()) {
             // do something with the event
         }

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

### getRobotDeathEvents

    List<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 event : getRobotDeathEvents()) {
             // do something with the event
         }

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

### getScannedRobotEvents

    List<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 event : getScannedRobotEvents()) {
             // do something with the event
         }

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

### getDataDirectory

    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(String)`, `RobocodeFileOutputStream`, `RobocodeFileWriter`

### getDataFile

    File getDataFile(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.SittingDuck` to see an example of how to use this method.

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

### getDataQuotaAvailable

    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()`, `getDataFile(String)`