- Class
Class JuniorRobot
- robocode.JuniorRobot
Robocode Download
- All Implemented Interfaces:
- Runnable, IBasicRobot, IJuniorRobot
This is the simplest robot type, which is simpler than theRobot
andAdvancedRobot
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.
- Since:
- 1.4
- Author:
- Nutch Poovarawan from Cubic Creative (designer), Flemming N. Larsen (original), Pavel Savara (contributor)
- See Also:
Robot
,AdvancedRobot
,TeamRobot
,RateControlRobot
,Droid
,BorderSentry
Apr 04, 2018 Download Robocode for free. Robocode is a programming tank game for Java and.NET. Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks in Java or.NET. The robot battles are running in real-time and on-screen. Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks. The program allows: programming robots.
Robocode Robots
Field Summary
Fields Modifier and Type Field and Description static int
black
static int
blue
The color blue (0x0000FF)static int
brown
int
energy
Current energy of this robot, where 100 means full energy and 0 means no energy (dead).int
fieldHeight
int
fieldWidth
Contains the width of the battlefield.static int
gray
static int
green
The color green (0x008000)int
gunBearing
Current gun heading angle of this robot compared to its body (in degrees).int
gunHeading
Current gun heading angle of this robot (in degrees).boolean
gunReady
Flag specifying if the gun is ready to fire, i.e. gun heat <= 0.int
heading
int
hitByBulletAngle
Latest angle from where this robot was hit by a bullet (in degrees).int
hitByBulletBearing
Latest angle from where this robot was hit by a bullet (in degrees) compared to the body of this robot.int
hitRobotAngle
Latest angle where this robot has hit another robot (in degrees).int
hitRobotBearing
Latest angle where this robot has hit another robot (in degrees) compared to the body of this robot.int
hitWallAngle
Latest angle where this robot has hit a wall (in degrees).int
hitWallBearing
Latest angle where this robot has hit a wall (in degrees) compared to the body of this robot.static int
orange
int
others
Current number of other robots on the battle field.static int
purple
static int
red
The color red (0xFF0000)int
robotX
Current horizontal location of this robot (in pixels).int
robotY
Current vertical location of this robot (in pixels).int
scannedAngle
Current angle to the scanned nearest other robot (in degrees).int
scannedBearing
Current angle to the scanned nearest other robot (in degrees) compared to the body of this robot.int
scannedDistance
Current distance to the scanned nearest other robot (in pixels).int
scannedEnergy
int
scannedHeading
Current heading of the scanned nearest other robot (in degrees).int
scannedVelocity
Current velocity of the scanned nearest other robot.static int
white
static int
yellow
The color yellow (0xFFFF00)Fields inherited from class robocode._RobotBase
out
Constructor Summary
Constructors Constructor and Description JuniorRobot()
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description void
ahead(int distance)
void
back(int distance)
Moves this robot backward by pixels.void
bearGunTo(int angle)
Turns the gun to the specified angle (in degrees) relative to body of this robot.void
doNothing()
void
doNothing(int turns)
Skips the specified number of turns.void
fire()
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.IBasicEvents
getBasicEventListener()
Runnable
getRobotRunnable()
Do not call this method!void
onHitByBullet()
This event methods is called from the game when this robot has been hit by another robot's bullet.void
onHitRobot()
This event methods is called from the game when a bullet from this robot has hit another robot.void
onHitWall()
This event methods is called from the game when this robot has hit a wall.void
onScannedRobot()
This event method is called from the game when the radar detects another robot.void
run()
void
setColors(int bodyColor, int gunColor, int radarColor)
Sets the colors of the robot.void
setColors(int bodyColor, int gunColor, int radarColor, int bulletColor, int scanArcColor)
void
turnAheadLeft(int distance, int degrees)
Moves this robot forward by pixels and turns this robot left by degrees at the same time.void
turnAheadRight(int distance, int degrees)
Moves this robot forward by pixels and turns this robot right by degrees at the same time.void
turnBackLeft(int distance, int degrees)
Moves this robot backward by pixels and turns this robot left by degrees at the same time.void
turnBackRight(int distance, int degrees)
Moves this robot backward by pixels and turns this robot right by degrees at the same time.void
turnGunLeft(int degrees)
void
turnGunRight(int degrees)
Turns the gun right by degrees.void
turnGunTo(int angle)
Turns the gun to the specified angle (in degrees).void
turnLeft(int degrees)
void
turnRight(int degrees)
Turns this robot right by degrees.void
turnTo(int angle)
Turns this robot to the specified angle (in degrees).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
setOut, setPeer
Field Detail
black
- See Also:
- Constant Field Values
white
The color white (0xFFFFFF)- See Also:
- Constant Field Values
red
- See Also:
- Constant Field Values
orange
The color orange (0xFFA500)- See Also:
- Constant Field Values
yellow
- See Also:
- Constant Field Values
green
The color green (0x008000)- See Also:
- Constant Field Values
blue
- See Also:
- Constant Field Values
purple
The color purple (0x800080)- See Also:
- Constant Field Values
brown
- See Also:
- Constant Field Values
gray
The color gray (0x808080)- See Also:
- Constant Field Values
fieldWidth
- See Also:
fieldWidth
fieldHeight
Contains the height of the battlefield.- See Also:
fieldWidth
others
Current number of other robots on the battle field.
energy
Current energy of this robot, where 100 means full energy and 0 means no energy (dead).
robotX
Current horizontal location of this robot (in pixels).- See Also:
robotY
robotY
Current vertical location of this robot (in pixels).- See Also:
robotX
heading
- See Also:
turnLeft(int)
,turnRight(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
gunHeading
Current gun heading angle of this robot (in degrees).- See Also:
gunBearing
,turnGunLeft(int)
,turnGunRight(int)
,turnGunTo(int)
,bearGunTo(int)
gunBearing
Current gun heading angle of this robot compared to its body (in degrees).- See Also:
gunHeading
,turnGunLeft(int)
,turnGunRight(int)
,turnGunTo(int)
,bearGunTo(int)
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)
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.- See Also:
onScannedRobot()
,scannedAngle
,scannedBearing
,scannedEnergy
,scannedVelocity
,scannedHeading
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.- See Also:
onScannedRobot()
,scannedDistance
,scannedBearing
,scannedEnergy
,scannedVelocity
,scannedHeading
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.- See Also:
onScannedRobot()
,scannedDistance
,scannedAngle
,scannedEnergy
,scannedVelocity
,scannedHeading
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.- See Also:
onScannedRobot()
,scannedDistance
,scannedAngle
,scannedBearing
,scannedEnergy
,scannedHeading
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.- See Also:
onScannedRobot()
,scannedDistance
,scannedAngle
,scannedBearing
,scannedEnergy
,scannedVelocity
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.- See Also:
onScannedRobot()
,scannedDistance
,scannedAngle
,scannedBearing
,scannedVelocity
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
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
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
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
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
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
Constructor Detail
JuniorRobot
Method Detail
ahead
- Parameters:
distance
- the amount of pixels to move forward- See Also:
back(int)
,robotX
,robotY
back
Moves this robot backward by pixels.- Parameters:
distance
- the amount of pixels to move backward- See Also:
ahead(int)
,robotX
,robotY
bearGunTo
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)
doNothing
- See Also:
doNothing(int)
doNothing
Skips the specified number of turns.- Parameters:
turns
- the number of turns to skip- See Also:
doNothing()
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
fire
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
getBasicEventListener
Do not call this method!This method is called by the game to notify this robot about basic robot event. Hence, this method must be implemented so it returns your
IBasicEvents
listener.- Specified by:
getBasicEventListener
in interfaceIBasicRobot
- Returns:
- listener to basic events or
null
if this robot should not receive the notifications.
getRobotRunnable
Do not call this method!This method is called by the game to invoke the
run()
method of your robot, where the program of your robot is implemented.- Specified by:
getRobotRunnable
in interfaceIBasicRobot
- Returns:
- a runnable implementation
- See Also:
Runnable.run()
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
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
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
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
run
The main method in every robot. You must override this to set up your robot's basic behavior.Example: This method is automatically re-called when it has returned.
- Specified by:
run
in interfaceRunnable
setColors
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)
setColors
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)
turnAheadLeft
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- See Also:
heading
,robotX
,robotY
,turnLeft(int)
,turnRight(int)
,turnTo(int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
turnAheadRight
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- See Also:
heading
,robotX
,robotY
,turnLeft(int)
,turnRight(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
turnBackLeft
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- See Also:
heading
,robotX
,robotY
,turnLeft(int)
,turnRight(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackRight(int, int)
turnBackRight
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- See Also:
heading
,robotX
,robotY
,turnLeft(int)
,turnRight(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
turnGunLeft
- Parameters:
degrees
- the amount of degrees to turn the gun to the left- See Also:
gunHeading
,gunBearing
,turnGunRight(int)
,turnGunTo(int)
,bearGunTo(int)
turnGunRight
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)
turnGunTo
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)
turnLeft
- Parameters:
degrees
- the amount of degrees to turn to the left- See Also:
heading
,turnRight(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
turnRight
Turns this robot right by degrees.- Parameters:
degrees
- the amount of degrees to turn to the right- See Also:
heading
,turnLeft(int)
,turnTo(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
turnTo
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- See Also:
heading
,turnLeft(int)
,turnRight(int)
,turnAheadLeft(int, int)
,turnAheadRight(int, int)
,turnBackLeft(int, int)
,turnBackRight(int, int)
C4 Robot Download Games
- Class
- Summary:
- Nested |
- Field |
- Constr |
- Detail:
- Field |
- Constr |
Copyright © 2017 Robocode. All Rights Reserved.