JuniorRobot MembersRobocode Robot API for .NET

The JuniorRobot type exposes the following members.
Constructors

  NameDescription
Protected methodJuniorRobot
Initializes a new instance of the JuniorRobot class
Back to Top
Methods

  NameDescription
Public methodAhead
Moves this robot forward by pixels.
Public methodBack
Moves this robot backward by pixels.
Public methodBearGunTo
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.
Public methodDoNothing 
Skips a turn.
Public methodDoNothing(Int32)
Skips the specified number of turns.
Public methodFire 
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.
Public methodFire(Double)
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.
Public methodOnHitByBullet
This event method is called from the game when this robot has been hit by another robot's bullet. When this event occurs the HitByBulletAngle and HitByBulletBearing fields values are automatically updated.
Public methodOnHitRobot
This event method is called from the game when a bullet from this robot has hit another robot. When this event occurs the HitRobotAngle and HitRobotBearing fields values are automatically updated.
Public methodOnHitWall
This event method is called from the game when this robot has hit a wall. When this event occurs the HitWallAngle and HitWallBearing fields values are automatically updated.
Public methodOnScannedRobot
This event method is called from the game when the radar detects another robot. When this event occurs the ScannedDistance, ScannedAngle, ScannedBearing, and ScannedEnergy field values are automatically updated.
Public methodRun
The main method in every robot. You must override this to set up your robot's basic behavior.

Examples

// 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 methodSetColors(Int32, Int32, Int32)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
Public methodSetColors(Int32, Int32, Int32, Int32, Int32)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
Public methodTurnAheadLeft
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.
Public methodTurnAheadRight
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.
Public methodTurnBackLeft
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.
Public methodTurnBackRight
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.
Public methodTurnGunLeft
Turns the gun left by degrees.
Public methodTurnGunRight
Turns the gun right by degrees.
Public methodTurnGunTo
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.
Public methodTurnLeft
Turns this robot left by degrees.
Public methodTurnRight
Turns this robot right by degrees.
Public methodTurnTo
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.
Back to Top
Fields

  NameDescription
Public fieldStatic memberBLACK
The color black (0x000000)
Public fieldStatic memberBLUE
The color blue (0x0000FF)
Public fieldStatic memberBROWN
The color brown (0x8B4513)
Public fieldStatic memberGRAY
The color gray (0x808080)
Public fieldStatic memberGREEN
The color green (0x008000)
Public fieldStatic memberORANGE
The color orange (0xFFA500)
Public fieldStatic memberPURPLE
The color purple (0x800080)
Public fieldStatic memberRED
The color red (0xFF0000)
Public fieldStatic memberWHITE
The color white (0xFFFFFF)
Public fieldStatic memberYELLOW
The color yellow (0xFFFF00)
Back to Top
Properties

  NameDescription
Public propertyEnergy
Current energy of this robot, where 100 means full energy and 0 means no energy (dead).
Public propertyFieldHeight
Contains the height of the battlefield.
Public propertyFieldWidth
Contains the width of the battlefield.
Public propertyGunBearing
Current gun heading angle of this robot compared to its body (in degrees).
Public propertyGunHeading
Current gun heading angle of this robot (in degrees).
Public propertyHeading
Current heading angle of this robot (in degrees).
Public propertyHitByBulletAngle
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 while OnHitByBullet  event is active.
Public propertyHitByBulletBearing
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 while OnHitByBullet  event is active.
Public propertyHitRobotAngle
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 while OnHitRobot  event is active.
Public propertyHitRobotBearing
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 while OnHitRobot  event is active.
Public propertyHitWallAngle
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 while OnHitWall  event is active.
Public propertyHitWallBearing
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 while OnHitWall  event is active.
Public propertyIsGunReady
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.
Public propertyOthers
Current number of other robots on the battle field.
Public propertyOut
The Out stream your robot should use to print.

You can view the print-outs by clicking the button for your robot in the right side of the battle window.

Examples

// Print Out a line each time my robot hits another robot 
public void OnHitRobot(HitRobotEvent e)
{
    Out.WriteLine("I hit a robot!  My energy: " + Energy + " his energy: " + e.Energy);
}
Public propertyRobotX
Current horizontal location of this robot (in pixels).
Public propertyRobotY
Current vertical location of this robot (in pixels).
Public propertyScannedAngle
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 while OnScannedRobot  event is active.
Public propertyScannedBearing
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 while OnScannedRobot  event is active.
Public propertyScannedDistance
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 while OnScannedRobot  event is active.
Public propertyScannedEnergy
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 while OnScannedRobot  event is active.
Public propertyScannedHeading
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 while OnScannedRobot  event is active.
Public propertyScannedVelocity
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 while OnScannedRobot  event is active.
Back to Top
See Also