# Class Robot

java.lang.Object
robocode._RobotBase
robocode._Robot
robocode.Robot

All Implemented Interfaces:
  `Runnable, IBasicEvents, IBasicEvents2, IBasicEvents3, IBasicRobot, IInteractiveEvents, IInteractiveRobot, IPaintEvents, IPaintRobot`

Direct Known Subclasses:
  `_AdvancedRobot`

public class Robot extends _Robot implements IInteractiveRobot, IPaintRobot, IBasicEvents3, IInteractiveEvents, IPaintEvents
The basic robot class that you will extend to create your own robots.

Please note the following standards will be used:
heading - absolute angle in degrees with 0 facing up the screen, positive clockwise. 0 invalid input: '<'= heading invalid input: '<' 360.
bearing - relative angle to some object from your robot's heading, positive clockwise. -180 invalid input: '<' bearing invalid input: '<'= 180
All coordinates are expressed as (x,y).
All coordinates are positive.
The origin (0,0) is at the bottom left of the screen.
Positive x is right.
Positive y is up.

Author:
  Mathew A. Nelson (original), Flemming N. Larsen (contributor), Matthew Reeder (contributor), Stefan Westen (contributor), Pavel Savara (contributor)
See Also:
  - robocode.sourceforge.net
  - Building your first robot
  - `JuniorRobot`
  - `AdvancedRobot`
  - `TeamRobot`
  - `Droid`
  - `RateControlRobot`
  - `BorderSentry`

## Field Summary

### Fields inherited from class _RobotBase

`out`

## Constructor Summary

Constructors
Constructor
Description
`Robot()`
Constructs a new robot.

## Method Summary

Modifier and Type
Method
Description
`void`
`ahead(double distance)`
Immediately moves your robot ahead (forward) by distance measured in pixels.
`void`
`back(double distance)`
Immediately moves your robot backward by distance measured in pixels.
`void`
`doNothing()`
Do nothing this turn, meaning that the robot will skip it's turn.
`void`
`fire(double power)`
Immediately fires a bullet.
`Bullet`
`fireBullet(double power)`
Immediately fires a bullet.
`final IBasicEvents`
`getBasicEventListener()`
This method is called by the game to notify this robot about basic robot event.
`double`
`getBattleFieldHeight()`
Returns the height of the current battlefield measured in pixels.
`double`
`getBattleFieldWidth()`
Returns the width of the current battlefield measured in pixels.
`double`
`getEnergy()`
Returns the robot's current energy.
`Graphics2D`
`getGraphics()`
Returns a graphics context used for painting graphical items for the robot.
`double`
`getGunCoolingRate()`
Returns the rate at which the gun will cool down, i.e.
`double`
`getGunHeading()`
Returns the direction that the robot's gun is facing, in degrees.
`double`
`getGunHeat()`
Returns the current heat of the gun.
`double`
`getHeading()`
Returns the direction that the robot's body is facing, in degrees.
`double`
`getHeight()`
Returns the height of the robot measured in pixels.
`final IInteractiveEvents`
`getInteractiveEventListener()`
This method is called by the game to notify this robot about interactive events, i.e.
`String`
`getName()`
Returns the robot's name.
`int`
`getNumRounds()`
Returns the number of rounds in the current battle.
`int`
`getNumSentries()`
Returns how many sentry robots that are left in the current round.
`int`
`getOthers()`
Returns how many opponents that are left in the current round.
`final IPaintEvents`
`getPaintEventListener()`
This method is called by the game to notify this robot about painting events.
`double`
`getRadarHeading()`
Returns the direction that the robot's radar is facing, in degrees.
`final Runnable`
`getRobotRunnable()`
This method is called by the game to invoke the `run()` method of your robot, where the program of your robot is implemented.
`int`
`getRoundNum()`
Returns the current round number (0 to `getNumRounds()` - 1) of the battle.
`int`
`getSentryBorderSize()`
Returns the sentry border size for a `BorderSentry` that defines the how far a BorderSentry is allowed to move from the border edges measured in units.
Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this border area.
`long`
`getTime()`
Returns the game time of the current round, where the time is equal to the current turn in the round.
`double`
`getVelocity()`
Returns the velocity of the robot measured in pixels/turn.
`double`
`getWidth()`
Returns the width of the robot measured in pixels.
`double`
`getX()`
Returns the X position of the robot.
`double`
`getY()`
Returns the Y position of the robot.
`void`
`onBattleEnded(BattleEndedEvent event)`
This method is called after the end of the battle, even when the battle is aborted.
`void`
`onBulletHit(BulletHitEvent event)`
This method is called when one of your bullets hits another robot.
`void`
`onBulletHitBullet(BulletHitBulletEvent event)`
This method is called when one of your bullets hits another bullet.
`void`
`onBulletMissed(BulletMissedEvent event)`
This method is called when one of your bullets misses, i.e.
`void`
`onDeath(DeathEvent event)`
This method is called if your robot dies.
`void`
`onHitByBullet(HitByBulletEvent event)`
This method is called when your robot is hit by a bullet.
`void`
`onHitRobot(HitRobotEvent event)`
This method is called when your robot collides with another robot.
`void`
`onHitWall(HitWallEvent event)`
This method is called when your robot collides with a wall.
`void`
`onKeyPressed(KeyEvent e)`
This method is called when a key has been pressed.
`void`
`onKeyReleased(KeyEvent e)`
This method is called when a key has been released.
`void`
`onKeyTyped(KeyEvent e)`
This method is called when a key has been typed (pressed and released).
`void`
`onMouseClicked(MouseEvent e)`
This method is called when a mouse button has been clicked (pressed and released).
`void`
`onMouseDragged(MouseEvent e)`
This method is called when a mouse button has been pressed and then dragged.
`void`
`onMouseEntered(MouseEvent e)`
This method is called when the mouse has entered the battle view.
`void`
`onMouseExited(MouseEvent e)`
This method is called when the mouse has exited the battle view.
`void`
`onMouseMoved(MouseEvent e)`
This method is called when the mouse has been moved.
`void`
`onMousePressed(MouseEvent e)`
This method is called when a mouse button has been pressed.
`void`
`onMouseReleased(MouseEvent e)`
This method is called when a mouse button has been released.
`void`
`onMouseWheelMoved(MouseWheelEvent e)`
This method is called when the mouse wheel has been rotated.
`void`
`onPaint(Graphics2D g)`
This method is called every time the robot is painted.
`void`
`onRobotDeath(RobotDeathEvent event)`
This method is called when another robot dies.
`void`
`onRoundEnded(RoundEndedEvent event)`
This method is called after the end of a round.
`void`
`onScannedRobot(ScannedRobotEvent event)`
This method is called when your robot sees another robot, i.e.
`void`
`onStatus(StatusEvent e)`
This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time.
`void`
`onWin(WinEvent event)`
This method is called if your robot wins a battle.
`void`
`resume()`
Immediately resumes the movement you stopped by `stop()`, if any.
`void`
`run()`
The main method in every robot.
`void`
`scan()`
Scans for other robots.
`void`
`setAdjustGunForRobotTurn(boolean independent)`
Sets the gun to turn independent from the robot's turn.
`void`
`setAdjustRadarForGunTurn(boolean independent)`
Sets the radar to turn independent from the gun's turn.
`void`
`setAdjustRadarForRobotTurn(boolean independent)`
Sets the radar to turn independent from the robot's turn.
`void`
`setAllColors(Color color)`
Sets all the robot's color to the same color in the same time, i.e.
`void`
`setBodyColor(Color color)`
Sets the color of the robot's body.
`void`
`setBulletColor(Color color)`
Sets the color of the robot's bullets.
`void`
`setColors(Color bodyColor, Color gunColor, Color radarColor)`
Sets the color of the robot's body, gun, and radar in the same time.
`void`
`setColors(Color bodyColor, Color gunColor, Color radarColor, Color bulletColor, Color scanArcColor)`
Sets the color of the robot's body, gun, radar, bullet, and scan arc in the same time.
`void`
`setDebugProperty(String key, String value)`
Sets the debug property with the specified key to the specified value.
`void`
`setGunColor(Color color)`
Sets the color of the robot's gun.
`void`
`setRadarColor(Color color)`
Sets the color of the robot's radar.
`void`
`setScanColor(Color color)`
Sets the color of the robot's scan arc.
`void`
`stop()`
Immediately stops all movement, and saves it for a call to `resume()`.
`void`
`stop(boolean overwrite)`
Immediately stops all movement, and saves it for a call to `resume()`.
`void`
`turnGunLeft(double degrees)`
Immediately turns the robot's gun to the left by degrees.
`void`
`turnGunRight(double degrees)`
Immediately turns the robot's gun to the right by degrees.
`void`
`turnLeft(double degrees)`
Immediately turns the robot's body to the left by degrees.
`void`
`turnRadarLeft(double degrees)`
Immediately turns the robot's radar to the left by degrees.
`void`
`turnRadarRight(double degrees)`
Immediately turns the robot's radar to the right by degrees.
`void`
`turnRight(double degrees)`
Immediately turns the robot's body to the right by degrees.

### Methods inherited from class _Robot

`getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setInterruptible, setRadarImageName, setRobotImageName`

### Methods inherited from class _RobotBase

`finalize, setOut, setPeer`

### Methods inherited from class Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface IBasicRobot

`setOut, setPeer`

## Constructor Details

### Robot

public Robot()
Constructs a new robot.

## Method Details

### getRobotRunnable

public final Runnable getRobotRunnable()
This method is called by the game to invoke the `run()` method of your robot, where the program of your robot is implemented.}

Specified by:
  `getRobotRunnable` in interface `IBasicRobot`
Returns:
  a runnable implementation
See Also:
  - `Runnable.run()`

### getBasicEventListener

public final IBasicEvents getBasicEventListener()
This method is called by the game to notify this robot about basic robot event. Hence, this method must be implemented so it returns your `IBasicEvents` listener.}

Specified by:
  `getBasicEventListener` in interface `IBasicRobot`
Returns:
  listener to basic events or `null` if this robot should not receive the notifications.

### getInteractiveEventListener

public final IInteractiveEvents getInteractiveEventListener()
This method is called by the game to notify this robot about interactive events, i.e. keyboard and mouse events. Hence, this method must be implemented so it returns your `IInteractiveEvents` listener.}

Specified by:
  `getInteractiveEventListener` in interface `IInteractiveRobot`
Returns:
  listener to interactive events or `null` if this robot should not receive the notifications.

### getPaintEventListener

public final IPaintEvents getPaintEventListener()
This method is called by the game to notify this robot about painting events. Hence, this method must be implemented so it returns your `IPaintEvents` listener.}

Specified by:
  `getPaintEventListener` in interface `IPaintRobot`
Returns:
  listener to paint events or `null` if this robot should not receive the notifications.

### ahead

public void ahead(double distance)
Immediately moves your robot ahead (forward) by distance measured in pixels.

This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0.

If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot.

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:

      // Move the robot 100 pixels forward
      ahead(100);

      // Afterwards, move the robot 50 pixels backward
      ahead(-50);

Parameters:
  `distance` - the distance to move ahead measured in pixels. If this value is negative, the robot will move back instead of ahead.
See Also:
  - `back(double)`
  - `onHitWall(HitWallEvent)`
  - `onHitRobot(HitRobotEvent)`

### back

public void back(double distance)
Immediately moves your robot backward by distance measured in pixels.

This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0.

If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot.

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:

      // Move the robot 100 pixels backward
      back(100);

      // Afterwards, move the robot 50 pixels forward
      back(-50);

Parameters:
  `distance` - the distance to move back measured in pixels. If this value is negative, the robot will move ahead instead of back.
See Also:
  - `ahead(double)`
  - `onHitWall(HitWallEvent)`
  - `onHitRobot(HitRobotEvent)`

### getBattleFieldWidth

public double getBattleFieldWidth()
Returns the width of the current battlefield measured in pixels.

Returns:
  the width of the current battlefield measured in pixels.

### getBattleFieldHeight

public double getBattleFieldHeight()
Returns the height of the current battlefield measured in pixels.

Returns:
  the height of the current battlefield measured in pixels.

### getHeading

public double getHeading()
Returns the direction that the robot's body is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.

Returns:
  the direction that the robot's body is facing, in degrees.
See Also:
  - `getGunHeading()`
  - `getRadarHeading()`

### getHeight

public double getHeight()
Returns the height of the robot measured in pixels.

Returns:
  the height of the robot measured in pixels.
See Also:
  - `getWidth()`

### getWidth

public double getWidth()
Returns the width of the robot measured in pixels.

Returns:
  the width of the robot measured in pixels.
See Also:
  - `getHeight()`

### getName

public String getName()
Returns the robot's name.

Returns:
  the robot's name.

### getX

public double getX()
Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.

Returns:
  the X position of the robot.
See Also:
  - `getY()`

### getY

public double getY()
Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.

Returns:
  the Y position of the robot.
See Also:
  - `getX()`

### run

public void run()
The main method in every robot. You must override this to set up your robot's basic behavior.

Example:

      // A basic robot that moves around in a square
      public void run() {
          while (true) {
              ahead(100);
              turnRight(90);
          }
      }

Specified by:
  `run` in interface `Runnable`

### turnLeft

public void turnLeft(double degrees)
Immediately turns the robot's body to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

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:

      // Turn the robot 180 degrees to the left
      turnLeft(180);

      // Afterwards, turn the robot 90 degrees to the right
      turnLeft(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's body to the left. If `degrees` > 0 the robot will turn left. If `degrees` invalid input: '<' 0 the robot will turn right. If `degrees` = 0 the robot will not turn, but execute.
See Also:
  - `turnRight(double)`
  - `turnGunLeft(double)`
  - `turnGunRight(double)`
  - `turnRadarLeft(double)`
  - `turnRadarRight(double)`

### turnRight

public void turnRight(double degrees)
Immediately turns the robot's body to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

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:

      // Turn the robot 180 degrees to the right
      turnRight(180);

      // Afterwards, turn the robot 90 degrees to the left
      turnRight(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's body to the right. If `degrees` > 0 the robot will turn right. If `degrees` invalid input: '<' 0 the robot will turn left. If `degrees` = 0 the robot will not turn, but execute.
See Also:
  - `turnLeft(double)`
  - `turnGunLeft(double)`
  - `turnGunRight(double)`
  - `turnRadarLeft(double)`
  - `turnRadarRight(double)`

### doNothing

public void doNothing()
Do nothing this turn, meaning that the robot will skip it's turn.

This call executes immediately, and does not return until the turn is over.

### fire

public void fire(double power)
Immediately fires a bullet. The bullet will travel in the direction the gun is pointing.

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 `getGunHeat()` returns a value > 0.

A event is generated when the bullet hits a robot (`BulletHitEvent`), wall (`BulletMissedEvent`), or another bullet (`BulletHitBulletEvent`).

Example:

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

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

### fireBullet

public Bullet fireBullet(double power)
Immediately fires a bullet. The bullet will travel in the direction the gun is pointing.

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 `getGunHeat()` returns a value > 0.

A event is generated when the bullet hits a robot (`BulletHitEvent`), wall (`BulletMissedEvent`), or another bullet (`BulletHitBulletEvent`).

Example:

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

          // Get the velocity of the bullet
          if (bullet != null) {
              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:
  - `fire(double)`
  - `Bullet`
  - `getGunHeat()`
  - `getGunCoolingRate()`
  - `onBulletHit(BulletHitEvent)`
  - `onBulletHitBullet(BulletHitBulletEvent)`
  - `onBulletMissed(BulletMissedEvent)`

### getGunCoolingRate

public double getGunCoolingRate()
Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.

The gun cooling rate is default 0.1 / turn, but can be changed by the battle setup. So don't count on the cooling rate being 0.1!

Returns:
  the gun cooling rate
See Also:
  - `getGunHeat()`
  - `fire(double)`
  - `fireBullet(double)`

### getGunHeading

public double getGunHeading()
Returns the direction that the robot's gun is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.

Returns:
  the direction that the robot's gun is facing, in degrees.
See Also:
  - `getHeading()`
  - `getRadarHeading()`

### getGunHeat

public double getGunHeat()
Returns the current heat of the gun. The gun cannot fire unless this is 0. (Calls to fire will succeed, but will not actually fire unless getGunHeat() == 0).

The amount of gun heat generated when the gun is fired is 1 + (firePower / 5). Each turn the gun heat drops by the amount returned by `getGunCoolingRate()`, which is a battle setup.

Note that all guns are "hot" at the start of each round, where the gun heat is 3.

Returns:
  the current gun heat
See Also:
  - `getGunCoolingRate()`
  - `fire(double)`
  - `fireBullet(double)`

### getNumRounds

public int getNumRounds()
Returns the number of rounds in the current battle.

Returns:
  the number of rounds in the current battle
See Also:
  - `getRoundNum()`

### getSentryBorderSize

public int getSentryBorderSize()
Returns the sentry border size for a `BorderSentry` that defines the how far a BorderSentry is allowed to move from the border edges measured in units.
Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this border area.

Returns:
  the border size in units/pixels.
Since:
  1.9.0.0

### getOthers

public int getOthers()
Returns how many opponents that are left in the current round.

Returns:
  how many opponents that are left in the current round.

### getNumSentries

public int getNumSentries()
Returns how many sentry robots that are left in the current round.

Returns:
  how many sentry robots that are left in the current round.
Since:
  1.9.1.0

### getRadarHeading

public double getRadarHeading()
Returns the direction that the robot's radar is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.

Returns:
  the direction that the robot's radar is facing, in degrees.
See Also:
  - `getHeading()`
  - `getGunHeading()`

### getRoundNum

public int getRoundNum()
Returns the current round number (0 to `getNumRounds()` - 1) of the battle.

Returns:
  the current round number of the battle (zero indexed).
See Also:
  - `getNumRounds()`

### getTime

public long getTime()
Returns the game time of the current round, where the time is equal to the current turn in the round.

A battle consists of multiple rounds.

Time is reset to 0 at the beginning of every round.

Returns:
  the game time/turn of the current round.

### getVelocity

public double getVelocity()
Returns the velocity of the robot measured in pixels/turn.

The maximum velocity of a robot is defined by `Rules.MAX_VELOCITY` (8 pixels / turn).

Returns:
  the velocity of the robot measured in pixels/turn.
See Also:
  - `Rules.MAX_VELOCITY`

### onBulletHit

public void onBulletHit(BulletHitEvent event)
This method is called when one of your bullets hits another robot. You should override it in your robot if you want to be informed of this event.

Example:

      public void onBulletHit(BulletHitEvent event) {
          out.println("I hit " + event.getName() + "!");
      }

Specified by:
  `onBulletHit` in interface `IBasicEvents`
Parameters:
  `event` - the bullet-hit event set by the game
See Also:
  - `BulletHitEvent`
  - `Event`

### onBulletHitBullet

public void onBulletHitBullet(BulletHitBulletEvent event)
This method is called when one of your bullets hits another bullet. You should override it in your robot if you want to be informed of this event.

Example:

      public void onBulletHitBullet(BulletHitBulletEvent event) {
          out.println("I hit a bullet fired by " + event.getBullet().getName() + "!");
      }

Specified by:
  `onBulletHitBullet` in interface `IBasicEvents`
Parameters:
  `event` - the bullet-hit-bullet event set by the game
See Also:
  - `BulletHitBulletEvent`
  - `Event`

### onBulletMissed

public void onBulletMissed(BulletMissedEvent event)
This method is called when one of your bullets misses, i.e. hits a wall. You should override it in your robot if you want to be informed of this event.

Example:

      public void onBulletMissed(BulletMissedEvent event) {
          out.println("Drat, I missed.");
      }

Specified by:
  `onBulletMissed` in interface `IBasicEvents`
Parameters:
  `event` - the bullet-missed event set by the game
See Also:
  - `BulletMissedEvent`
  - `Event`

### 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.

Specified by:
  `onDeath` in interface `IBasicEvents`
Parameters:
  `event` - the death event set by the game
See Also:
  - `DeathEvent`
  - `WinEvent`
  - `RoundEndedEvent`
  - `BattleEndedEvent`
  - `Event`

### onHitByBullet

public void onHitByBullet(HitByBulletEvent event)
This method is called when your robot is hit by a bullet. You should override it in your robot if you want to be informed of this event.

Example:

      void onHitByBullet(HitByBulletEvent event) {
          out.println(event.getRobotName() + " hit me!");
      }

Specified by:
  `onHitByBullet` in interface `IBasicEvents`
Parameters:
  `event` - the hit-by-bullet event set by the game
See Also:
  - `HitByBulletEvent`
  - `Event`

### onHitRobot

public void onHitRobot(HitRobotEvent event)
This method is called when your robot collides with another robot. You should override it in your robot if you want to be informed of this event.

Example:

      void onHitRobot(HitRobotEvent event) {
          if (event.getBearing() > -90 invalid input: '&'invalid input: '&' event.getBearing() invalid input: '<'= 90) {
              back(100);
          } else {
              ahead(100);
          }
      }

      -- or perhaps, for a more advanced robot --

      public void onHitRobot(HitRobotEvent event) {
          if (event.getBearing() > -90 invalid input: '&'invalid input: '&' event.getBearing() invalid input: '<'= 90) {
              setBack(100);
          } else {
              setAhead(100);
          }
      }

The angle is relative to your robot's facing. So 0 is straight ahead of you.

This event can be generated if another robot hits you, in which case `event.isMyFault()` will return `false`. In this case, you will not be automatically stopped by the game -- but if you continue moving toward the robot you will hit it (and generate another event). If you are moving away, then you won't hit it.

Specified by:
  `onHitRobot` in interface `IBasicEvents`
Parameters:
  `event` - the hit-robot event set by the game
See Also:
  - `HitRobotEvent`
  - `Event`

### onHitWall

public void onHitWall(HitWallEvent event)
This method is called when your robot collides with a wall. You should override it in your robot if you want to be informed of this event.

The wall at the top of the screen is 0 degrees, right is 90 degrees, bottom is 180 degrees, left is 270 degrees. But this event is relative to your heading, so: The bearing is such that `turnRight` `(event.getBearing())` will point you perpendicular to the wall.

Example:

      void onHitWall(HitWallEvent event) {
          out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees.");
      }

Specified by:
  `onHitWall` in interface `IBasicEvents`
Parameters:
  `event` - the hit-wall event set by the game
See Also:
  - `HitWallEvent`
  - `Event`

### onRobotDeath

public void onRobotDeath(RobotDeathEvent event)
This method is called when another robot dies. You should override it in your robot if you want to be informed of this event.

Specified by:
  `onRobotDeath` in interface `IBasicEvents`
Parameters:
  `event` - The robot-death event set by the game
See Also:
  - `RobotDeathEvent`
  - `Event`

### onScannedRobot

public void onScannedRobot(ScannedRobotEvent event)
This method is called when your robot sees another robot, i.e. when the robot's radar scan "hits" another robot. You should override it in your robot if you want to be informed of this event. (Almost all robots should override this!)

This event is automatically called if there is a robot in range of your radar.

Note that the robot's radar can only see robot within the range defined by `Rules.RADAR_SCAN_RADIUS` (1200 pixels).

Also not that the bearing of the scanned robot is relative to your robot's heading.

Example:

      void onScannedRobot(ScannedRobotEvent event) {
          // Assuming radar and gun are aligned...
          if (event.getDistance() invalid input: '<' 100) {
              fire(3);
          } else {
              fire(1);
          }
      }

Note:
The game assists Robots in firing, as follows:

- If the gun and radar are aligned (and were aligned last turn),
- and the event is current,
- and you call fire() before taking any other actions, `fire()` will fire directly at the robot.

In essence, this means that if you can see a robot, and it doesn't move, then fire will hit it.

AdvancedRobots will NOT be assisted in this manner, and are expected to examine the event to determine if `fire()` would hit. (i.e. you are spinning your gun around, but by the time you get the event, your gun is 5 degrees past the robot).

Specified by:
  `onScannedRobot` in interface `IBasicEvents`
Parameters:
  `event` - the scanned-robot event set by the game
See Also:
  - `ScannedRobotEvent`
  - `Event`
  - `Rules.RADAR_SCAN_RADIUS`

### onWin

public void onWin(WinEvent event)
This method is called if your robot wins a battle.

Your robot could perform a victory dance here! :-)

Specified by:
  `onWin` in interface `IBasicEvents`
Parameters:
  `event` - the win event set by the game
See Also:
  - `DeathEvent`
  - `RoundEndedEvent`
  - `BattleEndedEvent`
  - `Event`

### onRoundEnded

public void onRoundEnded(RoundEndedEvent event)
This method is called after the end of a round. You should override it in your robot if you want to be informed of this event.

Example:

      public void onRoundEnded(RoundEndedEvent event) {
          out.println("The round has ended");
      }

Specified by:
  `onRoundEnded` in interface `IBasicEvents3`
Parameters:
  `event` - the RoundEndedEvent event set by the game
See Also:
  - `RoundEndedEvent`
  - `IBasicEvents2.onBattleEnded(BattleEndedEvent)`
  - `WinEvent`
  - `DeathEvent`
  - `Event`

### onBattleEnded

public void onBattleEnded(BattleEndedEvent event)
This method is called after the end of the battle, even when the battle is aborted. You should override it in your robot if you want to be informed of this event.

Example:

      public void onBattleEnded(BattleEndedEvent event) {
          out.println("The battle has ended");
      }

Specified by:
  `onBattleEnded` in interface `IBasicEvents2`
Parameters:
  `event` - the BattleEndedEvent set by the game
See Also:
  - `BattleEndedEvent`
  - `IBasicEvents3.onRoundEnded(RoundEndedEvent)`
  - `WinEvent`
  - `DeathEvent`
  - `Event`

### scan

public void scan()
Scans for other robots. This method is called automatically by the game, as long as the robot is moving, turning its body, turning its gun, or turning its radar.

Scan will cause `onScannedRobot(ScannedRobotEvent)` to be called if you see a robot.

There are 2 reasons to call `scan()` manually:

1. You want to scan after you stop moving.
2. You want to interrupt the `onScannedRobot` event. This is more likely. If you are in `onScannedRobot` and call `scan()`, and you still see a robot, then the system will interrupt your `onScannedRobot` event immediately and start it from the top.

This call executes immediately.

See Also:
  - `onScannedRobot(ScannedRobotEvent)`
  - `ScannedRobotEvent`

### setAdjustGunForRobotTurn

public void setAdjustGunForRobotTurn(boolean independent)
Sets the gun to turn independent from the robot's turn.

Ok, so this needs some explanation: The gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, then the gun will turn with it as it is mounted on top of the robot's body. To compensate for this, you can call `setAdjustGunForRobotTurn(true)`. When this is set, the gun will turn independent from the robot's turn, i.e. the gun will compensate for the robot's body turn.

Note: This method is additive until you reach the maximum the gun can turn. The "adjust" is added to the amount you set for turning the robot, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Example, assuming both the robot and gun start out facing up (0 degrees):

      // Set gun to turn with the robot's turn
      setAdjustGunForRobotTurn(false); // This is the default
      turnRight(90);
      // At this point, both the robot and gun are facing right (90 degrees)
      turnLeft(90);
      // Both are back to 0 degrees

      -- or --

      // Set gun to turn independent from the robot's turn
      setAdjustGunForRobotTurn(true);
      turnRight(90);
      // At this point, the robot is facing right (90 degrees), but the gun is still facing up.
      turnLeft(90);
      // Both are back to 0 degrees.

Note: The gun compensating this way does count as "turning the gun". See `setAdjustRadarForGunTurn(boolean)` for details.

Parameters:
  `independent` - `true` if the gun must turn independent from the robot's turn; `false` if the gun must turn with the robot's turn.
See Also:
  - `setAdjustRadarForGunTurn(boolean)`

### setAdjustRadarForRobotTurn

public void setAdjustRadarForRobotTurn(boolean independent)
Sets the radar to turn independent from the robot's turn.

Ok, so this needs some explanation: The radar is mounted on the gun, and the gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, the gun turns, as does the radar. Hence, if the robot turns 90 degrees to the right, then the gun and radar will turn with it as the radar is mounted on top of the gun. To compensate for this, you can call `setAdjustRadarForRobotTurn(true)`. When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the robot's turn.

Note: This method is additive until you reach the maximum the radar can turn. The "adjust" is added to the amount you set for turning the robot, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Example, assuming the robot, gun, and radar all start out facing up (0 degrees):

      // Set radar to turn with the robots's turn
      setAdjustRadarForRobotTurn(false); // This is the default
      turnRight(90);
      // At this point, the body, gun, and radar are all facing right (90 degrees);

      -- or --

      // Set radar to turn independent from the robot's turn
      setAdjustRadarForRobotTurn(true);
      turnRight(90);
      // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up.

Parameters:
  `independent` - `true` if the radar must turn independent from the robots's turn; `false` if the radar must turn with the robot's turn.
See Also:
  - `setAdjustGunForRobotTurn(boolean)`
  - `setAdjustRadarForGunTurn(boolean)`

### setAdjustRadarForGunTurn

public void setAdjustRadarForGunTurn(boolean independent)
Sets the radar to turn independent from the gun's turn.

Ok, so this needs some explanation: The radar is mounted on the robot's gun. So, normally, if the gun turns 90 degrees to the right, then the radar will turn with it as it is mounted on top of the gun. To compensate for this, you can call `setAdjustRadarForGunTurn(true)`. When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the gun's turn.

Note: This method is additive until you reach the maximum the radar can turn. The "adjust" is added to the amount you set for turning the gun, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Example, assuming both the gun and radar start out facing up (0 degrees):

      // Set radar to turn with the gun's turn
      setAdjustRadarForGunTurn(false); // This is the default
      turnGunRight(90);
      // At this point, both the radar and gun are facing right (90 degrees);

      -- or --

      // Set radar to turn independent from the gun's turn
      setAdjustRadarForGunTurn(true);
      turnGunRight(90);
      // At this point, the gun is facing right (90 degrees), but the radar is still facing up.

Note: Calling `setAdjustRadarForGunTurn(boolean)` will automatically call `setAdjustRadarForRobotTurn(boolean)` with the same value, unless you have already called it earlier. This behavior is primarily for backward compatibility with older Robocode robots.

Parameters:
  `independent` - `true` if the radar must turn independent from the gun's turn; `false` if the radar must turn with the gun's turn.
See Also:
  - `setAdjustRadarForRobotTurn(boolean)`
  - `setAdjustGunForRobotTurn(boolean)`

### setColors

public void setColors(Color bodyColor, Color gunColor, Color radarColor)
Sets the color of the robot's body, gun, and radar in the same time.

A `null` indicates the default (blue) color.

Example:

      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setColors(null, Color.RED, new Color(150, 0, 150));
          ...
      }

Parameters:
  `bodyColor` - the new body color
  `gunColor` - the new gun color
  `radarColor` - the new radar color
See Also:
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setColors

public void setColors(Color bodyColor, Color gunColor, Color radarColor, Color bulletColor, Color scanArcColor)
Sets the color of the robot's body, gun, radar, bullet, and scan arc in the same time.

A `null` indicates the default (blue) color for the body, gun, radar, and scan arc, but white for the bullet color.

Example:

      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setColors(null, Color.RED, Color.GREEN, null, new Color(150, 0, 150));
          ...
      }

Parameters:
  `bodyColor` - the new body color
  `gunColor` - the new gun color
  `radarColor` - the new radar color
  `bulletColor` - the new bullet color
  `scanArcColor` - the new scan arc color
Since:
  1.1.3
See Also:
  - `setColors(Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setAllColors

public void setAllColors(Color color)
Sets all the robot's color to the same color in the same time, i.e. the color of the body, gun, radar, bullet, and scan arc.

A `null` indicates the default (blue) color for the body, gun, radar, and scan arc, but white for the bullet color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setAllColors(Color.RED);
          ...
      }

Parameters:
  `color` - the new color for all the colors of the robot
Since:
  1.1.3
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setBodyColor

public void setBodyColor(Color color)
Sets the color of the robot's body.

A `null` indicates the default (blue) color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setBodyColor(Color.BLACK);
          ...
      }

Parameters:
  `color` - the new body color
Since:
  1.1.2
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setGunColor

public void setGunColor(Color color)
Sets the color of the robot's gun.

A `null` indicates the default (blue) color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setGunColor(Color.RED);
          ...
      }

Parameters:
  `color` - the new gun color
Since:
  1.1.2
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setRadarColor

public void setRadarColor(Color color)
Sets the color of the robot's radar.

A `null` indicates the default (blue) color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setRadarColor(Color.YELLOW);
          ...
      }

Parameters:
  `color` - the new radar color
Since:
  1.1.2
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setBulletColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setBulletColor

public void setBulletColor(Color color)
Sets the color of the robot's bullets.

A `null` indicates the default white color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setBulletColor(Color.GREEN);
          ...
      }

Parameters:
  `color` - the new bullet color
Since:
  1.1.2
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setScanColor(Color)`
  - `Color`

### setScanColor

public void setScanColor(Color color)
Sets the color of the robot's scan arc.

A `null` indicates the default (blue) color.

    Example:
      // Don't forget to import java.awt.Color at the top...
      import java.awt.Color;
      ...

      public void run() {
          setScanColor(Color.WHITE);
          ...
      }

Parameters:
  `color` - the new scan arc color
Since:
  1.1.2
See Also:
  - `setColors(Color, Color, Color)`
  - `setColors(Color, Color, Color, Color, Color)`
  - `setAllColors(Color)`
  - `setBodyColor(Color)`
  - `setGunColor(Color)`
  - `setRadarColor(Color)`
  - `setBulletColor(Color)`
  - `Color`

### stop

public void stop()
Immediately stops all movement, and saves it for a call to `resume()`. If there is already movement saved from a previous stop, this will have no effect.

This method is equivalent to `#stop(false)`.

See Also:
  - `resume()`
  - `stop(boolean)`

### stop

public void stop(boolean overwrite)
Immediately stops all movement, and saves it for a call to `resume()`. If there is already movement saved from a previous stop, you can overwrite it by calling `stop(true)`.

Parameters:
  `overwrite` - If there is already movement saved from a previous stop, you can overwrite it by calling `stop(true)`.
See Also:
  - `resume()`
  - `stop()`

### resume

public void resume()
Immediately resumes the movement you stopped by `stop()`, if any.

This call executes immediately, and does not return until it is complete.

See Also:
  - `stop()`
  - `stop(boolean)`

### turnGunLeft

public void turnGunLeft(double degrees)
Immediately turns the robot's gun to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

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:

      // Turn the robot's gun 180 degrees to the left
      turnGunLeft(180);

      // Afterwards, turn the robot's gun 90 degrees to the right
      turnGunLeft(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's gun to the left. If `degrees` > 0 the robot's gun will turn left. If `degrees` invalid input: '<' 0 the robot's gun will turn right. If `degrees` = 0 the robot's gun will not turn, but execute.
See Also:
  - `turnGunRight(double)`
  - `turnLeft(double)`
  - `turnRight(double)`
  - `turnRadarLeft(double)`
  - `turnRadarRight(double)`
  - `setAdjustGunForRobotTurn(boolean)`

### turnGunRight

public void turnGunRight(double degrees)
Immediately turns the robot's gun to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

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:

      // Turn the robot's gun 180 degrees to the right
      turnGunRight(180);

      // Afterwards, turn the robot's gun 90 degrees to the left
      turnGunRight(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's gun to the right. If `degrees` > 0 the robot's gun will turn right. If `degrees` invalid input: '<' 0 the robot's gun will turn left. If `degrees` = 0 the robot's gun will not turn, but execute.
See Also:
  - `turnGunLeft(double)`
  - `turnLeft(double)`
  - `turnRight(double)`
  - `turnRadarLeft(double)`
  - `turnRadarRight(double)`
  - `setAdjustGunForRobotTurn(boolean)`

### turnRadarLeft

public void turnRadarLeft(double degrees)
Immediately turns the robot's radar to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

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:

      // Turn the robot's radar 180 degrees to the left
      turnRadarLeft(180);

      // Afterwards, turn the robot's radar 90 degrees to the right
      turnRadarLeft(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's radar to the left. If `degrees` > 0 the robot's radar will turn left. If `degrees` invalid input: '<' 0 the robot's radar will turn right. If `degrees` = 0 the robot's radar will not turn, but execute.
See Also:
  - `turnRadarRight(double)`
  - `turnLeft(double)`
  - `turnRight(double)`
  - `turnGunLeft(double)`
  - `turnGunRight(double)`
  - `setAdjustRadarForRobotTurn(boolean)`
  - `setAdjustRadarForGunTurn(boolean)`

### turnRadarRight

public void turnRadarRight(double degrees)
Immediately turns the robot's radar to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

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:

      // Turn the robot's radar 180 degrees to the right
      turnRadarRight(180);

      // Afterwards, turn the robot's radar 90 degrees to the left
      turnRadarRight(-90);

Parameters:
  `degrees` - the amount of degrees to turn the robot's radar to the right. If `degrees` > 0 the robot's radar will turn right. If `degrees` invalid input: '<' 0 the robot's radar will turn left. If `degrees` = 0 the robot's radar will not turn, but execute.
See Also:
  - `turnRadarLeft(double)`
  - `turnLeft(double)`
  - `turnRight(double)`
  - `turnGunLeft(double)`
  - `turnGunRight(double)`
  - `setAdjustRadarForRobotTurn(boolean)`
  - `setAdjustRadarForGunTurn(boolean)`

### getEnergy

public double getEnergy()
Returns the robot's current energy.

Returns:
  the robot's current energy.

### getGraphics

public Graphics2D getGraphics()
Returns a graphics context used for painting graphical items for the robot.

This method is very useful for debugging your robot.

Note that the robot will only be painted if the "Paint" is enabled on the robot's console window; otherwise the robot will never get painted (the reason being that all robots might have graphical items that must be painted, and then you might not be able to tell what graphical items that have been painted for your robot).

Also note that the coordinate system for the graphical context where you paint items fits for the Robocode coordinate system where (0, 0) is at the bottom left corner of the battlefield, where X is towards right and Y is upwards.

Returns:
  a graphics context used for painting graphical items for the robot.
Since:
  1.6.1
See Also:
  - `onPaint(Graphics2D)`

### setDebugProperty

public void setDebugProperty(String key, String value)
Sets the debug property with the specified key to the specified value.

This method is very useful when debugging or reviewing your robot as you will be able to see this property displayed in the robot console for your robots under the Debug Properties tab page.

Parameters:
  `key` - the name/key of the debug property.
  `value` - the new value of the debug property, where `null` or the empty string is used for removing this debug property.
Since:
  1.6.2

### onPaint

public void onPaint(Graphics2D g)
This method is called every time the robot is painted. You should override this method if you want to draw items for your robot on the battle field, e.g. targets, virtual bullets etc.

This method is very useful for debugging your robot.

Note that the robot will only be painted if the "Paint" is enabled on the robot's console window; otherwise the robot will never get painted (the reason being that all robots might have graphical items that must be painted, and then you might not be able to tell what graphical items that have been painted for your robot).

Also note that the coordinate system for the graphical context where you paint items fits for the Robocode coordinate system where (0, 0) is at the bottom left corner of the battlefield, where X is towards right and Y is upwards.

Specified by:
  `onPaint` in interface `IPaintEvents`
Parameters:
  `g` - the graphics context to use for painting graphical items for the robot.
See Also:
  - `Graphics2D`

### onKeyPressed

public void onKeyPressed(KeyEvent e)
This method is called when a key has been pressed.

See the `sample.Interactive` robot for an example of how to use key events.

Specified by:
  `onKeyPressed` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `KeyListener.keyPressed(KeyEvent)`
  - `IInteractiveEvents.onKeyReleased(KeyEvent)`
  - `IInteractiveEvents.onKeyTyped(KeyEvent)`

### onKeyReleased

public void onKeyReleased(KeyEvent e)
This method is called when a key has been released.

See the `sample.Interactive` robot for an example of how to use key events.

Specified by:
  `onKeyReleased` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `KeyListener.keyReleased(KeyEvent)`
  - `IInteractiveEvents.onKeyPressed(KeyEvent)`
  - `IInteractiveEvents.onKeyTyped(KeyEvent)`

### onKeyTyped

public void onKeyTyped(KeyEvent e)
This method is called when a key has been typed (pressed and released).

See the `sample.Interactive` robot for an example of how to use key events.

Specified by:
  `onKeyTyped` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `KeyListener.keyTyped(KeyEvent)`
  - `IInteractiveEvents.onKeyPressed(KeyEvent)`
  - `IInteractiveEvents.onKeyReleased(KeyEvent)`

### onMouseClicked

public void onMouseClicked(MouseEvent e)
This method is called when a mouse button has been clicked (pressed and released).

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseClicked` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseListener.mouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseEntered

public void onMouseEntered(MouseEvent e)
This method is called when the mouse has entered the battle view.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseEntered` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseListener.mouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseExited

public void onMouseExited(MouseEvent e)
This method is called when the mouse has exited the battle view.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseExited` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseListener.mouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMousePressed

public void onMousePressed(MouseEvent e)
This method is called when a mouse button has been pressed.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMousePressed` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseListener.mousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseReleased

public void onMouseReleased(MouseEvent e)
This method is called when a mouse button has been released.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseReleased` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseListener.mouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseMoved

public void onMouseMoved(MouseEvent e)
This method is called when the mouse has been moved.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseMoved` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseMotionListener.mouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseDragged

public void onMouseDragged(MouseEvent e)
This method is called when a mouse button has been pressed and then dragged.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseDragged` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseMotionListener.mouseDragged(MouseEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseWheelMoved(MouseWheelEvent)`

### onMouseWheelMoved

public void onMouseWheelMoved(MouseWheelEvent e)
This method is called when the mouse wheel has been rotated.

See the `sample.Interactive` robot for an example of how to use mouse events.

Specified by:
  `onMouseWheelMoved` in interface `IInteractiveEvents`
Parameters:
  `e` - holds details about current event
See Also:
  - `MouseWheelListener.mouseWheelMoved(MouseWheelEvent)`
  - `IInteractiveEvents.onMouseMoved(MouseEvent)`
  - `IInteractiveEvents.onMousePressed(MouseEvent)`
  - `IInteractiveEvents.onMouseReleased(MouseEvent)`
  - `IInteractiveEvents.onMouseClicked(MouseEvent)`
  - `IInteractiveEvents.onMouseEntered(MouseEvent)`
  - `IInteractiveEvents.onMouseExited(MouseEvent)`
  - `IInteractiveEvents.onMouseDragged(MouseEvent)`

### onStatus

public void onStatus(StatusEvent e)
This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time.

The main benefit of this method is that you'll automatically receive all current data values of the robot like e.g. the x and y coordinate, heading, gun heat etc., which are grouped into the exact same time/turn.

This is the only way to map the robots data values to a specific time. For example, it is not possible to determine the exact time of the robot's heading by calling first calling `getTime()` and then `getHeading()` afterwards, as the time might change after between the `getTime()` and `getHeading()` call.

Specified by:
  `onStatus` in interface `IBasicEvents`
Parameters:
  `e` - the event containing the robot status at the time it occurred.
See Also:
  - `StatusEvent`
  - `Event`