Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
robocode._RobotBase
robocode._Robot
robocode.Robot
public class Robot
extends robocode._Robot
implements IInteractiveRobot, IPaintRobot, IBasicEvents2, IInteractiveEvents, IPaintEvents
Field Summary |
Fields inherited from class robocode._RobotBase | |
out |
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
Bullet |
|
IBasicEvents | |
double |
|
double |
|
double |
|
Graphics2D |
|
double |
|
double |
|
double |
|
double |
|
double |
|
IInteractiveEvents | |
String |
|
int |
|
int |
|
IPaintEvents | |
double |
|
Runnable | |
int |
|
long |
|
double |
|
double |
|
double |
|
double |
|
void |
|
void |
|
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected @Override |
|
Methods inherited from class robocode._Robot | |
String getGunImageName , String getRadarImageName , String getRobotImageName , double getGunCharge , double getLife , int getBattleNum , int getNumBattles , setInterruptible , void setGunImageName , void setRadarImageName , void setRobotImageName |
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.
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.
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.
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 callRules.getBulletDamage(double)
for getting the damage that a bullet with a specific bullet power will do. The specified bullet power should be betweenRules.MIN_BULLET_POWER
andRules.MAX_BULLET_POWER
. Note that the gun cannot fire if the gun is overheated, meaning thatgetGunHeat()
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.
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 callRules.getBulletDamage(double)
for getting the damage that a bullet with a specific bullet power will do. The specified bullet power should be betweenRules.MIN_BULLET_POWER
andRules.MAX_BULLET_POWER
. Note that the gun cannot fire if the gun is overheated, meaning thatgetGunHeat()
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.
public final IBasicEvents getBasicEventListener()
}
- Specified by:
- getBasicEventListener in interface IBasicRobot
public double getBattleFieldHeight()
Returns the height of the current battlefield measured in pixels.
- Returns:
- the height of the current battlefield measured in pixels.
public double getBattleFieldWidth()
Returns the width of the current battlefield measured in pixels.
- Returns:
- the width of the current battlefield measured in pixels.
public double getEnergy()
Returns the robot's current energy.
- Returns:
- the robot's current energy.
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)
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)
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()
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 bygetGunCoolingRate()
, 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)
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()
public double getHeight()
Returns the height of the robot measured in pixels.
- Returns:
- the height of the robot measured in pixels.
- See Also:
getWidth()
public final IInteractiveEvents getInteractiveEventListener()
}
- Specified by:
- getInteractiveEventListener in interface IInteractiveRobot
public String getName()
Returns the robot's name.
- Returns:
- the robot's name.
public int getNumRounds()
Returns the number of rounds in the current battle.
- Returns:
- the number of rounds in the current battle
- See Also:
getRoundNum()
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.
public final IPaintEvents getPaintEventListener()
}
- Specified by:
- getPaintEventListener in interface IPaintRobot
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()
public final Runnable getRobotRunnable()
}
- Specified by:
- getRobotRunnable in interface IBasicRobot
public int getRoundNum()
Returns the current round number (0 togetNumRounds()
- 1) of the battle.
- Returns:
- the current round number of the battle
- See Also:
getNumRounds()
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.
public double getVelocity()
Returns the velocity of the robot measured in pixels/turn. The maximum velocity of a robot is defined byRules.MAX_VELOCITY
(8 pixels / turn).
- Returns:
- the velocity of the robot measured in pixels/turn.
- See Also:
Rules.MAX_VELOCITY
public double getWidth()
Returns the width of the robot measured in pixels.
- Returns:
- the width of the robot measured in pixels.
- See Also:
getHeight()
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()
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()
public void onBattleEnded(BattleEndedEvent event)
- Specified by:
- onBattleEnded in interface IBasicEvents2
public void onBulletHit(BulletHitEvent event)
- Specified by:
- onBulletHit in interface IBasicEvents
public void onBulletHitBullet(BulletHitBulletEvent event)
- Specified by:
- onBulletHitBullet in interface IBasicEvents
public void onBulletMissed(BulletMissedEvent event)
- Specified by:
- onBulletMissed in interface IBasicEvents
public void onHitByBullet(HitByBulletEvent event)
- Specified by:
- onHitByBullet in interface IBasicEvents
public void onHitRobot(HitRobotEvent event)
- Specified by:
- onHitRobot in interface IBasicEvents
public void onKeyPressed(KeyEvent e)
- Specified by:
- onKeyPressed in interface IInteractiveEvents
public void onKeyReleased(KeyEvent e)
- Specified by:
- onKeyReleased in interface IInteractiveEvents
public void onKeyTyped(KeyEvent e)
- Specified by:
- onKeyTyped in interface IInteractiveEvents
public void onMouseClicked(MouseEvent e)
- Specified by:
- onMouseClicked in interface IInteractiveEvents
public void onMouseDragged(MouseEvent e)
- Specified by:
- onMouseDragged in interface IInteractiveEvents
public void onMouseEntered(MouseEvent e)
- Specified by:
- onMouseEntered in interface IInteractiveEvents
public void onMouseExited(MouseEvent e)
- Specified by:
- onMouseExited in interface IInteractiveEvents
public void onMouseMoved(MouseEvent e)
- Specified by:
- onMouseMoved in interface IInteractiveEvents
public void onMousePressed(MouseEvent e)
- Specified by:
- onMousePressed in interface IInteractiveEvents
public void onMouseReleased(MouseEvent e)
- Specified by:
- onMouseReleased in interface IInteractiveEvents
public void onMouseWheelMoved(MouseWheelEvent e)
- Specified by:
- onMouseWheelMoved in interface IInteractiveEvents
public void onRobotDeath(RobotDeathEvent event)
- Specified by:
- onRobotDeath in interface IBasicEvents
public void onScannedRobot(ScannedRobotEvent event)
- Specified by:
- onScannedRobot in interface IBasicEvents
public void resume()
Immediately resumes the movement you stopped bystop()
, if any. This call executes immediately, and does not return until it is complete.
- See Also:
stop()
,stop(boolean)
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); } }
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 causeonScannedRobot(ScannedRobotEvent)
to be called if you see a robot. There are 2 reasons to callscan()
manually:This call executes immediately.
- You want to scan after you stop moving.
- You want to interrupt the
onScannedRobot
event. This is more likely. If you are inonScannedRobot
and callscan()
, and you still see a robot, then the system will interrupt youronScannedRobot
event immediately and start it from the top.
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 callsetAdjustGunForRobotTurn(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. 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". SeesetAdjustRadarForGunTurn(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)
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 callsetAdjustRadarForGunTurn(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. 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: CallingsetAdjustRadarForGunTurn(boolean)
will automatically callsetAdjustRadarForRobotTurn(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.
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 callsetAdjustRadarForRobotTurn(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. 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.
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. You may only call this method one time per battle. Anull
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
public void setBodyColor(Color color)
Sets the color of the robot's body. Anull
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
public void setBulletColor(Color color)
Sets the color of the robot's bullets. Anull
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
public void setColors(Color bodyColor, Color gunColor, Color radarColor)
Sets the color of the robot's body, gun, and radar in the same time. You may only call this method one time per battle. Anull
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 colorgunColor
- the new gun colorradarColor
- the new radar color
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. You may only call this method one time per battle. Anull
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 colorgunColor
- the new gun colorradarColor
- the new radar colorbulletColor
- the new bullet colorscanArcColor
- the new scan arc color
- Since:
- 1.1.3
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, wherenull
or the empty string is used for removing this debug property.
- Since:
- 1.6.2
public void setGunColor(Color color)
Sets the color of the robot's gun. Anull
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
public void setRadarColor(Color color)
Sets the color of the robot's radar. Anull
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
public void setScanColor(Color color)
Sets the color of the robot's scan arc. Anull
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
public void stop()
Immediately stops all movement, and saves it for a call toresume()
. 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)
public void stop(boolean overwrite)
Immediately stops all movement, and saves it for a call toresume()
. If there is already movement saved from a previous stop, you can overwrite it by callingstop(true)
.
- Parameters:
overwrite
- If there is already movement saved from a previous stop, you can overwrite it by callingstop(true)
.
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. Ifdegrees
> 0 the robot's gun will turn left. Ifdegrees
<320 the robot's gun will turn right. Ifdegrees
= 0 the robot's gun will not turn, but execute.
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. Ifdegrees
> 0 the robot's gun will turn right. Ifdegrees
<320 the robot's gun will turn left. Ifdegrees
= 0 the robot's gun will not turn, but execute.
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. Ifdegrees
> 0 the robot will turn left. Ifdegrees
<320 the robot will turn right. Ifdegrees
= 0 the robot will not turn, but execute.
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. Ifdegrees
> 0 the robot's radar will turn left. Ifdegrees
<320 the robot's radar will turn right. Ifdegrees
= 0 the robot's radar will not turn, but execute.
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. Ifdegrees
> 0 the robot's radar will turn right. Ifdegrees
<320 the robot's radar will turn left. Ifdegrees
= 0 the robot's radar will not turn, but execute.
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. Ifdegrees
> 0 the robot will turn right. Ifdegrees
<320 the robot will turn left. Ifdegrees
= 0 the robot will not turn, but execute.
protected final @Override void finalize() throws Throwable
Called by the system to 'clean up' after your robot. You may not override this method.