Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
robocode._RobotBase
robocode.JuniorRobot
Robot
and
AdvancedRobot
classes. The JuniorRobot has a simplified model, in
purpose of teaching programming skills to inexperienced in programming
students. The simplified robot model will keep player from overwhelming of
Robocode's rules, programming syntax and programming concept.
Instead of using getters and setters, public fields are provided for
receiving information like the last scanned robot, the coordinate of the
robot etc.
All methods on this class are blocking calls, i.e. they do not return before
their action has been completed and will at least take one turn to execute.
However, setting colors is executed immediately and does not cost a turn to
perform.
Robot
, AdvancedRobot
, TeamRobot
, Droid
Field Summary | |
static int |
|
static int |
|
static int |
|
int |
|
int |
|
int |
|
static int |
|
static int |
|
int |
|
int |
|
boolean |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
static int |
|
int |
|
static int |
|
static int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
static int |
|
static int |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
IBasicEvents |
|
Runnable |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public static final int black
The color black (0x000000)
- Field Value:
- 0
public static final int blue
The color blue (0x0000FF)
- Field Value:
- 255
public static final int brown
The color brown (0x8B4513)
- Field Value:
- 9127187
public int energy
Current energy of this robot, where 100 means full energy and 0 means no energy (dead).
public static final int gray
The color gray (0x808080)
- Field Value:
- 8421504
public static final int green
The color green (0x008000)
- Field Value:
- 32768
public int gunBearing
Current gun heading angle of this robot compared to its body (in degrees).
public int gunHeading
Current gun heading angle of this robot (in degrees).
public boolean gunReady
Flag specifying if the gun is ready to fire, i.e. gun heat <= 0.true
means that the gun is able to fire;false
means that the gun cannot fire yet as it still needs to cool down.
- See Also:
fire()
,fire(double)
public int heading
Current heading angle of this robot (in degrees).
public int hitByBulletAngle
Latest angle from where this robot was hit by a bullet (in degrees). If the robot has never been hit, this field will be less than 0, i.e. -1. This field will not be updated whileonHitByBullet()
event is active.
- See Also:
onHitByBullet()
,hitByBulletBearing
public int hitByBulletBearing
Latest angle from where this robot was hit by a bullet (in degrees) compared to the body of this robot. If the robot has never been hit, this field will be less than 0, i.e. -1. This field will not be updated whileonHitByBullet()
event is active.
- See Also:
onHitByBullet()
,hitByBulletAngle
public int hitRobotAngle
Latest angle where this robot has hit another robot (in degrees). If this robot has never hit another robot, this field will be less than 0, i.e. -1. This field will not be updated whileonHitRobot()
event is active.
- See Also:
onHitRobot()
,hitRobotBearing
public int hitRobotBearing
Latest angle where this robot has hit another robot (in degrees) compared to the body of this robot. If this robot has never hit another robot, this field will be less than 0, i.e. -1. This field will not be updated whileonHitRobot()
event is active.
- See Also:
onHitRobot()
,hitRobotAngle
public int hitWallAngle
Latest angle where this robot has hit a wall (in degrees). If this robot has never hit a wall, this field will be less than 0, i.e. -1. This field will not be updated whileonHitWall()
event is active.
- See Also:
onHitWall()
,hitWallBearing
public int hitWallBearing
Latest angle where this robot has hit a wall (in degrees) compared to the body of this robot. If this robot has never hit a wall, this field will be less than 0, i.e. -1. This field will not be updated whileonHitWall()
event is active.
- See Also:
onHitWall()
,hitWallAngle
public static final int orange
The color orange (0xFFA500)
- Field Value:
- 16753920
public int others
Current number of other robots on the battle field.
public static final int purple
The color purple (0x800080)
- Field Value:
- 8388736
public static final int red
The color red (0xFF0000)
- Field Value:
- 16711680
public int scannedAngle
Current angle to the scanned nearest other robot (in degrees). If there is no robot in the radar's sight, this field will be less than 0, i.e -1. This field will not be updated whileonScannedRobot()
event is active.
public int scannedBearing
Current angle to the scanned nearest other robot (in degrees) compared to the body of this robot. If there is no robot in the radar's sight, this field will be less than 0, i.e -1. This field will not be updated whileonScannedRobot()
event is active.
public int scannedDistance
Current distance to the scanned nearest other robot (in pixels). If there is no robot in the radar's sight, this field will be less than 0, i.e -1. This field will not be updated whileonScannedRobot()
event is active.
public int scannedEnergy
Current energy of scanned nearest other robot. If there is no robot in the radar's sight, this field will be less than 0, i.e -1. This field will not be updated whileonScannedRobot()
event is active.
public int scannedHeading
Current heading of the scanned nearest other robot (in degrees). If there is no robot in the radar's sight, this field will be less than 0, i.e -1. This field will not be updated whileonScannedRobot()
event is active.
public int scannedVelocity
Current velocity of the scanned nearest other robot. If there is no robot in the radar's sight, this field will be -99. Note that a positive value means that the robot moves forward, a negative value means that the robot moved backward, and 0 means that the robot is not moving at all. This field will not be updated whileonScannedRobot()
event is active.
public static final int white
The color white (0xFFFFFF)
- Field Value:
- 16777215
public static final int yellow
The color yellow (0xFFFF00)
- Field Value:
- 16776960
public void ahead(int distance)
Moves this robot forward by pixels.
- Parameters:
distance
- the amount of pixels to move forward
public void back(int distance)
Moves this robot backward by pixels.
- Parameters:
distance
- the amount of pixels to move backward
- See Also:
ahead(int)
,robotX
,robotY
public void bearGunTo(int angle)
Turns the gun to the specified angle (in degrees) relative to body of this robot. The gun will turn to the side with the shortest delta angle to the specified angle.
- Parameters:
angle
- the angle to turn the gun to relative to the body of this robot
- See Also:
gunHeading
,gunBearing
,turnGunLeft(int)
,turnGunRight(int)
,turnGunTo(int)
public void doNothing(int turns)
Skips the specified number of turns.
- Parameters:
turns
- the number of turns to skip
- See Also:
doNothing()
public void fire()
Fires a bullet with the default power of 1. If the gun heat is more than 0 and hence cannot fire, this method will suspend until the gun is ready to fire, and then fire a bullet.
- See Also:
gunReady
public void fire(double power)
Fires a bullet with the specified bullet power, which is between 0.1 and 3 where 3 is the maximum bullet power. If the gun heat is more than 0 and hence cannot fire, this method will suspend until the gun is ready to fire, and then fire a bullet.
- Parameters:
power
- between 0.1 and 3
- See Also:
gunReady
public final IBasicEvents getBasicEventListener()
Do not call this method!
- Specified by:
- getBasicEventListener in interface IBasicRobot
public final Runnable getRobotRunnable()
Do not call this method!
- Specified by:
- getRobotRunnable in interface IBasicRobot
public void onHitByBullet()
This event methods is called from the game when this robot has been hit by another robot's bullet. When this event occurs thehitByBulletAngle
andhitByBulletBearing
fields values are automatically updated.
- See Also:
hitByBulletAngle
,hitByBulletBearing
public void onHitRobot()
This event methods is called from the game when a bullet from this robot has hit another robot. When this event occurs thehitRobotAngle
andhitRobotBearing
fields values are automatically updated.
- See Also:
hitRobotAngle
,hitRobotBearing
public void onHitWall()
This event methods is called from the game when this robot has hit a wall. When this event occurs thehitWallAngle
andhitWallBearing
fields values are automatically updated.
- See Also:
hitWallAngle
,hitWallBearing
public void onScannedRobot()
This event method is called from the game when the radar detects another robot. When this event occurs thescannedDistance
,scannedAngle
,scannedBearing
, andscannedEnergy
field values are automatically updated.
- See Also:
scannedDistance
,scannedAngle
,scannedBearing
,scannedEnergy
public void run()
The main method in every robot. You must override this to set up your robot's basic behavior. Example:// A basic robot that moves around in a square public void run() { ahead(100); turnRight(90); }This method is automatically re-called when it has returned.
public void setColors(int bodyColor, int gunColor, int radarColor)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
- Parameters:
bodyColor
- the RGB color value for the bodygunColor
- the RGB color value for the gunradarColor
- the RGB color value for the radar
- See Also:
setColors(int,int,int,int,int)
public void setColors(int bodyColor, int gunColor, int radarColor, int bulletColor, int scanArcColor)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
- Parameters:
bodyColor
- the RGB color value for the bodygunColor
- the RGB color value for the gunradarColor
- the RGB color value for the radarbulletColor
- the RGB color value for the bulletsscanArcColor
- the RGB color value for the scan arc
- See Also:
setColors(int,int,int)
public void turnAheadLeft(int distance, int degrees)
Moves this robot forward by pixels and turns this robot left by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time. Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
- Parameters:
distance
- the amount of pixels to move forwarddegrees
- the amount of degrees to turn to the left
public void turnAheadRight(int distance, int degrees)
Moves this robot forward by pixels and turns this robot right by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time. Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
- Parameters:
distance
- the amount of pixels to move forwarddegrees
- the amount of degrees to turn to the right
public void turnBackLeft(int distance, int degrees)
Moves this robot backward by pixels and turns this robot left by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time. Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
- Parameters:
distance
- the amount of pixels to move backwarddegrees
- the amount of degrees to turn to the left
public void turnBackRight(int distance, int degrees)
Moves this robot backward by pixels and turns this robot right by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time. Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
- Parameters:
distance
- the amount of pixels to move backwarddegrees
- the amount of degrees to turn to the right
public void turnGunLeft(int degrees)
Turns the gun left by degrees.
- Parameters:
degrees
- the amount of degrees to turn the gun to the left
- See Also:
gunHeading
,gunBearing
,turnGunRight(int)
,turnGunTo(int)
,bearGunTo(int)
public void turnGunRight(int degrees)
Turns the gun right by degrees.
- Parameters:
degrees
- the amount of degrees to turn the gun to the right
- See Also:
gunHeading
,gunBearing
,turnGunLeft(int)
,turnGunTo(int)
,bearGunTo(int)
public void turnGunTo(int angle)
Turns the gun to the specified angle (in degrees). The gun will turn to the side with the shortest delta angle to the specified angle.
- Parameters:
angle
- the angle to turn the gun to
- See Also:
gunHeading
,gunBearing
,turnGunLeft(int)
,turnGunRight(int)
,bearGunTo(int)
public void turnLeft(int degrees)
Turns this robot left by degrees.
- Parameters:
degrees
- the amount of degrees to turn to the left
public void turnRight(int degrees)
Turns this robot right by degrees.
- Parameters:
degrees
- the amount of degrees to turn to the right
public void turnTo(int angle)
Turns this robot to the specified angle (in degrees). The robot will turn to the side with the shortest delta angle to the specified angle.
- Parameters:
angle
- the angle to turn this robot to