JuniorRobot MethodsRobocode Robot API for .NET
The JuniorRobot type exposes the following members.
Methods

  NameDescription
Public methodAhead
Moves this robot forward by pixels.
Public methodBack
Moves this robot backward by pixels.
Public methodBearGunTo
Turns the gun to the specified angle (in degrees) relative to body of this robot. The gun will turn to the side with the shortest delta angle to the specified angle.
Public methodDoNothing 
Skips a turn.
Public methodDoNothing(Int32)
Skips the specified number of turns.
Public methodFire 
Fires a bullet with the default power of 1. If the gun heat is more than 0 and hence cannot Fire, this method will suspend until the gun is ready to Fire, and then Fire a bullet.
Public methodFire(Double)
Fires a bullet with the specified bullet power, which is between 0.1 and 3 where 3 is the maximum bullet power. If the gun heat is more than 0 and hence cannot Fire, this method will suspend until the gun is ready to Fire, and then Fire a bullet.
Public methodOnHitByBullet
This event method is called from the game when this robot has been hit by another robot's bullet. When this event occurs the HitByBulletAngle and HitByBulletBearing fields values are automatically updated.
Public methodOnHitRobot
This event method is called from the game when a bullet from this robot has hit another robot. When this event occurs the HitRobotAngle and HitRobotBearing fields values are automatically updated.
Public methodOnHitWall
This event method is called from the game when this robot has hit a wall. When this event occurs the HitWallAngle and HitWallBearing fields values are automatically updated.
Public methodOnScannedRobot
This event method is called from the game when the radar detects another robot. When this event occurs the ScannedDistance, ScannedAngle, ScannedBearing, and ScannedEnergy field values are automatically updated.
Public methodRun
The main method in every robot. You must override this to set up your robot's basic behavior.

Examples

// A basic robot that moves around in a square 
public void Run()
{
    Ahead(100);
    TurnRight(90);
}
This method is automatically re-called when it has returned.
Public methodSetColors(Int32, Int32, Int32)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
Public methodSetColors(Int32, Int32, Int32, Int32, Int32)
Sets the colors of the robot. The color values are RGB values. You can use the colors that are already defined for this class.
Public methodTurnAheadLeft
Moves this robot forward by pixels and turns this robot left by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time.

Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
Public methodTurnAheadRight
Moves this robot forward by pixels and turns this robot right by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time.

Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
Public methodTurnBackLeft
Moves this robot backward by pixels and turns this robot left by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time.

Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
Public methodTurnBackRight
Moves this robot backward by pixels and turns this robot right by degrees at the same time. The robot will move in a curve that follows a perfect circle, and the moving and turning will end at the same time.

Note that the max. velocity and max. turn rate is automatically adjusted, which means that the robot will move slower the sharper the turn is compared to the distance.
Public methodTurnGunLeft
Turns the gun left by degrees.
Public methodTurnGunRight
Turns the gun right by degrees.
Public methodTurnGunTo
Turns the gun to the specified angle (in degrees). The gun will turn to the side with the shortest delta angle to the specified angle.
Public methodTurnLeft
Turns this robot left by degrees.
Public methodTurnRight
Turns this robot right by degrees.
Public methodTurnTo
Turns this robot to the specified angle (in degrees). The robot will turn to the side with the shortest delta angle to the specified angle.
Back to Top
See Also