|
|||||||||
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
robocode.TeamRobot
robocode.RateControlRobot
public class RateControlRobot
This advanced robot type allows you to set a rate for each of the robot's movements.
You can set the rate for:setVelocityRate()
, setTurnRate()
, setGunRotationRate()
,
setRadarRotationRate()
and variants, Any previous calls to "movement" functions outside of
RateControlRobot
, such as setAhead()
, setTurnLeft()
,
setTurnRadarRightRadians()
and similar will be overridden when calling the
execute()
on this robot class.
Look into the source code for the sample.VelociRobot
in order to see how to use this
robot type.
Field Summary |
---|
Fields inherited from class robocode._RobotBase |
---|
out |
Constructor Summary | |
---|---|
RateControlRobot()
|
Method Summary | |
---|---|
void |
execute()
Executes any pending actions, or continues executing actions that are in process. |
double |
getGunRotationRate()
Gets the gun's clockwise rotation per turn, in degrees. |
double |
getGunRotationRateRadians()
Gets the gun's clockwise rotation per turn, in radians. |
double |
getRadarRotationRate()
Gets the radar's clockwise rotation per turn, in degrees. |
double |
getRadarRotationRateRadians()
Gets the radar's clockwise rotation per turn, in radians. |
double |
getTurnRate()
Gets the robot's clockwise rotation per turn, in degrees. |
double |
getTurnRateRadians()
Gets the robot's clockwise rotation per turn, in radians. |
double |
getVelocityRate()
Returns the speed the robot will move, in pixels per turn. |
void |
setGunRotationRate(double gunRotationRate)
Sets the gun's clockwise (right) rotation per turn, in degrees. |
void |
setGunRotationRateRadians(double gunRotationRate)
Sets the gun's clockwise (right) rotation per turn, in radians. |
void |
setRadarRotationRate(double radarRotationRate)
Sets the radar's clockwise (right) rotation per turn, in degrees. |
void |
setRadarRotationRateRadians(double radarRotationRate)
Sets the radar's clockwise (right) rotation per turn, in radians. |
void |
setTurnRate(double turnRate)
Sets the robot's clockwise (right) rotation per turn, in degrees. |
void |
setTurnRateRadians(double turnRate)
Sets the robot's clockwise (right) rotation per turn, in radians. |
void |
setVelocityRate(double velocityRate)
Sets the speed the robot will move (forward), in pixels per turn. |
Methods inherited from class robocode.TeamRobot |
---|
broadcastMessage, getMessageEvents, getTeamEventListener, getTeammates, isTeammate, onMessageReceived, sendMessage |
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.IAdvancedRobot |
---|
getAdvancedEventListener |
Methods inherited from interface robocode.robotinterfaces.IBasicRobot |
---|
getBasicEventListener, getRobotRunnable, setOut, setPeer |
Constructor Detail |
---|
public RateControlRobot()
Method Detail |
---|
public void setVelocityRate(double velocityRate)
// Set the robot to move forward 2 pixels per turn setVelocityRate(2); // Set the robot to move backwards 8 pixels per turn // (overrides the previous order) setVelocityRate(-8); ... // Executes the last setVelocityRate() execute();Note: This method overrules
AdvancedRobot.setAhead(double)
and
AdvancedRobot.setBack(double)
.
velocityRate
- pixels per turn the robot will move.getVelocityRate()
,
setTurnRate(double)
,
setGunRotationRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setAhead(double)
,
AdvancedRobot.setBack(double)
public double getVelocityRate()
setVelocityRate(double)
public void setTurnRate(double turnRate)
// Set the robot to turn right 10 degrees per turn setTurnRate(10); // Set the robot to turn left 4 degrees per turn // (overrides the previous order) setTurnRate(-5); ... // Executes the last setTurnRate() execute();
turnRate
- angle of the clockwise rotation, in degrees.getTurnRate()
,
setVelocityRate(double)
,
setGunRotationRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setTurnRight(double)
,
AdvancedRobot.setTurnLeft(double)
public double getTurnRate()
setTurnRate(double)
public void setTurnRateRadians(double turnRate)
// Set the robot to turn right pi / 32 radians per turn setTurnRateRadians(Math.PI / 32); // Set the robot to turn left pi / 20 radians per turn // (overrides the previous order) setTurnRateRadians(-Math.PI / 20); ... // Executes the last setTurnRateRadians() execute();
turnRate
- angle of the clockwise rotation, in radians.getTurnRateRadians()()
,
setVelocityRate(double)
,
setGunRotationRateRadians(double)
,
setRadarRotationRateRadians(double)
,
AdvancedRobot.setTurnRightRadians(double)
,
AdvancedRobot.setTurnLeftRadians(double)
public double getTurnRateRadians()
getTurnRateRadians()
public void setGunRotationRate(double gunRotationRate)
// Set the gun to turn right 15 degrees per turn setGunRotationRate(15); // Set the gun to turn left 9 degrees per turn // (overrides the previous order) setGunRotationRate(-9); ... // Executes the last setGunRotationRate() execute();
gunRotationRate
- angle of the clockwise rotation, in degrees.getGunRotationRate()
,
setVelocityRate(double)
,
setTurnRate(double)
,
setRadarRotationRate(double)
,
AdvancedRobot.setTurnGunRight(double)
,
AdvancedRobot.setTurnGunLeft(double)
public double getGunRotationRate()
setGunRotationRate(double)
public void setGunRotationRateRadians(double gunRotationRate)
// Set the gun to turn right pi / 16 radians per turn setGunRotationRateRadians(Math.PI / 16); // Set the gun to turn left pi / 12 radians per turn // (overrides the previous order) setGunRotationRateRadians(-Math.PI / 12); ... // Executes the last setGunRotationRateRadians() execute();
gunRotationRate
- angle of the clockwise rotation, in radians.getGunRotationRateRadians()
,
setVelocityRate(double)
,
setTurnRateRadians(double)
,
setRadarRotationRateRadians(double)
,
AdvancedRobot.setTurnGunRightRadians(double)
,
AdvancedRobot.setTurnGunLeftRadians(double)
public double getGunRotationRateRadians()
setGunRotationRateRadians(double)
public void setRadarRotationRate(double radarRotationRate)
// Set the radar to turn right 45 degrees per turn setRadarRotationRate(45); // Set the radar to turn left 15 degrees per turn // (overrides the previous order) setRadarRotationRate(-15); ... // Executes the last setRadarRotationRate() execute();
radarRotationRate
- angle of the clockwise rotation, in degrees.getRadarRotationRate()
,
setVelocityRate(double)
,
setTurnRate(double)
,
setGunRotationRate(double)
,
AdvancedRobot.setTurnRadarRight(double)
,
AdvancedRobot.setTurnRadarLeft(double)
public double getRadarRotationRate()
setRadarRotationRate(double)
public void setRadarRotationRateRadians(double radarRotationRate)
// Set the radar to turn right pi / 4 radians per turn setRadarRotationRateRadians(Math.PI / 4); // Set the radar to turn left pi / 8 radians per turn // (overrides the previous order) setRadarRotationRateRadians(-Math.PI / 8); ... // Executes the last setRadarRotationRateRadians() execute();
radarRotationRate
- angle of the clockwise rotation, in radians.getRadarRotationRateRadians()
,
setVelocityRate(double)
,
setTurnRateRadians(double)
,
setGunRotationRateRadians(double)
,
AdvancedRobot.setTurnRadarRightRadians(double)
,
AdvancedRobot.setTurnRadarLeftRadians(double)
public double getRadarRotationRateRadians()
setRadarRotationRateRadians(double)
public void execute()
setVelocityRate()
, setFire()
,
setTurnRate()
etc. Otherwise, these calls will never get executed.
Any previous calls to "movement" functions outside of RateControlRobot
,
such as setAhead()
, setTurnLeft()
, setTurnRadarLeftRadians()
etc. will be overridden when this method is called on this robot class.
In this example the robot will move while turning:
setVelocityRate(6); setTurnRate(7); while (true) { execute(); }
execute
in class AdvancedRobot
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |