TeamRobot MembersRobocode Robot API for .NET

The TeamRobot type exposes the following members.
Constructors

  NameDescription
Protected methodTeamRobot
Initializes a new instance of the TeamRobot class
Back to Top
Methods

  NameDescription
Public methodAddCustomEvent(Condition)
Registers a custom event to be called when a condition is met. When you are finished with your condition or just want to remove it you must call RemoveCustomEvent(Condition).

Examples

// Create the condition for our custom event
Condition triggerHitCondition = new Condition("triggerhit")
{
    public bool Test()
    {
        return (Energy <= trigger);
    }
}

// Add our custom event based on our condition
AddCustomEvent(triggerHitCondition);
(Inherited from AdvancedRobot.)
Public methodAddCustomEvent(String, Int32, ConditionTest)
Same as AddCustomEvent(Condition), but alows to define condition as anonymous method.
(Inherited from AdvancedRobot.)
Public methodAhead
Immediately moves your robot ahead (forward) by distance measured in pixels.

This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0.

If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot.

Note that both positive and negative values can be given as input, where negative values means that the robot is set to move backward instead of forward.

Examples

// Move the robot 100 pixels forward
Ahead(100);

// Afterwards, move the robot 50 pixels backward
Ahead(-50);
(Inherited from Robot.)
Public methodBack
Immediately moves your robot backward by distance measured in pixels.

This call executes immediately, and does not return until it is complete, i.e. when the remaining distance to move is 0.

If the robot collides with a wall, the move is complete, meaning that the robot will not move any further. If the robot collides with another robot, the move is complete if you are heading toward the other robot.

Note that both positive and negative values can be given as input, where negative values means that the robot is set to move forward instead of backward.

Examples

// Move the robot 100 pixels backward
Back(100);

// Afterwards, move the robot 50 pixels forward
Back(-50);
(Inherited from Robot.)
Public methodBroadcastMessage
Broadcasts a message to all teammates.

Examples

public void Run()
{
    BroadcastMessage("I'm here!");
}
Public methodClearAllEvents
Clears Out any pending events in the robot's event queue immediately.
(Inherited from AdvancedRobot.)
Public methodDoNothing
Do nothing this turn, meaning that the robot will skip it's turn.

This call executes immediately, and does not return until the turn is over.
(Inherited from Robot.)
Public methodExecute
Executes any pending actions, or continues executing actions that are in process. This call returns after the actions have been started.

Note that advanced robots must call this function in order to Execute pending set* calls like e.g. SetAhead(Double), SetFire(Double), SetTurnLeft(Double) etc. Otherwise, these calls will never get executed.

In this example the robot will move while turning:
Examples

SetTurnRight(90);
SetAhead(100);
Execute();

while (DistanceRemaining > 0 && TurnRemaining > 0)
{
    Execute();
}
(Inherited from AdvancedRobot.)
Public methodFire
Immediately fires a bullet. The bullet will travel in the direction the gun is pointing.

The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call GetBulletDamage(Double) for getting the damage that a bullet with a specific bullet power will do.

The specified bullet power should be between MIN_BULLET_POWER and MAX_BULLET_POWER.

Note that the gun cannot Fire if the gun is overheated, meaning that GunHeat returns a value > 0.

A event is generated when the bullet hits a robot (BulletHitEvent), wall (BulletMissedEvent), or another bullet (BulletHitBulletEvent).

Examples

// Fire a bullet with maximum power if the gun is ready 
if (GetGunHeat() == 0)
{
    Fire(Rules.MAX_BULLET_POWER);
}
(Inherited from Robot.)
Public methodFireBullet
Immediately fires a bullet. The bullet will travel in the direction the gun is pointing.

The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call GetBulletDamage(Double) for getting the damage that a bullet with a specific bullet power will do.

The specified bullet power should be between MIN_BULLET_POWER and MAX_BULLET_POWER.

Note that the gun cannot Fire if the gun is overheated, meaning that GunHeat returns a value > 0.

A event is generated when the bullet hits a robot (BulletHitEvent), wall (BulletMissedEvent), or another bullet (BulletHitBulletEvent).

Examples

// Fire a bullet with maximum power if the gun is ready 
if (GetGunHeat() == 0)
{
    Bullet bullet = FireBullet(Rules.MAX_BULLET_POWER);

    // Get the velocity of the bullet 
    if (bullet != null)
    {
        double bulletVelocity = bullet.Velocity;
    }
}
Returns a Bullet That contains information about the bullet if it was actually fired, which can be used for tracking the bullet after it has been fired. If the bullet was not fired, null is returned.
(Inherited from Robot.)
Public methodGetAllEvents
Returns a list containing all events currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (Event evnt : GetAllEvents()) {
    if (evnt is HitRobotEvent) {
        // do something with the event
    } else if (evnt is HitByBulletEvent) {
        // do something with the event
    }
}
(Inherited from AdvancedRobot.)
Public methodGetBulletHitBulletEvents
Returns a list containing all BulletHitBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (BulletHitBulletEvent evnt : GetBulletHitBulletEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetBulletHitEvents
Returns a list containing all BulletHitEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (BulletHitEvent event: GetBulletHitEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetBulletMissedEvents
Returns a list containing all BulletMissedEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (BulletMissedEvent evnt : GetBulletMissedEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetDataDirectory
Returns a file representing a data directory for the robot.

The system will automatically create the directory for you, so you do not need to create it by yourself.
(Inherited from AdvancedRobot.)
Public methodGetDataFile
Returns a file in your data directory that you can write to.

The system will automatically create the directory for you, so you do not need to create it by yourself.

Please notice that the max. size of your data file is set to 200000 bytes (~195 KB).

See the Sample.SittingDuck to see an example of how to use this method.
(Inherited from AdvancedRobot.)
Public methodGetEventPriority
Returns the current priority of a class of events. An event priority is a value from 0 - 99. The higher value, the higher priority.

Examples

int myHitRobotPriority = GetEventPriority("HitRobotEvent");

The default priorities are, from highest to lowest:
BattleEndedEvent:     100 (reserved)
                WinEvent:             100 (reserved)
                SkippedTurnEvent:     100 (reserved)
                StatusEvent:           99
                Key and mouse events:  98
                CustomEvent:           80 (default value)
                MessageEvent:          75
                RobotDeathEvent:       70
                BulletMissedEvent:     60
                BulletHitBulletEvent:  55
                BulletHitEvent:        50
                HitByBulletEvent:      40
                HitWallEvent:          30
                HitRobotEvent:         20
                ScannedRobotEvent:     10
                PaintEvent:             5
                DeathEvent:            -1 (reserved)
              
(Inherited from AdvancedRobot.)
Public methodGetHitByBulletEvents
Returns a list containing all HitByBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (HitByBulletEvent evnt : GetHitByBulletEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetHitRobotEvents
Returns a list containing all HitRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (HitRobotEvent evnt : GetHitRobotEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetHitWallEvents
Returns a list containing all HitWallEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (HitWallEvent evnt : GetHitWallEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetMessageEvents
Returns a list containing all MessageEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

foreach (MessageEvent e in GetMessageEvents())
{
    // do something with e
}
Public methodGetRobotDeathEvents
Returns a list containing all RobotDeathEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (RobotDeathEvent evnt : GetRobotDeathEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetScannedRobotEvents
Returns a list containing all ScannedRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (ScannedRobotEvent evnt : GetScannedRobotEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodGetStatusEvents
Returns a list containing all StatusEvents currently in the robot's queue. You might, for example, call this while processing another event.

Examples

for (StatusEvent evnt : GetStatusEvents())
{
    // do something with the event
}
(Inherited from AdvancedRobot.)
Public methodIsTeammate
Checks if a given robot name is the name of one of your teammates.

Examples

public void OnScannedRobot(ScannedRobotEvent e)
{
    if (IsTeammate(e.Name)
    {
        return;
    }
    Fire(1);
}
Public methodOnBattleEnded
This method is called after end of the battle, even when the battle is aborted. You should override it in your robot if you want to be informed of this event.

Examples

public void OnBattleEnded(BattleEndedEvent evnt)
{
    Out.WriteLine("The battle has ended");
}
(Inherited from Robot.)
Public methodOnBulletHit
This method is called when one of your bullets hits another robot. You should override it in your robot if you want to be informed of this event.

Examples

public void OnBulletHit(BulletHitEvent evnt)
{
    Out.WriteLine("I hit " + evnt.Name + "!");
}
(Inherited from Robot.)
Public methodOnBulletHitBullet
This method is called when one of your bullets hits another bullet. You should override it in your robot if you want to be informed of this event.

Examples

public void OnBulletHitBullet(BulletHitBulletEvent evnt)
{
    Out.WriteLine("I hit a bullet fired by " + evnt.Bullet.Name + "!");
}
(Inherited from Robot.)
Public methodOnBulletMissed
This method is called when one of your bullets misses, i.e. hits a wall. You should override it in your robot if you want to be informed of this event.

Examples

public void OnBulletMissed(BulletMissedEvent evnt)
{
    Out.WriteLine("Drat, I missed.");
}
(Inherited from Robot.)
Public methodOnCustomEvent
This method is called when a custom condition is met.

See the sample robots for examples of use, e.g. the Sample.Target robot.
(Inherited from AdvancedRobot.)
Public methodOnDeath
This method is called if your robot dies.

You should override it in your robot if you want to be informed of this event. Actions will have no effect if called from this section. The intent is to allow you to perform calculations or print something out when the robot is killed.
(Inherited from AdvancedRobot.)
Public methodOnHitByBullet
This method is called when your robot is hit by a bullet. You should override it in your robot if you want to be informed of this event.

Examples

void OnHitByBullet(HitByBulletEvent evnt)
{
    Out.WriteLine(event.RobotName + " hit me!");
}
(Inherited from Robot.)
Public methodOnHitRobot
This method is called when your robot collides with another robot. You should override it in your robot if you want to be informed of this event.

Examples

void OnHitRobot(HitRobotEvent evnt)
{
    if (event.Bearing > -90 && evnt.Bearing <= 90)
    {
        Back(100);
    }
    else
    {
        Ahead(100);
    }
}
public void OnHitRobot(HitRobotEvent evnt)
{
    if (event.Bearing > -90 && evnt.Bearing <= 90)
    {
        SetBack(100);
    }
    else
    {
        SetAhead(100);
    }
}
-- or perhaps, for a more advanced robot --

The angle is relative to your robot's facing. So 0 is straight ahead of you.

This event can be generated if another robot hits you, in which case IsMyFault will return false. In this case, you will not be automatically stopped by the game -- but if you continue moving toward the robot you will hit it (and generate another event). If you are moving away, then you won't hit it.
(Inherited from Robot.)
Public methodOnHitWall
This method is called when your robot collides with a wall. You should override it in your robot if you want to be informed of this event.

The wall at the top of the screen is 0 degrees, right is 90 degrees, bottom is 180 degrees, left is 270 degrees. But this event is relative to your heading, so: The bearing is such that TurnRight(Double)Bearing will point you perpendicular to the wall.

Examples

void OnHitWall(HitWallEvent evnt)
{
    Out.WriteLine("Ouch, I hit a wall bearing " + evnt.Bearing + " degrees.");
}
(Inherited from Robot.)
Public methodOnKeyPressed
This method is called when a key has been pressed.

See the Sample.Interactive robot for an example of how to use key events.
(Inherited from Robot.)
Public methodOnKeyReleased
This method is called when a key has been released.

See the Sample.Interactive robot for an example of how to use key events.
(Inherited from Robot.)
Public methodOnKeyTyped
This method is called when a key has been typed (pressed and released).

See the Sample.Interactive robot for an example of how to use key events.
(Inherited from Robot.)
Public methodOnMessageReceived
This method is called when your robot receives a message from a teammate. You should override it in your robot if you want to be informed of this event.

Examples

public void OnMessageReceived(MessageEvent evnt)
{
    Out.WriteLine(event.Sender + " sent me: " + evnt.Message);
}
Public methodOnMouseClicked
This method is called when a mouse button has been clicked (pressed and released).

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseDragged
This method is called when a mouse button has been pressed and then dragged.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseEntered
This method is called when the mouse has entered the battle view.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseExited
This method is called when the mouse has exited the battle view.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseMoved
This method is called when the mouse has been moved.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMousePressed
This method is called when a mouse button has been pressed.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseReleased
This method is called when a mouse button has been released.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnMouseWheelMoved
This method is called when the mouse wheel has been rotated.

See the Sample.Interactive robot for an example of how to use mouse events.
(Inherited from Robot.)
Public methodOnPaint
This method is called every time the robot is painted. You should override this method if you want to draw items for your robot on the battle field, e.g. targets, virtual bullets etc.

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 methodOnRobotDeath
This method is called when another robot dies. You should override it in your robot if you want to be informed of this event.
(Inherited from Robot.)
Public methodOnRoundEnded
This method is called after the end of a round. You should override it in your robot if you want to be informed of this event.

Examples

public void OnRoundEnded(RoundEndedEvent event)
{
    Out.WriteLine("The round has ended");
}
(Inherited from Robot.)
Public methodOnScannedRobot
This method is called when your robot sees another robot, i.e. when the robot's radar scan "hits" another robot. You should override it in your robot if you want to be informed of this event. (Almost all robots should override this!)

This event is automatically called if there is a robot in range of your radar.

Note that the robot's radar can only see robot within the range defined by RADAR_SCAN_RADIUS (1200 pixels).

Also not that the bearing of the scanned robot is relative to your robot's heading.

Examples

void OnScannedRobot(ScannedRobotEvent evnt)
{
    // Assuming radar and gun are aligned... 
    if (event.Distance < 100)
    {
        Fire(3);
    }
    else
    {
        Fire(1);
    }
}

Note:
The game assists Robots in firing, as follows:
  • If the gun and radar are aligned (and were aligned last turn),
  • and the event is current,
  • and you call Fire() before taking any other actions, Robot.Fire(double) will Fire directly at the robot.

In essence, this means that if you can see a robot, and it doesn't move, then Fire will hit it.

AdvancedRobots will NOT be assisted in this manner, and are expected to examine the event to determine if Fire(Double) would hit. (i.e. you are spinning your gun around, but by the time you get the event, your gun is 5 degrees past the robot).
(Inherited from Robot.)
Public methodOnSkippedTurn
This method is called if the robot is using too much time between actions. When this event occur, the robot's turn is skipped, meaning that it cannot take action anymore in this turn.

If you receive 30 skipped turn event, your robot will be removed from the round and loose the round.

You will only receive this event after taking an action. So a robot in an infinite loop will not receive any events, and will simply be stopped.

No correctly working, reasonable robot should ever receive this event unless it is using too many CPU cycles.
(Inherited from AdvancedRobot.)
Public methodOnStatus
This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time.

The main benefit of this method is that you'll automatically receive all current data values of the robot like e.g. the x and y coordinate, heading, gun heat etc., which are grouped into the exact same time/turn.

This is the only way to map the robots data values to a specific time. For example, it is not possible to determine the exact time of the robot's heading by calling first calling Time and then Heading afterwards, as the time might change after between the Time and Heading call.
(Inherited from Robot.)
Public methodOnWin
This method is called if your robot wins a battle.

Your robot could perform a victory dance here! :-)
(Inherited from Robot.)
Public methodRemoveCustomEvent
Removes a custom event that was previously added by calling AddCustomEvent(Condition).

Examples

// Create the condition for our custom event
Condition triggerHitCondition = new Condition("triggerhit")
{
    public bool Test()
    {
        return (Energy <= trigger);
    }
}

// Add our custom event based on our condition
AddCustomEvent(triggerHitCondition);
...
// do something with your robot
...
// Remove the custom event based on our condition
RemoveCustomEvent(triggerHitCondition);
(Inherited from AdvancedRobot.)
Public methodResume
Immediately resumes the movement you stopped by Stop , if any.

This call executes immediately, and does not return until it is complete.
(Inherited from Robot.)
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()
{
    while (true)
    {
        Ahead(100);
        TurnRight(90);
    }
}
(Inherited from Robot.)
Public methodScan
Scans for other robots. This method is called automatically by the game, as long as the robot is moving, turning its body, turning its gun, or turning its radar.

Scan will cause OnScannedRobot(ScannedRobotEvent) to be called if you see a robot.

There are 2 reasons to call Scan  manually:
  1. You want to scan after you stop moving.
  2. You want to interrupt the OnScannedRobot(ScannedRobotEvent) event. This is more likely. If you are in OnScannedRobot(ScannedRobotEvent) and call Scan , and you still see a robot, then the system will interrupt your OnScannedRobot(ScannedRobotEvent) event immediately and start it from the top.

This call executes immediately.
(Inherited from Robot.)
Public methodSendMessage
Sends a message to one (or more) teammates.

Examples

public void Run()
{
    SendMessage("Sample.DroidBot", "I'm here!");
}
Public methodSetAhead
Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place.

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 positive values means that the robot is set to move ahead, and negative values means that the robot is set to move back. If 0 is given as input, the robot will stop its movement, but will have to decelerate till it stands still, and will thus not be able to stop its movement immediately, but eventually.
(Inherited from AdvancedRobot.)
Public methodSetAllColors
Sets all the robot's color to the same color in the same time, i.e. the color of the body, gun, radar, bullet, and scan arc.

You may only call this method one time per battle. A null indicates the default (blue) color for the body, gun, radar, and scan arc, but white for the bullet color.

Examples

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

public void Run()
{
    SetAllColors(Color.Red);
    ...
}
(Inherited from Robot.)
Public methodSetBack
Sets the robot to move back by distance measured in pixels when the next execution takes place.

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 positive values means that the robot is set to move back, and negative values means that the robot is set to move ahead. If 0 is given as input, the robot will stop its movement, but will have to decelerate till it stands still, and will thus not be able to stop its movement immediately, but eventually.

Examples

// Set the robot to move 50 pixels back
SetBack(50);

// Set the robot to move 100 pixels ahead 
// (overrides the previous order)
SetBack(-100);

...
// Executes the last SetBack()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetColors(Color, Color, Color)
Sets the color of the robot's body, gun, and radar in the same time.

You may only call this method one time per battle. A null indicates the default (blue) color.

Examples

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

public void Run()
{
    SetColors(null, Color.Red, Color.fromArgb(150, 0, 150));
    ...
}
(Inherited from Robot.)
Public methodSetColors(Color, Color, Color, Color, Color)
Sets the color of the robot's body, gun, radar, bullet, and scan arc in the same time.

You may only call this method one time per battle. A null indicates the default (blue) color for the body, gun, radar, and scan arc, but white for the bullet color.

Examples

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

public void Run()
{
    SetColors(null, Color.Red, Color.Greeen, null, Color.fromArgb(150, 0, 150));
    ...
}
(Inherited from Robot.)
Public methodSetEventPriority
Sets the priority of a class of events.

Events are sent to the onXXX handlers in order of priority. Higher priority events can interrupt lower priority events. For events with the same priority, newer events are always sent first. Valid priorities are 0 - 99, where 100 is reserved and 80 is the default priority.

Examples

SetEventPriority("RobotDeathEvent", 15);

The default priorities are, from highest to lowest:
WinEvent:             100 (reserved)
                SkippedTurnEvent:     100 (reserved)
                StatusEvent:           99
                CustomEvent:           80
                MessageEvent:          75
                RobotDeathEvent:       70
                BulletMissedEvent:     60
                BulletHitBulletEvent:  55
                BulletHitEvent:        50
                HitByBulletEvent:      40
                HitWallEvent:          30
                HitRobotEvent:         20
                ScannedRobotEvent:     10
                PaintEvent:             5
                DeathEvent:            -1 (reserved)
              

Note that you cannot change the priority for events with the special priority value -1 or 100 (reserved) as these events are system events. Also note that you cannot change the priority of CustomEvent. Instead you must change the priority of the condition(s) for your custom event(s).
(Inherited from AdvancedRobot.)
Public methodSetFire
Sets the gun to Fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing.

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

The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call Rules.GetBulletDamage(double)} for getting the damage that a bullet with a specific bullet power will do.

The specified bullet power should be between MIN_BULLET_POWER and MAX_BULLET_POWER.

Note that the gun cannot Fire if the gun is overheated, meaning that GunHeat returns a value > 0.

An event is generated when the bullet hits a robot, wall, or another bullet.

Examples

// Fire a bullet with maximum power if the gun is ready 
if (GunGeat == 0)
{
    SetFire(Rules.MAX_BULLET_POWER);
}
...
Execute();
(Inherited from AdvancedRobot.)
Public methodSetFireBullet
Sets the gun to Fire a bullet when the next execution takes place. The bullet will travel in the direction the gun is pointing.

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

The specified bullet power is an amount of energy that will be taken from the robot's energy. Hence, the more power you want to spend on the bullet, the more energy is taken from your robot.

The bullet will do (4 * power) damage if it hits another robot. If power is greater than 1, it will do an additional 2 * (power - 1) damage. You will get (3 * power) back if you hit the other robot. You can call GetBulletDamage(Double) for getting the damage that a bullet with a specific bullet power will do.

The specified bullet power should be between MIN_BULLET_POWER and MAX_BULLET_POWER.

Note that the gun cannot Fire if the gun is overheated, meaning that GunHeat returns a value > 0.

An event is generated when the bullet hits a robot (BulletHitEvent), wall (BulletMissedEvent), or another bullet (BulletHitBulletEvent).

Examples

Bullet bullet = null;

// Fire a bullet with maximum power if the gun is ready 
if (GunHeat == 0)
{
    bullet = SetFireBullet(Rules.MAX_BULLET_POWER);
}
...
Execute();
...
// Get the velocity of the bullet 
if (bullet != null)
{
    double bulletVelocity = bullet.Velocity;
}
(Inherited from AdvancedRobot.)
Public methodSetResume
Sets the robot to resume the movement stopped by Stop  or SetStop , if any.

This call returns immediately, and will not execute until you call Execute  or take an action that executes.
(Inherited from AdvancedRobot.)
Public methodSetStop 
This call is identical to Stop , but returns immediately, and will not execute until you call Execute  or take an action that executes.

If there is already movement saved from a previous stop, this will have no effect.

This call is equivalent to calling SetStop(false);
(Inherited from AdvancedRobot.)
Public methodSetStop(Boolean)
This call is identical to Stop(Boolean), but returns immediately, and will not execute until you call Execute  or take an action that executes.

If there is already movement saved from a previous stop, you can overwrite it by calling SetStop(true).
(Inherited from AdvancedRobot.)
Public methodSetTurnGunLeft
Sets the robot's gun to turn left by degrees when the next execution takes place.

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's gun is set to turn right instead of left.

Examples

// Set the gun to turn 180 degrees to the left
SetTurnGunLeft(180);

// Set the gun to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnGunLeft(-90);

...
// Executes the last SetTurnGunLeft()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnGunLeftRadians
Sets the robot's gun to turn left by radians when the next execution takes place.

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's gun is set to turn right instead of left.

Examples

// Set the gun to turn 180 degrees to the left
SetTurnGunLeftRadians(Math.PI);

// Set the gun to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnGunLeftRadians(-Math.PI / 2);

...
// Executes the last SetTurnGunLeftRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnGunRight
Sets the robot's gun to turn right by degrees when the next execution takes place.

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's gun is set to turn left instead of right.

Examples

// Set the gun to turn 180 degrees to the right
SetTurnGunRight(180);

// Set the gun to turn 90 degrees to the left instead of right 
// (overrides the previous order)
SetTurnGunRight(-90);

...
// Executes the last SetTurnGunRight()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnGunRightRadians
Sets the robot's gun to turn right by radians when the next execution takes place.

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's gun is set to turn left instead of right.

Examples

// Set the gun to turn 180 degrees to the right
SetTurnGunRightRadians(Math.PI);

// Set the gun to turn 90 degrees to the left instead of right 
// (overrides the previous order)
SetTurnGunRightRadians(-Math.PI / 2);

...
// Executes the last SetTurnGunRightRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnLeft
Sets the robot's body to turn left by degrees when the next execution takes place.

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's body is set to turn right instead of left.

Examples

// Set the robot to turn 180 degrees to the left
SetTurnLeft(180);

// Set the robot to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnLeft(-90);

...
// Executes the last SetTurnLeft()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnLeftRadians
Sets the robot's body to turn left by radians when the next execution takes place.

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's body is set to turn right instead of left.

Examples

// Set the robot to turn 180 degrees to the left
SetTurnLeftRadians(Math.PI);

// Set the robot to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnLeftRadians(-Math.PI / 2);

...
// Executes the last SetTurnLeftRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRadarLeft
Sets the robot's radar to turn left by degrees when the next execution takes place.

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's radar is set to turn right instead of left.

Examples

// Set the radar to turn 180 degrees to the left
SetTurnRadarLeft(180);

// Set the radar to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnRadarLeft(-90);

...
// Executes the last SetTurnRadarLeft()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRadarLeftRadians
Sets the robot's radar to turn left by radians when the next execution takes place.

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's radar is set to turn right instead of left.

Examples

// Set the radar to turn 180 degrees to the left
SetTurnRadarLeftRadians(Math.PI);

// Set the radar to turn 90 degrees to the right instead of left 
// (overrides the previous order)
SetTurnRadarLeftRadians(-Math.PI / 2);

...
// Executes the last SetTurnRadarLeftRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRadarRight
Sets the robot's radar to turn right by degrees when the next execution takes place.

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's radar is set to turn left instead of right.

Examples

// Set the radar to turn 180 degrees to the right
SetTurnRadarRight(180);

// Set the radar to turn 90 degrees to the right instead of right 
// (overrides the previous order)
SetTurnRadarRight(-90);

...
// Executes the last SetTurnRadarRight()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRadarRightRadians
Sets the robot's radar to turn right by radians when the next execution takes place.

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's radar is set to turn left instead of right.

Examples

// Set the radar to turn 180 degrees to the right
SetTurnRadarRightRadians(Math.PI);

// Set the radar to turn 90 degrees to the right instead of right 
// (overrides the previous order)
SetTurnRadarRightRadians(-Math.PI / 2);

...
// Executes the last SetTurnRadarRightRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRight
Sets the robot's body to turn right by degrees when the next execution takes place.

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's body is set to turn left instead of right.

Examples

// Set the robot to turn 180 degrees to the right
SetTurnRight(180);

// Set the robot to turn 90 degrees to the left instead of right 
// (overrides the previous order)
SetTurnRight(-90);

...
// Executes the last SetTurnRight()
Execute();
(Inherited from AdvancedRobot.)
Public methodSetTurnRightRadians
Sets the robot's body to turn right by radians when the next execution takes place.

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's body is set to turn left instead of right.

Examples

// Set the robot to turn 180 degrees to the right
SetTurnRightRadians(Math.PI);

// Set the robot to turn 90 degrees to the left instead of right 
// (overrides the previous order)
SetTurnRightRadians(-Math.PI / 2);

...
// Executes the last SetTurnRightRadians()
Execute();
(Inherited from AdvancedRobot.)
Public methodStop 
Immediately stops all movement, and saves it for a call to Resume . If there is already movement saved from a previous stop, this will have no effect.

This method is equivalent to Stop(false).
(Inherited from Robot.)
Public methodStop(Boolean)
Immediately stops all movement, and saves it for a call to Resume . If there is already movement saved from a previous stop, you can overwrite it by calling Stop(true).
(Inherited from Robot.)
Public methodTurnGunLeft
Immediately turns the robot's gun to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn right instead of left.

Examples

// Turn the robot's gun 180 degrees to the left
TurnGunLeft(180);

// Afterwards, turn the robot's gun 90 degrees to the right
TurnGunLeft(-90);
(Inherited from Robot.)
Public methodTurnGunLeftRadians
Immediately turns the robot's gun to the left by radians.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn right instead of left.

Examples

// Turn the robot's gun 180 degrees to the left
TurnGunLeftRadians(Math.PI);

// Afterwards, turn the robot's gun 90 degrees to the right
TurnGunLeftRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodTurnGunRight
Immediately turns the robot's gun to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn left instead of right.

Examples

// Turn the robot's gun 180 degrees to the right
TurnGunRight(180);

// Afterwards, turn the robot's gun 90 degrees to the left
TurnGunRight(-90);
(Inherited from Robot.)
Public methodTurnGunRightRadians
Immediately turns the robot's gun to the right by radians. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the gun's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's gun is set to turn left instead of right.

Examples

// Turn the robot's gun 180 degrees to the right
TurnGunRightRadians(Math.PI);

// Afterwards, turn the robot's gun 90 degrees to the left
TurnGunRightRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodTurnLeft
Immediately turns the robot's body to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn right instead of left.

Examples

// Turn the robot 180 degrees to the left
TurnLeft(180);

// Afterwards, turn the robot 90 degrees to the right
TurnLeft(-90);
(Inherited from Robot.)
Public methodTurnLeftRadians
Immediately turns the robot's body to the left by radians.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn right instead of left.

Examples

// Turn the robot 180 degrees to the left
TurnLeftRadians(Math.PI);

// Afterwards, turn the robot 90 degrees to the right
TurnLeftRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodTurnRadarLeft
Immediately turns the robot's radar to the left by degrees.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn right instead of left.

Examples

// Turn the robot's radar 180 degrees to the left
TurnRadarLeft(180);

// Afterwards, turn the robot's radar 90 degrees to the right
TurnRadarLeft(-90);
(Inherited from Robot.)
Public methodTurnRadarLeftRadians
Immediately turns the robot's radar to the left by radians.

This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn right instead of left.

Examples

// Turn the robot's radar 180 degrees to the left
TurnRadarLeftRadians(Math.PI);

// Afterwards, turn the robot's radar 90 degrees to the right
TurnRadarLeftRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodTurnRadarRight
Immediately turns the robot's radar to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn left instead of right.

Examples

// Turn the robot's radar 180 degrees to the right
TurnRadarRight(180);

// Afterwards, turn the robot's radar 90 degrees to the left
TurnRadarRight(-90);
(Inherited from Robot.)
Public methodTurnRadarRightRadians
Immediately turns the robot's radar to the right by radians. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the radar's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's radar is set to turn left instead of right.

Examples

// Turn the robot's radar 180 degrees to the right
TurnRadarRightRadians(Math.PI);

// Afterwards, turn the robot's radar 90 degrees to the left
TurnRadarRightRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodTurnRight
Immediately turns the robot's body to the right by degrees. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn left instead of right.

Examples

// Turn the robot 180 degrees to the right
TurnRight(180);

// Afterwards, turn the robot 90 degrees to the left
TurnRight(-90);
(Inherited from Robot.)
Public methodTurnRightRadians
Immediately turns the robot's body to the right by radians. This call executes immediately, and does not return until it is complete, i.e. when the angle remaining in the robot's turn is 0.

Note that both positive and negative values can be given as input, where negative values means that the robot's body is set to turn left instead of right.

Examples

// Turn the robot 180 degrees to the right
TurnRightRadians(Math.PI);

// Afterwards, turn the robot 90 degrees to the left
TurnRightRadians(-Math.PI / 2);
(Inherited from AdvancedRobot.)
Public methodWaitFor
Does not return until a condition is met, i.e. when a Test  returns true.

This call executes immediately.

See the Sample.Crazy robot for how this method can be used.
(Inherited from AdvancedRobot.)
Back to Top
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 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 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);
        }
    }
}
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 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 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