RateControlRobot PropertiesRobocode Robot API for .NET
The RateControlRobot type exposes the following members.
Properties

  NameDescription
Public propertyBattleFieldHeight
Returns the height of the current battlefield measured in pixels.
(Inherited from Robot.)
Public propertyBattleFieldWidth
Returns the width of the current battlefield measured in pixels.
(Inherited from Robot.)
Public propertyBodyColor
Sets the color of the robot's body.

A null indicates the default (blue) color.

Examples

// Don't forget to using System.Drawing at the top... 
using System.Drawing;
...

public void Run()
{
    SetBodyColor(Color.Black);
    ...
}
(Inherited from Robot.)
Public propertyBulletColor
Sets the color of the robot's bullets.

A null indicates the default white color.

Examples

// Don't forget to using System.Drawing at the top... 
using System.Drawing;
...

public void Run()
{
    SetBulletColor(Color.Green);
    ...
}
(Inherited from Robot.)
Public propertyDataQuotaAvailable
Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.
(Inherited from AdvancedRobot.)
Public propertyDebugProperty
Sets the debug property with the specified key to the specified value.

This method is very useful when debugging or reviewing your robot as you will be able to see this property displayed in the robot console for your robots under the Debug Properties tab page.
(Inherited from Robot.)
Public propertyDistanceRemaining
Returns the distance remaining in the robot's current move measured in pixels.

This call returns both positive and negative values. Positive values means that the robot is currently moving forwards. Negative values means that the robot is currently moving backwards. If the returned value is 0, the robot currently stands still.
(Inherited from AdvancedRobot.)
Public propertyEnergy
Returns the robot's current energy.
(Inherited from Robot.)
Public propertyGraphics
Returns a graphics context used for painting graphical items for the robot.

This method is very useful for debugging your robot.

Note that the robot will only be painted if the "Paint" is enabled on the robot's console window; otherwise the robot will never get painted (the reason being that all robots might have graphical items that must be painted, and then you might not be able to tell what graphical items that have been painted for your robot).

Also note that the coordinate system for the graphical context where you paint items fits for the Robocode coordinate system where (0, 0) is at the bottom left corner of the battlefield, where X is towards right and Y is upwards.
(Inherited from Robot.)
Public propertyGunColor
Sets the color of the robot's gun.

A null indicates the default (blue) color.

Examples

// Don't forget to using System.Drawing at the top... 
using System.Drawing;
...

public void Run()
{
    SetGunColor(Color.Red);
    ...
}
(Inherited from Robot.)
Public propertyGunCoolingRate
Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn.

The gun cooling rate is default 0.1 / turn, but can be changed by the battle setup. So don't count on the cooling rate being 0.1!
(Inherited from Robot.)
Public propertyGunHeading
Returns the direction that the robot's gun is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.
(Inherited from Robot.)
Public propertyGunHeadingRadians
Returns the direction that the robot's gun is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 2 means West.
(Inherited from AdvancedRobot.)
Public propertyGunHeat
Returns the current heat of the gun. The gun cannot Fire unless this is 0. (Calls to Fire will succeed, but will not actually Fire unless GetGunHeat() == 0).

The amount of gun heat generated when the gun is fired is 1 + (firePower / 5). Each turn the gun heat drops by the amount returned by GunCoolingRate, which is a battle setup.

Note that all guns are "hot" at the start of each round, where the gun heat is 3.
(Inherited from Robot.)
Public propertyGunRotationRate
The gun's clockwise (right) rotation per turn, in degrees.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)

Examples

// Set the gun to turn right 15 degrees per turn
GunRotationRate = 15;

// Set the gun to turn left 9 degrees per turn 
// (overrides the previous order)
GunRotationRate = -9;

...
// Executes the last GunRotationRate()
Execute();
Public propertyGunRotationRateRadians
The gun's clockwise (right) rotation per turn, in radians.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the gun turns counterclockwise (left)

Examples

// Set the gun to turn right pi / 16 radians per turn
GunRotationRateRadians = Math.PI / 16;

// Set the gun to turn left pi / 12 radians per turn 
// (overrides the previous order)
GunRotationRateRadians = -Math.PI / 12;

...
// Executes the last GunRotationRateRadians
Execute();
Public propertyGunTurnRemaining
Returns the angle remaining in the gun's turn, in degrees.

This call returns both positive and negative values. Positive values means that the gun is currently turning to the right. Negative values means that the gun is currently turning to the left. If the returned value is 0, the gun is currently not turning.
(Inherited from AdvancedRobot.)
Public propertyGunTurnRemainingRadians
Returns the angle remaining in the gun's turn, in radians.

This call returns both positive and negative values. Positive values means that the gun is currently turning to the right. Negative values means that the gun is currently turning to the left.
(Inherited from AdvancedRobot.)
Public propertyHeading
Returns the direction that the robot's body is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.
(Inherited from Robot.)
Public propertyHeadingRadians
Returns the direction that the robot's body is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 2 means West.
(Inherited from AdvancedRobot.)
Public propertyHeight
Returns the height of the robot measured in pixels.
(Inherited from Robot.)
Public propertyIsAdjustGunForRobotTurn
Sets the gun to turn independent from the robot's turn.

Ok, so this needs some explanation: The gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, then the gun will turn with it as it is mounted on top of the robot's body. To compensate for this, you can call IsAdjustGunForRobotTurn. When this is set, the gun will turn independent from the robot's turn, i.e. the gun will compensate for the robot's body turn.

Note: This method is additive until you reach the maximum the gun can turn. The "adjust" is added to the amount you set for turning the robot, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Examples

Assuming both the robot and gun start Out facing up (0 degrees):
// Set gun to turn with the robot's turn
SetAdjustGunForRobotTurn(false); // This is the default
TurnRight(90);
// At this point, both the robot and gun are facing right (90 degrees)
TurnLeft(90);
// Both are back to 0 degrees
// Set gun to turn independent from the robot's turn
SetAdjustGunForRobotTurn(true);
TurnRight(90);
// At this point, the robot is facing right (90 degrees), but the gun is still facing up.
TurnLeft(90);
// Both are back to 0 degrees.
-- or --

Note: The gun compensating this way does count as "turning the gun".
(Inherited from Robot.)
Public propertyIsAdjustRadarForGunTurn
Sets the radar to turn independent from the gun's turn.

Ok, so this needs some explanation: The radar is mounted on the robot's gun. So, normally, if the gun turns 90 degrees to the right, then the radar will turn with it as it is mounted on top of the gun. To compensate for this, you can call IsAdjustRadarForGunTurn = (true). When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the gun's turn.

Note: This method is additive until you reach the maximum the radar can turn. The "adjust" is added to the amount you set for turning the gun, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Examples

Assuming both the gun and radar start Out facing up (0 degrees):
// Set radar to turn with the gun's turn
SetAdjustRadarForGunTurn(false); // This is the default
TurnGunRight(90);
// At this point, both the radar and gun are facing right (90 degrees);
// Set radar to turn independent from the gun's turn
SetAdjustRadarForGunTurn(true);
TurnGunRight(90);
// At this point, the gun is facing right (90 degrees), but the radar is still facing up.
-- or -- Note: Calling IsAdjustRadarForGunTurn will automatically call IsAdjustRadarForRobotTurn with the same value, unless you have already called it earlier. This behavior is primarily for backward compatibility with older Robocode robots.
(Inherited from Robot.)
Public propertyIsAdjustRadarForRobotTurn
Sets the radar to turn independent from the robot's turn.

Ok, so this needs some explanation: The radar is mounted on the gun, and the gun is mounted on the robot's body. So, normally, if the robot turns 90 degrees to the right, the gun turns, as does the radar. Hence, if the robot turns 90 degrees to the right, then the gun and radar will turn with it as the radar is mounted on top of the gun. To compensate for this, you can call IsAdjustRadarForRobotTurn = true. When this is set, the radar will turn independent from the robot's turn, i.e. the radar will compensate for the robot's turn.

Note: This method is additive until you reach the maximum the radar can turn. The "adjust" is added to the amount you set for turning the robot, then capped by the physics of the game. If you turn infinite, then the adjust is ignored (and hence overridden).

Examples

Assuming the robot, gun, and radar all start Out facing up (0 degrees):
// Set radar to turn with the robots's turn
SetAdjustRadarForRobotTurn(false); // This is the default
TurnRight(90);
// At this point, the body, gun, and radar are all facing right (90 degrees);
// Set radar to turn independent from the robot's turn
SetAdjustRadarForRobotTurn(true);
TurnRight(90);
// At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up.
-- or --
(Inherited from Robot.)
Public propertyIsInterruptible
Call this during an event handler to allow new events of the same priority to restart the event handler.

Examples

public override void OnScannedRobot(ScannedRobotEvent e)
{
    Fire(1);
    IsInterruptible = true;
    Ahead(100); // If you see a robot while moving ahead, 
                // this handler will start from the top 
                // Without IsInterruptible (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.WriteLine("Ok, I can't see anyone");
}
(Inherited from AdvancedRobot.)
Public propertyMaxTurnRate
Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than MAX_TURN_RATE (10 degress/turn).
(Inherited from AdvancedRobot.)
Public propertyMaxVelocity
Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than MAX_VELOCITY (8 pixels/turn).
(Inherited from AdvancedRobot.)
Public propertyName
Returns the robot's name.
(Inherited from Robot.)
Public propertyNumRounds
Returns the number of rounds in the current battle.
(Inherited from Robot.)
Public propertyNumSentries
Returns how many sentry robots that are left in the current round.
(Inherited from Robot.)
Public propertyOthers
Returns how many opponents that are left in the current round.
(Inherited from Robot.)
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);
}
(Inherited from Robot.)
Public propertyRadarColor
Sets the color of the robot's radar.

A null indicates the default (blue) color.

Examples

// Don't forget to using System.Drawing at the top... 
using System.Drawing;
...

public void Run()
{
    SetRadarColor(Color.Yellow);
    ...
}
(Inherited from Robot.)
Public propertyRadarHeading
Returns the direction that the robot's radar is facing, in degrees. The value returned will be between 0 and 360 (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, 90 means East, 180 means South, and 270 means West.
(Inherited from Robot.)
Public propertyRadarHeadingRadians
Returns the direction that the robot's radar is facing, in radians. The value returned will be between 0 and 2 * PI (is excluded).

Note that the heading in Robocode is like a compass, where 0 means North, PI / 2 means East, PI means South, and 3 * PI / 2 means West.
(Inherited from AdvancedRobot.)
Public propertyRadarRotationRate
The radar's clockwise (right) rotation per turn, in degrees.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)

Examples

// Set the radar to turn right 45 degrees per turn
RadarRotationRate = 45;

// Set the radar to turn left 15 degrees per turn 
// (overrides the previous order)
RadarRotationRate = -15;

...
// Executes the last RadarRotationRate
Execute();
Public propertyRadarRotationRateRadians
The radar's clockwise (right) rotation per turn, in radians.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the radar turns counterclockwise (left)

Examples

// Set the radar to turn right pi / 4 radians per turn
RadarRotationRateRadians = Math.PI / 4;

// Set the radar to turn left pi / 8 radians per turn 
// (overrides the previous order)
RadarRotationRateRadians = -Math.PI / 8;

...
// Executes the last RadarRotationRateRadians
Execute();
Public propertyRadarTurnRemaining
Returns the angle remaining in the radar's turn, in degrees.

This call returns both positive and negative values. Positive values means that the radar is currently turning to the right. Negative values means that the radar is currently turning to the left. If the returned value is 0, the radar is currently not turning.
(Inherited from AdvancedRobot.)
Public propertyRadarTurnRemainingRadians
Returns the angle remaining in the radar's turn, in radians.

This call returns both positive and negative values. Positive values means that the radar is currently turning to the right. Negative values means that the radar is currently turning to the left.
(Inherited from AdvancedRobot.)
Public propertyRoundNum
Returns the current round number (0 to NumRounds - 1) of the battle.
(Inherited from Robot.)
Public propertyScanColor
Sets the color of the robot's scan arc.

A null indicates the default (blue) color.

Examples

// Don't forget to using System.Drawing at the top... 
using System.Drawing;
...

public void Run()
{
    SetScanColor(Color.White);
    ...
}
(Inherited from Robot.)
Public propertySentryBorderSize
Returns the sentry border size for a BorderSentry that defines the how far a BorderSentry is allowed to move from the border edges measured in units.
Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this border area.
(Inherited from Robot.)
Public propertyTeammates
Returns the names of all teammates, or null there is no teammates. The length of the string array is equal to the number of teammates.

Examples

public void Run()
{
    // Prints Out all teammates 
    string[] teammates = GetTeammates();
    if (teammates != null)
    {
        foreach (string member in teammates)
        {
            Out.WriteLine(member);
        }
    }
}
(Inherited from TeamRobot.)
Public propertyTime
Returns the game time of the current round, where the time is equal to the current turn in the round.

A battle consists of multiple rounds.

Time is reset to 0 at the beginning of every round.
(Inherited from Robot.)
Public propertyTurnRate
The robot's clockwise (right) rotation per turn, in degrees.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)

Examples

// Set the robot to turn right 10 degrees per turn
TurnRate = 10;

// Set the robot to turn left 4 degrees per turn 
// (overrides the previous order)
TurnRate = -5;

...
// Executes the last TurnRate
Execute();
Public propertyTurnRateRadians
The robot's clockwise (right) rotation per turn, in radians.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the robot turns counterclockwise (left)

Examples

// Set the robot to turn right pi / 32 radians per turn
TurnRateRadians = Math.PI / 32;

// Set the robot to turn left pi / 20 radians per turn 
// (overrides the previous order)
TurnRateRadians = -Math.PI / 20;

...
// Executes the last TurnRateRadians
Execute();
Public propertyTurnRemaining
Returns the angle remaining in the robots's turn, in degrees.

This call returns both positive and negative values. Positive values means that the robot is currently turning to the right. Negative values means that the robot is currently turning to the left. If the returned value is 0, the robot is currently not turning.
(Inherited from AdvancedRobot.)
Public propertyTurnRemainingRadians
Returns the angle remaining in the robot's turn, in radians.

This call returns both positive and negative values. Positive values means that the robot is currently turning to the right. Negative values means that the robot is currently turning to the left.
(Inherited from AdvancedRobot.)
Public propertyVelocity
Returns the velocity of the robot measured in pixels/turn.

The maximum velocity of a robot is defined by MAX_VELOCITY (8 pixels / turn).
(Inherited from Robot.)
Public propertyVelocityRate
The speed the robot will move (forward), in pixels per turn.

This call returns immediately, and will not execute until you call Execute() or take an action that executes.

Note that both positive and negative values can be given as input, where negative values means that the robot will move backwards

Examples

// Set the robot to move forward 2 pixels per turn
VelocityRate = 2;

// Set the robot to move backwards 8 pixels per turn 
// (overrides the previous order)
VelocityRate = -8;

...
// Executes the last VelocityRate
Execute();
Note: This method overrules SetAhead(Double) and SetBack(Double)
Public propertyWidth
Returns the width of the robot measured in pixels.
(Inherited from Robot.)
Public propertyX
Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.
(Inherited from Robot.)
Public propertyY
Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.
(Inherited from Robot.)
Back to Top
See Also