|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrobocode._RobotBase
robocode._Robot
robocode.Robot
robocode._AdvancedRobot
robocode._AdvancedRadiansRobot
robocode.AdvancedRobot
public class AdvancedRobot
A more advanced type of robot than Robot that allows non-blocking calls, custom events, and writes to the filesystem.
If you have not already, you should create aRobot
first.
JuniorRobot
,
Robot
,
TeamRobot
,
Droid
Field Summary |
---|
Fields inherited from class robocode._RobotBase |
---|
out |
Constructor Summary | |
---|---|
AdvancedRobot()
|
Method Summary | |
---|---|
void |
addCustomEvent(Condition condition)
Registers a custom event to be called when a condition is met. |
void |
clearAllEvents()
Clears out any pending events in the robot's event queue immediately. |
void |
execute()
Executes any pending actions, or continues executing actions that are in process. |
IAdvancedEvents |
getAdvancedEventListener()
Do not call this method! |
Vector<Event> |
getAllEvents()
Returns a vector containing all events currently in the robot's queue. |
Vector<BulletHitBulletEvent> |
getBulletHitBulletEvents()
Returns a vector containing all BulletHitBulletEvents currently in the robot's queue. |
Vector<BulletHitEvent> |
getBulletHitEvents()
Returns a vector containing all BulletHitEvents currently in the robot's queue. |
Vector<BulletMissedEvent> |
getBulletMissedEvents()
Returns a vector containing all BulletMissedEvents currently in the robot's queue. |
File |
getDataDirectory()
Returns a file representing a data directory for the robot, which can be written to using RobocodeFileOutputStream or
RobocodeFileWriter . |
File |
getDataFile(String filename)
Returns a file in your data directory that you can write to using RobocodeFileOutputStream or RobocodeFileWriter . |
long |
getDataQuotaAvailable()
Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot. |
double |
getDistanceRemaining()
Returns the distance remaining in the robot's current move measured in pixels. |
int |
getEventPriority(String eventClass)
Returns the current priority of a class of events. |
double |
getGunHeadingRadians()
Returns the direction that the robot's gun is facing, in radians. |
double |
getGunTurnRemaining()
Returns the angle remaining in the gun's turn, in degrees. |
double |
getGunTurnRemainingRadians()
Returns the angle remaining in the gun's turn, in radians. |
double |
getHeadingRadians()
Returns the direction that the robot's body is facing, in radians. |
Vector<HitByBulletEvent> |
getHitByBulletEvents()
Returns a vector containing all HitByBulletEvents currently in the robot's queue. |
Vector<HitRobotEvent> |
getHitRobotEvents()
Returns a vector containing all HitRobotEvents currently in the robot's queue. |
Vector<HitWallEvent> |
getHitWallEvents()
Returns a vector containing all HitWallEvents currently in the robot's queue. |
double |
getRadarHeadingRadians()
Returns the direction that the robot's radar is facing, in radians. |
double |
getRadarTurnRemaining()
Returns the angle remaining in the radar's turn, in degrees. |
double |
getRadarTurnRemainingRadians()
Returns the angle remaining in the radar's turn, in radians. |
Vector<RobotDeathEvent> |
getRobotDeathEvents()
Returns a vector containing all RobotDeathEvents currently in the robot's queue. |
Vector<ScannedRobotEvent> |
getScannedRobotEvents()
Returns a vector containing all ScannedRobotEvents currently in the robot's queue. |
Vector<StatusEvent> |
getStatusEvents()
Returns a vector containing all StatusEvents currently in the robot's queue. |
double |
getTurnRemaining()
Returns the angle remaining in the robots's turn, in degrees. |
double |
getTurnRemainingRadians()
Returns the angle remaining in the robot's turn, in radians. |
boolean |
isAdjustGunForRobotTurn()
Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. |
boolean |
isAdjustRadarForGunTurn()
Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn. |
boolean |
isAdjustRadarForRobotTurn()
Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. |
void |
onCustomEvent(CustomEvent event)
This method is called when a custom condition is met. |
void |
onDeath(DeathEvent event)
This method is called if your robot dies. |
void |
onSkippedTurn(SkippedTurnEvent event)
This method is called if the robot is using too much time between actions. |
void |
removeCustomEvent(Condition condition)
Removes a custom event that was previously added by calling addCustomEvent(Condition) . |
void |
setAhead(double distance)
Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place. |
void |
setBack(double distance)
Sets the robot to move back by distance measured in pixels when the next execution takes place. |
void |
setEventPriority(String eventClass,
int priority)
Sets the priority of a class of events. |
void |
setFire(double power)
Sets the gun to fire a bullet when the next execution takes place. |
Bullet |
setFireBullet(double power)
Sets the gun to fire a bullet when the next execution takes place. |
void |
setInterruptible(boolean interruptible)
Call this during an event handler to allow new events of the same priority to restart the event handler. |
void |
setMaxTurnRate(double newMaxTurnRate)
Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than Rules.MAX_TURN_RATE (10 degress/turn). |
void |
setMaxVelocity(double newMaxVelocity)
Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than Rules.MAX_VELOCITY (8 pixels/turn). |
void |
setResume()
Sets the robot to resume the movement stopped by stop()
or setStop() , if any. |
void |
setStop()
This call is identical to stop() , but returns immediately, and
will not execute until you call execute() or take an action that
executes. |
void |
setStop(boolean overwrite)
This call is identical to stop(boolean) , but
returns immediately, and will not execute until you call
execute() or take an action that executes. |
void |
setTurnGunLeft(double degrees)
Sets the robot's gun to turn left by degrees when the next execution takes place. |
void |
setTurnGunLeftRadians(double radians)
Sets the robot's gun to turn left by radians when the next execution takes place. |
void |
setTurnGunRight(double degrees)
Sets the robot's gun to turn right by degrees when the next execution takes place. |
void |
setTurnGunRightRadians(double radians)
Sets the robot's gun to turn right by radians when the next execution takes place. |
void |
setTurnLeft(double degrees)
Sets the robot's body to turn left by degrees when the next execution takes place. |
void |
setTurnLeftRadians(double radians)
Sets the robot's body to turn left by radians when the next execution takes place. |
void |
setTurnRadarLeft(double degrees)
Sets the robot's radar to turn left by degrees when the next execution takes place. |
void |
setTurnRadarLeftRadians(double radians)
Sets the robot's radar to turn left by radians when the next execution takes place. |
void |
setTurnRadarRight(double degrees)
Sets the robot's radar to turn right by degrees when the next execution takes place. |
void |
setTurnRadarRightRadians(double radians)
Sets the robot's radar to turn right by radians when the next execution takes place. |
void |
setTurnRight(double degrees)
Sets the robot's body to turn right by degrees when the next execution takes place. |
void |
setTurnRightRadians(double radians)
Sets the robot's body to turn right by radians when the next execution takes place. |
void |
turnGunLeftRadians(double radians)
Immediately turns the robot's gun to the left by radians. |
void |
turnGunRightRadians(double radians)
Immediately turns the robot's gun to the right by radians. |
void |
turnLeftRadians(double radians)
Immediately turns the robot's body to the left by radians. |
void |
turnRadarLeftRadians(double radians)
Immediately turns the robot's radar to the left by radians. |
void |
turnRadarRightRadians(double radians)
Immediately turns the robot's radar to the right by radians. |
void |
turnRightRadians(double radians)
Immediately turns the robot's body to the right by radians. |
void |
waitFor(Condition condition)
Does not return until a condition is met, i.e. when a Condition.test() returns true . |
Methods inherited from class robocode._Robot |
---|
getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setRadarImageName, setRobotImageName |
Methods inherited from class robocode._RobotBase |
---|
finalize, setOut, setPeer |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface robocode.robotinterfaces.IBasicRobot |
---|
getBasicEventListener, getRobotRunnable, setOut, setPeer |
Constructor Detail |
---|
public AdvancedRobot()
Method Detail |
---|
public double getDistanceRemaining()
getTurnRemaining()
,
getTurnRemainingRadians()
,
getGunTurnRemaining()
,
getGunTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public double getTurnRemaining()
getTurnRemainingRadians()
,
getDistanceRemaining()
,
getGunTurnRemaining()
,
getGunTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public double getGunTurnRemaining()
getGunTurnRemainingRadians()
,
getDistanceRemaining()
,
getTurnRemaining()
,
getTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public double getRadarTurnRemaining()
getRadarTurnRemainingRadians()
,
getDistanceRemaining()
,
getGunTurnRemaining()
,
getGunTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public void setAhead(double distance)
execute()
or take an action that executes.
Note that both positive and negative values can be given as input, where
positive values means that the robot is set to move 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();
distance
- the distance to move measured in pixels.
If distance
> 0 the robot is set to move ahead.
If distance
< 0 the robot is set to move back.
If distance
= 0 the robot is set to stop its movement.ahead(double)
,
back(double)
,
setBack(double)
public void setBack(double distance)
execute()
or take an action that executes.
Note that both positive and negative values can be given as input, where
positive values means that the robot is set to move 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();
distance
- the distance to move measured in pixels.
If distance
> 0 the robot is set to move back.
If distance
< 0 the robot is set to move ahead.
If distance
= 0 the robot is set to stop its movement.back(double)
,
ahead(double)
,
setAhead(double)
public void setTurnLeft(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's body to the left.
If degrees
> 0 the robot is set to turn left.
If degrees
< 0 the robot is set to turn right.
If degrees
= 0 the robot is set to stop turning.setTurnLeftRadians(double)
,
turnLeft(double)
,
turnLeftRadians(double)
,
turnRight(double)
,
turnRightRadians(double)
,
setTurnRight(double)
,
setTurnRightRadians(double)
public void setTurnRight(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's body to the right.
If degrees
> 0 the robot is set to turn right.
If degrees
< 0 the robot is set to turn left.
If degrees
= 0 the robot is set to stop turning.setTurnRightRadians(double)
,
turnRight(double)
,
turnRightRadians(double)
,
turnLeft(double)
,
turnLeftRadians(double)
,
setTurnLeft(double)
,
setTurnLeftRadians(double)
public void setFire(double power)
Rules.MIN_BULLET_POWER
and Rules.MAX_BULLET_POWER
.
Note that the gun cannot fire if the gun is overheated, meaning that
Robot.getGunHeat()
returns a value > 0.
An event is generated when the bullet hits a robot, wall, or another
bullet.
Example:
// Fire a bullet with maximum power if the gun is ready if (getGunHeat() == 0) { setFire(Rules.MAX_BULLET_POWER); } ... execute();
power
- the amount of energy given to the bullet, and subtracted
from the robot's energy.setFireBullet(double)
,
fire(double)
,
fireBullet(double)
,
getGunHeat()
,
getGunCoolingRate()
,
onBulletHit(BulletHitEvent)
,
onBulletHitBullet(BulletHitBulletEvent)
,
onBulletMissed(BulletMissedEvent)
public Bullet setFireBullet(double power)
Rules.getBulletDamage(double)
for getting the damage that a
bullet with a specific bullet power will do.
The specified bullet power should be between
Rules.MIN_BULLET_POWER
and Rules.MAX_BULLET_POWER
.
Note that the gun cannot fire if the gun is overheated, meaning that
Robot.getGunHeat()
returns a value > 0.
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(); }
power
- the amount of energy given to the bullet, and subtracted
from the robot's energy.
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.setFire(double)
,
Bullet
,
fire(double)
,
fireBullet(double)
,
getGunHeat()
,
getGunCoolingRate()
,
onBulletHit(BulletHitEvent)
,
onBulletHitBullet(BulletHitBulletEvent)
,
onBulletMissed(BulletMissedEvent)
public void addCustomEvent(Condition condition)
removeCustomEvent(Condition)
.
Example:
// Create the condition for our custom event Condition triggerHitCondition = new Condition("triggerhit") { public boolean test() { return (getEnergy() <= trigger); } } // Add our custom event based on our condition addCustomEvent(triggerHitCondition);
condition
- the condition that must be met.
NullPointerException
- if the condition parameter has been set to
null
.Condition
,
removeCustomEvent(Condition)
public void removeCustomEvent(Condition condition)
addCustomEvent(Condition)
.
Example:
// Create the condition for our custom event Condition triggerHitCondition = new Condition("triggerhit") { public boolean test() { return (getEnergy() <= trigger); } } // Add our custom event based on our condition addCustomEvent(triggerHitCondition); ... do something with your robot ... // Remove the custom event based on our condition removeCustomEvent(triggerHitCondition);
condition
- the condition that was previous added and that must be
removed now.
NullPointerException
- if the condition parameter has been set to
null
.Condition
,
addCustomEvent(Condition)
public void clearAllEvents()
getAllEvents()
public void execute()
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 Vector<Event> getAllEvents()
for (Event event : getAllEvents()) { if (event instanceof HitRobotEvent) { // do something with the event } else if (event instanceof HitByBulletEvent) { // do something with the event } }
Event
,
clearAllEvents()
,
getStatusEvents()
,
getScannedRobotEvents()
,
getBulletHitEvents()
,
getBulletMissedEvents()
,
getBulletHitBulletEvents()
,
getRobotDeathEvents()
public Vector<BulletHitBulletEvent> getBulletHitBulletEvents()
for (BulletHitBulletEvent event : getBulletHitBulletEvents()) { // do something with the event }
onBulletHitBullet(BulletHitBulletEvent)
,
BulletHitBulletEvent
,
getAllEvents()
public Vector<BulletHitEvent> getBulletHitEvents()
for (BulletHitEvent event: getBulletHitEvents()) { // do something with the event }
onBulletHit(BulletHitEvent)
,
BulletHitEvent
,
getAllEvents()
public Vector<BulletMissedEvent> getBulletMissedEvents()
for (BulletMissedEvent event : getBulletMissedEvents()) { // do something with the event }
onBulletMissed(BulletMissedEvent)
,
BulletMissedEvent
,
getAllEvents()
public File getDataDirectory()
RobocodeFileOutputStream
or
RobocodeFileWriter
.
The system will automatically create the directory for you, so you do not
need to create it by yourself.
getDataFile(String)
,
RobocodeFileOutputStream
,
RobocodeFileWriter
public File getDataFile(String filename)
RobocodeFileOutputStream
or RobocodeFileWriter
.
The system will automatically create the directory for you, so you do not
need to create it by yourself.
Please notice that the max. size of your data file is set to 200000
(~195 KB).
See the sample.SittingDuck
to see an example of how to use this
method.
filename
- the file name of the data file for your robot
getDataDirectory()
,
RobocodeFileOutputStream
,
RobocodeFileWriter
public long getDataQuotaAvailable()
getDataDirectory()
,
getDataFile(String)
public int getEventPriority(String eventClass)
int myHitRobotPriority = getEventPriority("HitRobotEvent");The default priorities are, from highest to lowest:
RoundEndedEvent
: 100 (reserved)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)
eventClass
- the name of the event class (string)
setEventPriority(String, int)
public Vector<HitByBulletEvent> getHitByBulletEvents()
for (HitByBulletEvent event : getHitByBulletEvents()) { // do something with the event }
onHitByBullet(HitByBulletEvent)
,
HitByBulletEvent
,
getAllEvents()
public Vector<HitRobotEvent> getHitRobotEvents()
for (HitRobotEvent event : getHitRobotEvents()) { // do something with the event }
onHitRobot(HitRobotEvent)
,
HitRobotEvent
,
getAllEvents()
public Vector<HitWallEvent> getHitWallEvents()
for (HitWallEvent event : getHitWallEvents()) { // do something with the event }
onHitWall(HitWallEvent)
,
HitWallEvent
,
getAllEvents()
public Vector<RobotDeathEvent> getRobotDeathEvents()
for (RobotDeathEvent event : getRobotDeathEvents()) { // do something with the event }
onRobotDeath(RobotDeathEvent)
,
RobotDeathEvent
,
getAllEvents()
public Vector<ScannedRobotEvent> getScannedRobotEvents()
for (ScannedRobotEvent event : getScannedRobotEvents()) { // do something with the event }
onScannedRobot(ScannedRobotEvent)
,
ScannedRobotEvent
,
getAllEvents()
public Vector<StatusEvent> getStatusEvents()
for (StatusEvent event : getStatusEvents()) { // do something with the event }
onStatus(StatusEvent)
,
StatusEvent
,
getAllEvents()
public boolean isAdjustGunForRobotTurn()
true
if the gun is set to turn independent of
the turn of the robot's body. Otherwise, false
is returned,
meaning that the gun is set to turn with the robot's body turn.
true
if the gun is set to turn independent of the robot
turning; false
if the gun is set to turn with the robot
turningsetAdjustGunForRobotTurn(boolean)
,
isAdjustRadarForRobotTurn()
,
isAdjustRadarForGunTurn()
public boolean isAdjustRadarForRobotTurn()
true
if the radar is set to turn independent of
the turn of the robot. Otherwise, false
is returned, meaning that
the radar is set to turn with the robot's turn.
true
if the radar is set to turn independent of the robot
turning; false
if the radar is set to turn with the robot
turningsetAdjustRadarForRobotTurn(boolean)
,
isAdjustGunForRobotTurn()
,
isAdjustRadarForGunTurn()
public boolean isAdjustRadarForGunTurn()
true
if the radar is set to turn independent of
the turn of the gun. Otherwise, false
is returned, meaning that
the radar is set to turn with the gun's turn.
true
if the radar is set to turn independent of the gun
turning; false
if the radar is set to turn with the gun
turningsetAdjustRadarForGunTurn(boolean)
,
isAdjustGunForRobotTurn()
,
isAdjustRadarForRobotTurn()
public void onCustomEvent(CustomEvent event)
sample.Target
robot.
onCustomEvent
in interface IAdvancedEvents
event
- the custom event that occurredaddCustomEvent(robocode.Condition)
,
CustomEvent
,
Event
public void setEventPriority(String eventClass, int priority)
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)
eventClass
- the name of the event class (string) to set the
priority forpriority
- the new priority for that event classgetEventPriority(String)
,
setInterruptible(boolean)
public void setInterruptible(boolean interruptible)
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"); }
setInterruptible
in class _Robot
interruptible
- true
if the event handler should be
interrupted if new events of the same priority occurs; false
otherwisesetEventPriority(String, int)
,
onScannedRobot(ScannedRobotEvent)
public void setMaxTurnRate(double newMaxTurnRate)
Rules.MAX_TURN_RATE
(10 degress/turn).
newMaxTurnRate
- the new maximum turn rate of the robot measured in
degrees. Valid values are 0 - Rules.MAX_TURN_RATE
turnRight(double)
,
turnLeft(double)
,
setTurnRight(double)
,
setTurnLeft(double)
,
setMaxVelocity(double)
public void setMaxVelocity(double newMaxVelocity)
Rules.MAX_VELOCITY
(8 pixels/turn).
newMaxVelocity
- the new maximum turn rate of the robot measured in
pixels/turn. Valid values are 0 - Rules.MAX_VELOCITY
Robot.ahead(double)
,
setAhead(double)
,
Robot.back(double)
,
setBack(double)
,
setMaxTurnRate(double)
public void setResume()
stop()
or setStop()
, if any.
This call returns immediately, and will not execute until you call
execute()
or take an action that executes.
resume()
,
stop()
,
stop(boolean)
,
setStop()
,
setStop(boolean)
,
execute()
public void setStop()
stop()
, but returns immediately, and
will not execute until you call execute()
or take an action that
executes.
If there is already movement saved from a previous stop, this will have
no effect.
This call is equivalent to calling setStop(false)
;
stop()
,
stop(boolean)
,
resume()
,
setResume()
,
setStop(boolean)
,
execute()
public void setStop(boolean overwrite)
stop(boolean)
, but
returns immediately, and will not execute until you call
execute()
or take an action that executes.
If there is already movement saved from a previous stop, you can
overwrite it by calling setStop(true)
.
overwrite
- true
if the movement saved from a previous stop
should be overwritten; false
otherwise.stop()
,
stop(boolean)
,
resume()
,
setResume()
,
setStop()
,
execute()
public void setTurnGunLeft(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's gun to the left.
If degrees
> 0 the robot's gun is set to turn left.
If degrees
< 0 the robot's gun is set to turn right.
If degrees
= 0 the robot's gun is set to stop turning.setTurnGunLeftRadians(double)
,
turnGunLeft(double)
,
turnGunLeftRadians(double)
,
turnGunRight(double)
,
turnGunRightRadians(double)
,
setTurnGunRight(double)
,
setTurnGunRightRadians(double)
,
setAdjustGunForRobotTurn(boolean)
public void setTurnGunRight(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's gun to the right.
If degrees
> 0 the robot's gun is set to turn right.
If degrees
< 0 the robot's gun is set to turn left.
If degrees
= 0 the robot's gun is set to stop turning.setTurnGunRightRadians(double)
,
turnGunRight(double)
,
turnGunRightRadians(double)
,
turnGunLeft(double)
,
turnGunLeftRadians(double)
,
setTurnGunLeft(double)
,
setTurnGunLeftRadians(double)
,
setAdjustGunForRobotTurn(boolean)
public void setTurnRadarLeft(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's radar to the left.
If degrees
> 0 the robot's radar is set to turn left.
If degrees
< 0 the robot's radar is set to turn right.
If degrees
= 0 the robot's radar is set to stop turning.setTurnRadarLeftRadians(double)
,
turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
turnRadarRight(double)
,
turnRadarRightRadians(double)
,
setTurnRadarRight(double)
,
setTurnRadarRightRadians(double)
,
setAdjustRadarForRobotTurn(boolean)
,
setAdjustRadarForGunTurn(boolean)
public void setTurnRadarRight(double degrees)
// 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();
degrees
- the amount of degrees to turn the robot's radar to the right.
If degrees
> 0 the robot's radar is set to turn right.
If degrees
< 0 the robot's radar is set to turn left.
If degrees
= 0 the robot's radar is set to stop turning.setTurnRadarRightRadians(double)
,
turnRadarRight(double)
,
turnRadarRightRadians(double)
,
turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
setTurnRadarLeft(double)
,
setTurnRadarLeftRadians(double)
,
setAdjustRadarForRobotTurn(boolean)
,
setAdjustRadarForGunTurn(boolean)
public void waitFor(Condition condition)
Condition.test()
returns true
.
This call executes immediately.
See the sample.Crazy
robot for how this method can be used.
condition
- the condition that must be met before this call returnsCondition
,
Condition.test()
public void onDeath(DeathEvent event)
onDeath
in interface IBasicEvents
onDeath
in class Robot
event
- the death event set by the gameDeathEvent
,
Event
public void onSkippedTurn(SkippedTurnEvent event)
onSkippedTurn
in interface IAdvancedEvents
event
- the skipped turn event set by the gameSkippedTurnEvent
,
Event
public double getHeadingRadians()
getHeadingRadians
in class _AdvancedRadiansRobot
_AdvancedRobot.getHeadingDegrees()
,
getGunHeadingRadians()
,
getRadarHeadingRadians()
public void setTurnLeftRadians(double radians)
// 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();
setTurnLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's body to the left.
If radians
> 0 the robot is set to turn left.
If radians
< 0 the robot is set to turn right.
If radians
= 0 the robot is set to stop turning.setTurnLeft(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
setTurnRight(double)
,
setTurnRightRadians(double)
public void setTurnRightRadians(double radians)
// 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();
setTurnRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's body to the right.
If radians
> 0 the robot is set to turn right.
If radians
< 0 the robot is set to turn left.
If radians
= 0 the robot is set to stop turning.setTurnRight(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
setTurnLeft(double)
,
setTurnLeftRadians(double)
public void turnLeftRadians(double radians)
// Turn the robot 180 degrees to the left turnLeftRadians(Math.PI); // Afterwards, turn the robot 90 degrees to the right turnLeftRadians(-Math.PI / 2);
turnLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's body to the left.
If radians
> 0 the robot will turn right.
If radians
< 0 the robot will turn left.
If radians
= 0 the robot will not turn, but execute.Robot.turnLeft(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public void turnRightRadians(double radians)
// Turn the robot 180 degrees to the right turnRightRadians(Math.PI); // Afterwards, turn the robot 90 degrees to the left turnRightRadians(-Math.PI / 2);
turnRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's body to the right.
If radians
> 0 the robot will turn right.
If radians
< 0 the robot will turn left.
If radians
= 0 the robot will not turn, but execute.Robot.turnRight(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public double getGunHeadingRadians()
getGunHeadingRadians
in class _AdvancedRadiansRobot
_AdvancedRobot.getGunHeadingDegrees()
,
getHeadingRadians()
,
getRadarHeadingRadians()
public double getRadarHeadingRadians()
getRadarHeadingRadians
in class _AdvancedRadiansRobot
_AdvancedRobot.getRadarHeadingDegrees()
,
getHeadingRadians()
,
getGunHeadingRadians()
public void setTurnGunLeftRadians(double radians)
// 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();
setTurnGunLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's gun to the left.
If radians
> 0 the robot's gun is set to turn left.
If radians
< 0 the robot's gun is set to turn right.
If radians
= 0 the robot's gun is set to stop turning.setTurnGunLeft(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
setTurnGunRight(double)
,
setTurnGunRightRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public void setTurnGunRightRadians(double radians)
// 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();
setTurnGunRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's gun to the right.
If radians
> 0 the robot's gun is set to turn left.
If radians
< 0 the robot's gun is set to turn right.
If radians
= 0 the robot's gun is set to stop turning.setTurnGunRight(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
setTurnGunLeft(double)
,
setTurnGunLeftRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public void setTurnRadarLeftRadians(double radians)
// 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();
setTurnRadarLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's radar to the left.
If radians
> 0 the robot's radar is set to turn left.
If radians
< 0 the robot's radar is set to turn right.
If radians
= 0 the robot's radar is set to stop turning.setTurnRadarLeft(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
setTurnRadarRight(double)
,
setTurnRadarRightRadians(double)
,
Robot.setAdjustRadarForRobotTurn(boolean)
,
Robot.setAdjustRadarForGunTurn(boolean)
public void setTurnRadarRightRadians(double radians)
// 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();
setTurnRadarRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's radar to the right.
If radians
> 0 the robot's radar is set to turn left.
If radians
< 0 the robot's radar is set to turn right.
If radians
= 0 the robot's radar is set to stop turning.setTurnRadarRight(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
setTurnRadarLeft(double)
,
setTurnRadarLeftRadians(double)
,
Robot.setAdjustRadarForRobotTurn(boolean)
,
Robot.setAdjustRadarForGunTurn(boolean)
public void turnGunLeftRadians(double radians)
// 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);
turnGunLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's gun to the left.
If radians
> 0 the robot's gun will turn left.
If radians
< 0 the robot's gun will turn right.
If radians
= 0 the robot's gun will not turn, but execute.Robot.turnGunLeft(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public void turnGunRightRadians(double radians)
// 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);
turnGunRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's gun to the right.
If radians
> 0 the robot's gun will turn right.
If radians
< 0 the robot's gun will turn left.
If radians
= 0 the robot's gun will not turn, but execute.Robot.turnGunRight(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnRadarLeft(double)
,
turnRadarLeftRadians(double)
,
Robot.turnRadarRight(double)
,
turnRadarRightRadians(double)
,
Robot.setAdjustGunForRobotTurn(boolean)
public void turnRadarLeftRadians(double radians)
// 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);
turnRadarLeftRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's radar to the left.
If radians
> 0 the robot's radar will turn left.
If radians
< 0 the robot's radar will turn right.
If radians
= 0 the robot's radar will not turn, but execute.Robot.turnRadarLeft(double)
,
Robot.turnRadarRight(double)
,
turnGunRightRadians(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.setAdjustRadarForRobotTurn(boolean)
,
Robot.setAdjustRadarForGunTurn(boolean)
public void turnRadarRightRadians(double radians)
// 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);
turnRadarRightRadians
in class _AdvancedRadiansRobot
radians
- the amount of radians to turn the robot's radar to the right.
If radians
> 0 the robot's radar will turn right.
If radians
< 0 the robot's radar will turn left.
If radians
= 0 the robot's radar will not turn, but execute.Robot.turnRadarRight(double)
,
Robot.turnRadarLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnLeft(double)
,
turnLeftRadians(double)
,
Robot.turnRight(double)
,
turnRightRadians(double)
,
Robot.turnGunLeft(double)
,
turnGunLeftRadians(double)
,
Robot.turnGunRight(double)
,
turnGunRightRadians(double)
,
Robot.setAdjustRadarForRobotTurn(boolean)
,
Robot.setAdjustRadarForGunTurn(boolean)
public double getGunTurnRemainingRadians()
getGunTurnRemainingRadians
in class _AdvancedRadiansRobot
getGunTurnRemaining()
,
getTurnRemaining()
,
getTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public double getRadarTurnRemainingRadians()
getRadarTurnRemainingRadians
in class _AdvancedRadiansRobot
getRadarTurnRemaining()
,
getTurnRemaining()
,
getTurnRemainingRadians()
,
getGunTurnRemaining()
,
getGunTurnRemainingRadians()
public double getTurnRemainingRadians()
getTurnRemainingRadians
in class _AdvancedRadiansRobot
getTurnRemaining()
,
getGunTurnRemaining()
,
getGunTurnRemainingRadians()
,
getRadarTurnRemaining()
,
getRadarTurnRemainingRadians()
public final IAdvancedEvents getAdvancedEventListener()
IAdvancedEvents
listener.
getAdvancedEventListener
in interface IAdvancedRobot
null
if this robot should
not receive the notifications.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |