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
robocode._AdvancedRobot
robocode._AdvancedRadiansRobot
robocode.AdvancedRobot
public class AdvancedRobot
extends robocode._AdvancedRadiansRobot
implements IAdvancedRobot, IAdvancedEvents
Robot
first.
robocode.sourceforge.net
,
Building your first robot
, JuniorRobot
, Robot
, TeamRobot
, Droid
Field Summary |
Fields inherited from class robocode._RobotBase | |
out |
Method Summary | |
void |
|
void |
|
void |
|
IAdvancedEvents |
|
Vector |
|
Vector |
|
Vector |
|
Vector |
|
File |
|
File |
|
long |
|
double |
|
int |
|
double |
|
double |
|
double |
|
double |
|
Vector |
|
Vector |
|
Vector |
|
double |
|
double |
|
double |
|
Vector |
|
Vector |
|
Vector |
|
double |
|
double |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Bullet |
|
void |
|
void |
|
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
@Override |
|
@Override |
|
void |
Methods inherited from class robocode._AdvancedRadiansRobot | |
getGunHeadingRadians , getGunTurnRemainingRadians , getHeadingRadians , getRadarHeadingRadians , getRadarTurnRemainingRadians , getTurnRemainingRadians , setTurnGunLeftRadians , setTurnGunRightRadians , setTurnLeftRadians , setTurnRadarLeftRadians , setTurnRadarRightRadians , setTurnRightRadians , turnGunLeftRadians , turnGunRightRadians , turnLeftRadians , turnRadarLeftRadians , turnRadarRightRadians , turnRightRadians |
Methods inherited from class robocode._Robot | |
String getGunImageName , String getRadarImageName , String getRobotImageName , double getGunCharge , double getLife , int getBattleNum , int getNumBattles , setInterruptible , void setGunImageName , void setRadarImageName , void setRobotImageName |
public 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 callremoveCustomEvent(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.
- See Also:
Condition
,removeCustomEvent(Condition)
public void clearAllEvents()
Clears out any pending events in the robot's event queue immediately.
- See Also:
getAllEvents()
public void execute()
Executes any pending actions, or continues executing actions that are in process. This call returns after the actions have been started. Note that advanced robots must call this function in order to execute pending set* calls like e.g.setAhead(double)
,setFire(double)
,setTurnLeft(double)
etc. Otherwise, these calls will never get executed. In this example the robot will move while turning:setTurnRight(90); setAhead(100); execute(); while (getDistanceRemaining() > 0 && getTurnRemaining() > 0) { execute(); }
public final IAdvancedEvents getAdvancedEventListener()
Do not call this method!
- Specified by:
- getAdvancedEventListener in interface IAdvancedRobot
public VectorgetAllEvents()
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
public VectorgetBulletHitBulletEvents()
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
public VectorgetBulletHitEvents()
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
public VectorgetBulletMissedEvents()
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
public File getDataDirectory()
Returns a file representing a data directory for the robot, which can be written to usingRobocodeFileOutputStream
orRobocodeFileWriter
. 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
public File getDataFile(String filename)
Returns a file in your data directory that you can write to usingRobocodeFileOutputStream
orRobocodeFileWriter
. 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 thesample.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
public long getDataQuotaAvailable()
Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.
- Returns:
- the amount of bytes left in the robot's data directory
- See Also:
getDataDirectory()
,getDataFile(String)
public double getDistanceRemaining()
Returns the distance remaining in the robot's current move measured in pixels. This call returns both positive and negative values. Positive values means that the robot is currently moving forwards. Negative values means that the robot is currently moving backwards. If the returned value is 0, the robot currently stands still.
- Returns:
- the distance remaining in the robot's current move measured in pixels.
public 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. Example:int myHitRobotPriority = getEventPriority("HitRobotEvent");The default priorities are, from highest to lowest:BattleEndedEvent
: 100 (reserved)WinEvent
: 100 (reserved)SkippedTurnEvent
: 100 (reserved)StatusEvent
: 99 Key and mouse events: 98CustomEvent
: 80 (default value)MessageEvent
: 75RobotDeathEvent
: 70BulletMissedEvent
: 60BulletHitBulletEvent
: 55BulletHitEvent
: 50HitByBulletEvent
: 40HitWallEvent
: 30HitRobotEvent
: 20ScannedRobotEvent
: 10PaintEvent
: 5DeathEvent
: -1 (reserved)
- Parameters:
eventClass
- the name of the event class (string)
- Returns:
- the current priority of a class of events
- See Also:
setEventPriority(String,int)
public double getGunHeadingRadians()
Returns the direction that the robot's gun is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded). Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 4 means West.
- Overrides:
- getGunHeadingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the direction that the robot's gun is facing, in radians.
- See Also:
getGunHeadingDegrees()
,getHeadingRadians()
,getRadarHeadingRadians()
public double getGunTurnRemaining()
Returns the angle remaining in the gun's turn, in degrees. This call returns both positive and negative values. Positive values means that the gun is currently turning to the right. Negative values means that the gun is currently turning to the left. If the returned value is 0, the gun is currently not turning.
- Returns:
- the angle remaining in the gun's turn, in degrees
public double getGunTurnRemainingRadians()
Returns the angle remaining in the gun's turn, in radians. This call returns both positive and negative values. Positive values means that the gun is currently turning to the right. Negative values means that the gun is currently turning to the left.
- Overrides:
- getGunTurnRemainingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the angle remaining in the gun's turn, in radians
public double getHeadingRadians()
Returns the direction that the robot's body is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded). Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 4 means West.
- Overrides:
- getHeadingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the direction that the robot's body is facing, in radians.
- See Also:
getHeadingDegrees()
,getGunHeadingRadians()
,getRadarHeadingRadians()
public VectorgetHitByBulletEvents()
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
public VectorgetHitRobotEvents()
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()
public VectorgetHitWallEvents()
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()
public double getRadarHeadingRadians()
Returns the direction that the robot's radar is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded). Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 4 means West.
- Overrides:
- getRadarHeadingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the direction that the robot's radar is facing, in radians.
- See Also:
getRadarHeadingDegrees()
,getHeadingRadians()
,getGunHeadingRadians()
public double getRadarTurnRemaining()
Returns the angle remaining in the radar's turn, in degrees. This call returns both positive and negative values. Positive values means that the radar is currently turning to the right. Negative values means that the radar is currently turning to the left. If the returned value is 0, the radar is currently not turning.
- Returns:
- the angle remaining in the radar's turn, in degrees
public double getRadarTurnRemainingRadians()
Returns the angle remaining in the radar's turn, in radians. This call returns both positive and negative values. Positive values means that the radar is currently turning to the right. Negative values means that the radar is currently turning to the left.
- Overrides:
- getRadarTurnRemainingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the angle remaining in the radar's turn, in radians
public VectorgetRobotDeathEvents()
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
public VectorgetScannedRobotEvents()
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
public VectorgetStatusEvents()
Returns a vector containing all StatusEvents currently in the robot's queue. You might, for example, call this while processing another event. Example:for (StatusEvent event : getStatusEvents()) { // do something with the event }
- Returns:
- a vector containing all StatusEvents currently in the robot's queue
- Since:
- 1.6.1
- See Also:
onStatus(StatusEvent)
,StatusEvent
,getAllEvents()
public double getTurnRemaining()
Returns the angle remaining in the robots's turn, in degrees. This call returns both positive and negative values. Positive values means that the robot is currently turning to the right. Negative values means that the robot is currently turning to the left. If the returned value is 0, the robot is currently not turning.
- Returns:
- the angle remaining in the robots's turn, in degrees
public double getTurnRemainingRadians()
Returns the angle remaining in the robot's turn, in radians. This call returns both positive and negative values. Positive values means that the robot is currently turning to the right. Negative values means that the robot is currently turning to the left.
- Overrides:
- getTurnRemainingRadians in interface robocode._AdvancedRadiansRobot
- Returns:
- the angle remaining in the robot's turn, in radians
public boolean isAdjustGunForRobotTurn()
Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. This call returnstrue
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
public boolean isAdjustRadarForGunTurn()
Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn. This call returnstrue
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
public boolean isAdjustRadarForRobotTurn()
Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. This call returnstrue
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
public void onCustomEvent(CustomEvent event)
- Specified by:
- onCustomEvent in interface IAdvancedEvents
public void onSkippedTurn(SkippedTurnEvent event)
- Specified by:
- onSkippedTurn in interface IAdvancedEvents
public void removeCustomEvent(Condition condition)
Removes a custom event that was previously added by callingaddCustomEvent(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.
- See Also:
Condition
,addCustomEvent(Condition)
public void setAhead(double distance)
Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place. This call returns immediately, and will not execute until you callexecute()
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 ahead, and negative values means that the robot is set to move back. 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 ahead setAhead(50); // Set the robot to move 100 pixels back // (overrides the previous order) setAhead(-100); ... // Executes the last setAhead() execute();
- Parameters:
distance
- the distance to move measured in pixels. Ifdistance
> 0 the robot is set to move ahead. Ifdistance
<320 the robot is set to move back. Ifdistance
= 0 the robot is set to stop its movement.
- See Also:
ahead(double)
,back(double)
,setBack(double)
public void setBack(double distance)
Sets the robot to move back by distance measured in pixels when the next execution takes place. This call returns immediately, and will not execute until you callexecute()
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 back, and negative values means that the robot is set to move ahead. 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 back setBack(50); // Set the robot to move 100 pixels ahead // (overrides the previous order) setBack(-100); ... // Executes the last setBack() execute();
- Parameters:
distance
- the distance to move measured in pixels. Ifdistance
> 0 the robot is set to move back. Ifdistance
<320 the robot is set to move ahead. Ifdistance
= 0 the robot is set to stop its movement.
- See Also:
back(double)
,ahead(double)
,setAhead(double)
public 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: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).WinEvent
: 100 (reserved)SkippedTurnEvent
: 100 (reserved)StatusEvent
: 99CustomEvent
: 80MessageEvent
: 75RobotDeathEvent
: 70BulletMissedEvent
: 60BulletHitBulletEvent
: 55BulletHitEvent
: 50HitByBulletEvent
: 40HitWallEvent
: 30HitRobotEvent
: 20ScannedRobotEvent
: 10PaintEvent
: 5DeathEvent
: -1 (reserved)
- Parameters:
eventClass
- the name of the event class (string) to set the priority forpriority
- 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.
public void setFire(double power)
Sets the gun to fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing. This call returns immediately, and will not execute until you call execute() or take an action that executes. The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot. The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call Rules#getBulletDamage(double)} for getting the damage that a bullet with a specific bullet power will do. The specified bullet power should be 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. An event is generated when the bullet hits a robot, wall, or another bullet. Example:// Fire a bullet with maximum power if the gun is ready if (getGunHeat() == 0) { setFire(Rules.MAX_BULLET_POWER); } ... execute();
- Parameters:
power
- the amount of energy given to the bullet, and subtracted from the robot's energy.
public Bullet setFireBullet(double power)
Sets the gun to fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing. This call returns immediately, and will not execute until you call execute() or take an action that executes. The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot. The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can 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:Bullet bullet = null; // Fire a bullet with maximum power if the gun is ready if (getGunHeat() == 0) { bullet = setFireBullet(Rules.MAX_BULLET_POWER); } ... execute(); ... // 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 void setMaxTurnRate(double newMaxTurnRate)
Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower thanRules.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
public void setMaxVelocity(double newMaxVelocity)
Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower thanRules.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
public void setResume()
Sets the robot to resume the movement stopped bystop()
orsetStop()
, if any. This call returns immediately, and will not execute until you callexecute()
or take an action that executes.
- See Also:
resume()
,stop()
,stop(boolean)
,setStop()
,setStop(boolean)
,execute()
public void setStop()
This call is identical tostop()
, but returns immediately, and will not execute until you callexecute()
or take an action that executes. If there is already movement saved from a previous stop, this will have no effect. This call is equivalent to callingsetStop(false)
;
- See Also:
stop()
,stop(boolean)
,resume()
,setResume()
,setStop(boolean)
,execute()
public void setStop(boolean overwrite)
This call is identical tostop(boolean)
, but returns immediately, and will not execute until you callexecute()
or take an action that executes. If there is already movement saved from a previous stop, you can overwrite it by callingsetStop(true)
.
- Parameters:
overwrite
-true
if the movement saved from a previous stop should be overwritten;false
otherwise.
- See Also:
stop()
,stop(boolean)
,resume()
,setResume()
,setStop()
,execute()
public void setTurnGunLeft(double degrees)
Sets the robot's gun to turn left by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn right instead of left. Example:// Set the gun to turn 180 degrees to the left setTurnGunLeft(180); // Set the gun to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnGunLeft(-90); ... // Executes the last setTurnGunLeft() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's gun to the left. Ifdegrees
> 0 the robot's gun is set to turn left. Ifdegrees
<320 the robot's gun is set to turn right. Ifdegrees
= 0 the robot's gun is set to stop turning.
public void setTurnGunLeftRadians(double radians)
Sets the robot's gun to turn 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 negative values means that the robot's gun is set to turn right instead of left. Example:// Set the gun to turn 180 degrees to the left setTurnGunLeftRadians(Math.PI); // Set the gun to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnGunLeftRadians(-Math.PI / 2); ... // Executes the last setTurnGunLeftRadians() execute();
- Overrides:
- setTurnGunLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the left. Ifradians
> 0 the robot's gun is set to turn left. Ifradians
<320 the robot's gun is set to turn right. Ifradians
= 0 the robot's gun is set to stop turning.
public void setTurnGunRight(double degrees)
Sets the robot's gun to turn right by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn left instead of right. Example:// Set the gun to turn 180 degrees to the right setTurnGunRight(180); // Set the gun to turn 90 degrees to the left instead of right // (overrides the previous order) setTurnGunRight(-90); ... // Executes the last setTurnGunRight() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's gun to the right. Ifdegrees
> 0 the robot's gun is set to turn right. Ifdegrees
<320 the robot's gun is set to turn left. Ifdegrees
= 0 the robot's gun is set to stop turning.
public void setTurnGunRightRadians(double radians)
Sets the robot's gun to turn right 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 negative values means that the robot's gun is set to turn left instead of right. Example:// Set the gun to turn 180 degrees to the right setTurnGunRightRadians(Math.PI); // Set the gun to turn 90 degrees to the left instead of right // (overrides the previous order) setTurnGunRightRadians(-Math.PI / 2); ... // Executes the last setTurnGunRightRadians() execute();
- Overrides:
- setTurnGunRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the right. Ifradians
> 0 the robot's gun is set to turn left. Ifradians
<320 the robot's gun is set to turn right. Ifradians
= 0 the robot's gun is set to stop turning.
public void setTurnLeft(double degrees)
Sets the robot's body to turn left by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn right instead of left. Example:// Set the robot to turn 180 degrees to the left setTurnLeft(180); // Set the robot to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnLeft(-90); ... // Executes the last setTurnLeft() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's body to the left. Ifdegrees
> 0 the robot is set to turn left. Ifdegrees
<320 the robot is set to turn right. Ifdegrees
= 0 the robot is set to stop turning.
public void setTurnLeftRadians(double radians)
Sets the robot's body to turn 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 negative values means that the robot's body is set to turn right instead of left. Example:// Set the robot to turn 180 degrees to the left setTurnLeftRadians(Math.PI); // Set the robot to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnLeftRadians(-Math.PI / 2); ... // Executes the last setTurnLeftRadians() execute();
- Overrides:
- setTurnLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the left. Ifradians
> 0 the robot is set to turn left. Ifradians
<320 the robot is set to turn right. Ifradians
= 0 the robot is set to stop turning.
public void setTurnRadarLeft(double degrees)
Sets the robot's radar to turn left by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn right instead of left. Example:// Set the radar to turn 180 degrees to the left setTurnRadarLeft(180); // Set the radar to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnRadarLeft(-90); ... // Executes the last setTurnRadarLeft() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's radar to the left. Ifdegrees
> 0 the robot's radar is set to turn left. Ifdegrees
<320 the robot's radar is set to turn right. Ifdegrees
= 0 the robot's radar is set to stop turning.
public void setTurnRadarLeftRadians(double radians)
Sets the robot's radar to turn 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 negative values means that the robot's radar is set to turn right instead of left. Example:// Set the radar to turn 180 degrees to the left setTurnRadarLeftRadians(Math.PI); // Set the radar to turn 90 degrees to the right instead of left // (overrides the previous order) setTurnRadarLeftRadians(-Math.PI / 2); ... // Executes the last setTurnRadarLeftRadians() execute();
- Overrides:
- setTurnRadarLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the left. Ifradians
> 0 the robot's radar is set to turn left. Ifradians
<320 the robot's radar is set to turn right. Ifradians
= 0 the robot's radar is set to stop turning.
public void setTurnRadarRight(double degrees)
Sets the robot's radar to turn right by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn left instead of right. Example:// Set the radar to turn 180 degrees to the right setTurnRadarRight(180); // Set the radar to turn 90 degrees to the right instead of right // (overrides the previous order) setTurnRadarRight(-90); ... // Executes the last setTurnRadarRight() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's radar to the right. Ifdegrees
> 0 the robot's radar is set to turn right. Ifdegrees
<320 the robot's radar is set to turn left. Ifdegrees
= 0 the robot's radar is set to stop turning.
public void setTurnRadarRightRadians(double radians)
Sets the robot's radar to turn right 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 negative values means that the robot's radar is set to turn left instead of right. Example:// Set the radar to turn 180 degrees to the right setTurnRadarRightRadians(Math.PI); // Set the radar to turn 90 degrees to the right instead of right // (overrides the previous order) setTurnRadarRightRadians(-Math.PI / 2); ... // Executes the last setTurnRadarRightRadians() execute();
- Overrides:
- setTurnRadarRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the right. Ifradians
> 0 the robot's radar is set to turn left. Ifradians
<320 the robot's radar is set to turn right. Ifradians
= 0 the robot's radar is set to stop turning.
public void setTurnRight(double degrees)
Sets the robot's body to turn right by degrees when the next execution takes place. This call returns immediately, and will not execute until you call execute() or take an action that executes. Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn left instead of right. Example:// Set the robot to turn 180 degrees to the right setTurnRight(180); // Set the robot to turn 90 degrees to the left instead of right // (overrides the previous order) setTurnRight(-90); ... // Executes the last setTurnRight() execute();
- Parameters:
degrees
- the amount of degrees to turn the robot's body to the right. Ifdegrees
> 0 the robot is set to turn right. Ifdegrees
<320 the robot is set to turn left. Ifdegrees
= 0 the robot is set to stop turning.
public void setTurnRightRadians(double radians)
Sets the robot's body to turn right 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 negative values means that the robot's body is set to turn left instead of right. Example:// Set the robot to turn 180 degrees to the right setTurnRightRadians(Math.PI); // Set the robot to turn 90 degrees to the left instead of right // (overrides the previous order) setTurnRightRadians(-Math.PI / 2); ... // Executes the last setTurnRightRadians() execute();
- Overrides:
- setTurnRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the right. Ifradians
> 0 the robot is set to turn right. Ifradians
<320 the robot is set to turn left. Ifradians
= 0 the robot is set to stop turning.
public void turnGunLeftRadians(double radians)
Immediately turns the robot's gun to the left by radians. 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 turnGunLeftRadians(Math.PI); // Afterwards, turn the robot's gun 90 degrees to the right turnGunLeftRadians(-Math.PI / 2);
- Overrides:
- turnGunLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the left. Ifradians
> 0 the robot's gun will turn left. Ifradians
<320 the robot's gun will turn right. Ifradians
= 0 the robot's gun will not turn, but execute.
- See Also:
turnGunLeft(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnRight(double)
,turnRightRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,setAdjustGunForRobotTurn(boolean)
public void turnGunRightRadians(double radians)
Immediately turns the robot's gun to the right by radians. 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 turnGunRightRadians(Math.PI); // Afterwards, turn the robot's gun 90 degrees to the left turnGunRightRadians(-Math.PI / 2);
- Overrides:
- turnGunRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the right. Ifradians
> 0 the robot's gun will turn right. Ifradians
<320 the robot's gun will turn left. Ifradians
= 0 the robot's gun will not turn, but execute.
- See Also:
turnGunRight(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnRight(double)
,turnRightRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,setAdjustGunForRobotTurn(boolean)
public void turnLeftRadians(double radians)
Immediately turns the robot's body to the left by radians. 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 turnLeftRadians(Math.PI); // Afterwards, turn the robot 90 degrees to the right turnLeftRadians(-Math.PI / 2);
- Overrides:
- turnLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the left. Ifradians
> 0 the robot will turn right. Ifradians
<320 the robot will turn left. Ifradians
= 0 the robot will not turn, but execute.
- See Also:
turnLeft(double)
,turnRight(double)
,turnRightRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,setAdjustGunForRobotTurn(boolean)
public void turnRadarLeftRadians(double radians)
Immediately turns the robot's radar to the left by radians. 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 turnRadarLeftRadians(Math.PI); // Afterwards, turn the robot's radar 90 degrees to the right turnRadarLeftRadians(-Math.PI / 2);
- Overrides:
- turnRadarLeftRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the left. Ifradians
> 0 the robot's radar will turn left. Ifradians
<320 the robot's radar will turn right. Ifradians
= 0 the robot's radar will not turn, but execute.
- See Also:
turnRadarLeft(double)
,turnRadarRight(double)
,turnGunRightRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnRight(double)
,turnRightRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,setAdjustRadarForRobotTurn(boolean)
,setAdjustRadarForGunTurn(boolean)
public void turnRadarRightRadians(double radians)
Immediately turns the robot's radar to the right by radians. 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 turnRadarRightRadians(Math.PI); // Afterwards, turn the robot's radar 90 degrees to the left turnRadarRightRadians(-Math.PI / 2);
- Overrides:
- turnRadarRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the right. Ifradians
> 0 the robot's radar will turn right. Ifradians
<320 the robot's radar will turn left. Ifradians
= 0 the robot's radar will not turn, but execute.
- See Also:
turnRadarRight(double)
,turnRadarLeft(double)
,turnGunLeftRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnRight(double)
,turnRightRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,setAdjustRadarForRobotTurn(boolean)
,setAdjustRadarForGunTurn(boolean)
public void turnRightRadians(double radians)
Immediately turns the robot's body to the right by radians. 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 turnRightRadians(Math.PI); // Afterwards, turn the robot 90 degrees to the left turnRightRadians(-Math.PI / 2);
- Overrides:
- turnRightRadians in interface robocode._AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the right. Ifradians
> 0 the robot will turn right. Ifradians
<320 the robot will turn left. Ifradians
= 0 the robot will not turn, but execute.
- See Also:
turnRight(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,setAdjustGunForRobotTurn(boolean)
public @Override 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.
- Parameters:
event
- the death event set by the game
- See Also:
DeathEvent
,Event
public @Override 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); ahead(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. out.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
public void waitFor(Condition condition)
Does not return until a condition is met, i.e. when aCondition.test()
returnstrue
. This call executes immediately. See thesample.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()