Robocode NamespaceRobocode Robot API for .NET
 
Classes

  ClassDescription
Public classAdvancedRobot
A more advanced type of robot than Robot that allows non-blocking calls, custom events, and writes to the filesystem.

If you have not already, you should create a Robot first.
Onlinehttp://robocode.sourceforge.net
Online Building your first robot
Public classBattleEndedEvent
A BattleEndedEvent is sent to OnBattleEnded(BattleEndedEvent) when the battle is ended. You can use the information contained in this event to determine if the battle was aborted and also get the results of the battle.
Public classBattleResults
Contains the battle results returned by Results when a battle has ended.
Public classBattleRules
Contains the battle rules returned by BattleStartedEvent.BattleRules when a battle is started and BattleCompletedEvent.BattleRules when a battle is completed.
Public classBullet
Represents a bullet. This is returned from FireBullet(Double) and SetFireBullet(Double), and all the bullet-related events.
Public classBulletHitBulletEvent
This event is sent to OnBulletHitBullet(BulletHitBulletEvent) when one of your bullets has hit another bullet.
Public classBulletHitEvent
This event is sent to OnBulletHit(BulletHitEvent) when one of your bullets has hit another robot.
Public classBulletMissedEvent
This event is sent to OnBulletMissed(BulletMissedEvent) when one of your bullets has missed, i.e. when the bullet has reached the border of the battlefield.
Public classCondition
Condition is used to define custom WaitFor(Condition) and custom events for an AdvancedRobot. The code below is taken from the sample robot named samplecs.Target. See the samplecs/Target.cs for details.
Examples

AddCustomEvent(
    new Condition("triggerhit", (c) =>
    {
        return Energy <= trigger;
    }));
WaitFor(Condition)AddCustomEvent(Condition)RemoveCustomEvent(Condition)OnCustomEvent(CustomEvent)
Public classCustomEvent
This event is sent to OnCustomEvent(CustomEvent) when a custom condition is met. Be sure to reset or remove the custom condition to avoid having it recurring repeatedly (see the example for the Condition method.
Public classDeathEvent
This event is sent to OnDeath(DeathEvent) when your robot dies.
Public classEvent
The superclass of all Robocode events.
Public classGunTurnCompleteCondition
A prebuilt condition you can use that indicates your gun has finished turning.
Public classHitByBulletEvent
A HitByBulletEvent is sent to OnHitByBullet(HitByBulletEvent) when your robot has been hit by a bullet. You can use the information contained in this event to determine what to do.
Public classHitRobotEvent
A HitRobotEvent is sent to OnHitRobot(HitRobotEvent) when your robot collides with another robot. You can use the information contained in this event to determine what to do.
Public classHitWallEvent
A HitWallEvent is sent to OnHitWall(HitWallEvent) when you collide a wall. You can use the information contained in this event to determine what to do.
Public classJuniorRobot
This is the simplest robot type, which is simpler than the Robot and AdvancedRobot classes. The JuniorRobot has a simplified model, in purpose of teaching programming skills to inexperienced in programming students. The simplified robot model will keep player from overwhelming of Robocode's rules, programming syntax and programming concept.

Instead of using getters and setters, public fields are provided for receiving information like the last scanned robot, the coordinate of the robot etc.

All methods on this class are blocking calls, i.e. they do not return before their action has been completed and will at least take one turn to execute. However, setting colors is executed immediately and does not cost a turn to perform.
Public classKeyEvent
Super class of all events that originates from the keyboard.
Public classKeyPressedEvent
A KeyPressedEvent is sent to OnKeyPressed(KeyEvent) when a key has been pressed on the keyboard.
Public classKeyReleasedEvent
A KeyReleasedEvent is sent to OnKeyReleased(KeyEvent) when a key has been released on the keyboard.
Public classKeyTypedEvent
A KeyTypedEvent is sent to OnKeyTyped(KeyEvent) when a key has been typed (pressed and released) on the keyboard.
Public classMessageEvent
A MessageEvent is sent to OnMessageReceived(MessageEvent) when a teammate sends a message to your robot. You can use the information contained in this event to determine what to do.
Public classMouseClickedEvent
A MouseClickedEvent is sent to OnMouseClicked(MouseEvent) when the mouse is clicked inside the battle view.
Public classMouseDraggedEvent
A MouseDraggedEvent is sent to OnMouseDragged(MouseEvent) when the mouse is dragged inside the battle view.
Public classMouseEnteredEvent
A MouseEnteredEvent is sent to OnMouseEntered(MouseEvent) when the mouse has entered the battle view.
Public classMouseEvent
Super class of all events that originates from the mouse.
Public classMouseExitedEvent
A MouseExitedEvent is sent to OnMouseExited(MouseEvent) when the mouse has exited the battle view.
Public classMouseMovedEvent
A MouseMovedEvent is sent to OnMouseMoved(MouseEvent) when the mouse has moved inside the battle view.
Public classMousePressedEvent
A MousePressedEvent is sent to OnMousePressed(MouseEvent) when the mouse is pressed inside the battle view.
Public classMouseReleasedEvent
A MouseReleasedEvent is sent to OnMouseReleased(MouseEvent) when the mouse is released inside the battle view.
Public classMouseWheelMovedEvent
A MouseWheelMovedEvent is sent to OnMouseWheelMoved(MouseWheelMovedEvent) when the mouse wheel is rotated inside the battle view.
Public classMoveCompleteCondition
A prebuilt condition you can use that indicates your robot has finished moving.
Public classPaintEvent
This event occurs when your robot should paint, where the OnPaint(IGraphics) is called on your robot.

You can use this event for setting the event priority by calling SetEventPriority(String, Int32)
Public classRadarTurnCompleteCondition
A prebuilt condition you can use that indicates your radar has finished turning.
Public classRateControlRobot
This advanced robot type allows you to set a rate for each of the robot's movements.

You can set the rate for:
  • velocity - pixels per turn
  • robot turn - radians per turn
  • gun rotation - radians per turn
  • radar rotation - radians per turn
When you set a rate for one of the above movements, the movement will continue the move by specified rate for ever, until the rate is changed. In order to move ahead or right, the rate must be set to a positive value. If a negative value is used instead, the movement will go back or to the left. In order to stop the movement, the rate must be set to 0.

Note: When calling VelocityRate, TurnRate, GunRotationRate, RadarRotationRate and variants, any previous calls to "movement" functions outside of RateControlRobot, such as SetAhead(Double), SetTurnLeft(Double), SetTurnRadarRightRadians(Double) and similar will be overridden when calling the Execute  on this robot class.

Look into the source code for the samplecs.VelociRobot in order to see how to use this robot type.
Public classRobot
The basic robot class that you will extend to create your own robots.

Please note the following standards will be used:

heading - absolute angle in degrees with 0 facing up the screen, positive clockwise. 0 <= heading < 360.

bearing - relative angle to some obj from your robot's heading, positive clockwise. -180 < bearing <= 180

All coordinates are expressed as (x,y). All coordinates are positive.

The origin (0,0) is at the bottom left of the screen.

Positive X is right. Positive Y is up.
Onlinehttp://robocode.sourceforge.net
Online Building your first robot
Public classRobot DebugPropertyH
Container class for debug properties
Public classRobotDeathEvent
This event is sent to OnRobotDeath(RobotDeathEvent) when another robot (not your robot) dies.
Public classRobotStatus
Contains the status of a robot for a specific time/turn returned by Status.
Public classRoundEndedEvent
A RoundEndedEvent is sent to OnRoundEnded(RoundEndedEvent) when a round has ended. You can use the information contained in this event to determine which round that has ended.
Public classRules
Constants and methods that defines the rules of Robocode. Constants are used for rules that will not change. Methods are provided for rules that can be changed between battles or which depends on some other factor.
Public classScannedRobotEvent
A ScannedRobotEvent is sent to OnScannedRobot(ScannedRobotEvent) OnScannedRobot()} when you scan a robot. You can use the information contained in this event to determine what to do.

Note: You should not inherit from this class in your own event class! The internal logic of this event class might change. Hence, your robot might not work in future Robocode versions, if you choose to inherit from this class.
Public classSkippedTurnEvent
A SkippedTurnEvent is sent to OnSkippedTurn(SkippedTurnEvent) OnSkippedTurn()} when your robot is forced to skipping a turn. You must take an action every turn in order to participate in the game.
Examples

Thread.Sleep(1000);
will cause many SkippedTurnEvents, because you are not responding to the game. If you receive 30 SkippedTurnEvents, you will be removed from the round.

Instead, you should do something such as:
for (int i = 0; i < 30; i++)
{
    DoNothing(); // or perhaps Scan();
}

This event may also be generated if you are simply doing too much processing between actions, that is using too much processing power for the calculations etc. in your robot.
Public classStatusEvent
This event is sent to OnStatus(StatusEvent) every turn in a battle to provide the status of the robot.
Public classTeamRobot
An advanced type of robot that supports sending messages between team mates in a robot team.

If you have not done already, you should create a Robot or AdvancedRobot first.
Public classThread
Wrapper for .NET Thread, secured according to robocode rules.
Public classTurnCompleteCondition
A prebuilt condition you can use that indicates your robot has finished turning.
Public classWinEvent
This event is sent to OnWin(WinEvent) when your robot wins the round in a battle.
Interfaces

  InterfaceDescription
Public interfaceIBorderSentry
A robot that implement IBorderSentry is a robot type used for keeping other robots away from the borders, i.e. guarding the borders in order to prevent "wall crawlers".
Robots that implement IBorderSentry have 400 extra life/energy (500 in total), but is placed at the border of the battlefield when the game is started.
Border sentry robots cannot move away from the border area, and they can only make damage to robots that are moving into the border area. The size of the border area is determined by the battle rules.
This type of robot is intended for use in battles where robots should be forced away from the borders in order to prevent "wall crawlers".
Border sentry robots does not get scores, and will not occur in the battle results or rankings.
Public interfaceIDroid
Robots that implement IDroid have no scanner, but an extra 20 life/energy. This class is intended for use in teams.
Public interfaceIGraphics
Delegates

  DelegateDescription
Public delegateConditionTest
Method signature for Test method of Condition