robocode.robotinterfaces
Interface IShip

All Superinterfaces:
IBackCannonFunctions, IBasicRobot, IFrontCannonFunctions, IRadarFunctions
All Known Implementing Classes:
Ship

public interface IShip
extends IBasicRobot, IFrontCannonFunctions, IBackCannonFunctions, IRadarFunctions

Since:
1.8.3 Alpha 1
Version:
0.1
Author:
Thales B.V. / Thomas Hakkers

Method Summary
 void execute()
          Executes any pending actions, or continues executing actions that are in process.
 double getBattleFieldHeight()
          Returns the height of the current battlefield measured in pixels.
 double getBattleFieldWidth()
          Returns the width of the current battlefield measured in pixels.
 double getBodyHeadingDegrees()
          Returns the heading of the Ship in Degrees.
 double getBodyHeadingRadians()
          Returns the heading of the Ship in Radians.
 double getBodyTurnRemainingDegrees()
          Deprecated to avoid confusion Returns the angle remaining in the robots's turn, in degrees.
 double getBodyTurnRemainingRadians()
          Returns the angle remaining in the robot's turn, in radians.
 double getComponentHeadingDegrees(int index)
          Returns the absolute heading of the component in degrees.
 double getComponentHeadingRadians(int index)
          Returns the absolute heading of the component in radians.
 double getDistanceRemaining()
          Returns the distance remaining in the robot's current move measured in pixels.
 double getEnergy()
          Returns the robot's current energy.
 double getGunHeatComponent(int index)
          Returns the gunHeat of the given component.
 long getTime()
          Returns the game time of the current round, where the time is equal to the current turn in the round.
 double getVelocity()
          Returns the velocity the Ship is going at in knots (pixels per second)
 double getX()
          Returns the X position of the robot. (0,0) is at the bottom left of the battlefield.
 double getXMiddle()
          Returns the X coordinate of the middle of the Ship.
 double getY()
          Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield.
 double getYMiddle()
          Returns the Y coordinate of the middle of the Ship.
 void scan()
           
 void setAdjustComponentForShipTurn(int index, boolean independent)
          Sets whether the component moves dependently from the Ship or not.
 void setAhead(double distance)
          Immediately moves your robot ahead (forward) by distance measured in pixels.
 void setBack(double distance)
          Moves your Ship back by the given number of pixels.
 void setBodyColor(Color color)
          Sets the color of the body of the ship
 void setCourseDegrees(double angle)
          Sets the course towards the specified heading.
 void setCourseRadians(double angle)
          Sets the course towards the specified heading.
 void setMaxKnots(double maxKnots)
          Sets the maximum amount of knots you want to travel per turn.
 void setTurnLeftDegrees(double angle)
          Attempts to turn your Ship by the given angle in degrees towards the left.
 void setTurnLeftRadians(double angle)
          Attempts to turn your Ship by the given angle in radians towards the left.
 void setTurnRightDegrees(double angle)
          Attempts to turn your Ship by the given angle in degrees towards the right.
 void setTurnRightRadians(double angle)
          Attempts to turn your Ship by the given angle in radians towards the right.
 
Methods inherited from interface robocode.robotinterfaces.IBasicRobot
getBasicEventListener, getRobotRunnable, setOut, setPeer
 
Methods inherited from interface robocode.naval.interfaces.IFrontCannonFunctions
fireFrontCannon, getCopyOfBlindSpotFrontCannon, getFrontCannonAtBlindSpot, getFrontCannonHeadingDegrees, getFrontCannonHeadingRadians, getFrontCannonTurnRemainingDegrees, getFrontCannonTurnRemainingRadians, getXFrontCannon, getYFrontCannon, setBulletColorFront, setFrontCannonColor, setTurnFrontCannonLeftDegrees, setTurnFrontCannonLeftRadians, setTurnFrontCannonRightDegrees, setTurnFrontCannonRightRadians
 
Methods inherited from interface robocode.naval.interfaces.IBackCannonFunctions
fireBackCannon, getBackCannonAtBlindSpot, getBackCannonHeadingDegrees, getBackCannonHeadingRadians, getBackCannonTurnRemainingDegrees, getBackCannonTurnRemainingRadians, getCopyOfBlindSpotBackCannon, getXBackCannon, getYBackCannon, setBackCannonColor, setBulletColorBack, setTurnBackCannonLeftDegrees, setTurnBackCannonLeftRadians, setTurnBackCannonRightDegrees, setTurnBackCannonRightRadians
 
Methods inherited from interface robocode.naval.interfaces.IRadarFunctions
getRadarHeadingDegrees, getRadarHeadingRadians, getRadarTurnRemainingDegrees, getRadarTurnRemainingRadians, getXRadar, getYRadar, setRadarColor, setScanColor, setTurnRadarLeftDegrees, setTurnRadarLeftRadians, setTurnRadarRightDegrees, setTurnRadarRightRadians
 

Method Detail

setCourseDegrees

void setCourseDegrees(double angle)
Sets the course towards the specified heading.

Parameters:
angle - The angle in degrees to which we want to set course. (0 = North, 90 = East, etc)

setCourseRadians

void setCourseRadians(double angle)
Sets the course towards the specified heading.

Parameters:
angle - The angle in radians to which we want to set course. (0 = North, PI/2 = East, etc)

setBodyColor

void setBodyColor(Color color)
Sets the color of the body of the ship

Parameters:
color - The color you wish your ship to be

setTurnLeftRadians

void setTurnLeftRadians(double angle)
Attempts to turn your Ship by the given angle in radians towards the left. Remember that Ships can't turn when they're not moving.

Parameters:
angle - The angle in radians we want to rotate to the left.

setTurnRightRadians

void setTurnRightRadians(double angle)
Attempts to turn your Ship by the given angle in radians towards the right. Remember that Ships can't turn when they're not moving.

Parameters:
angle - The angle in radians we want to rotate to the right.

setTurnLeftDegrees

void setTurnLeftDegrees(double angle)
Attempts to turn your Ship by the given angle in degrees towards the left. Remember that Ships can't turn when they're not moving.

Parameters:
angle - The angle in degrees we want to rotate to the left.

setTurnRightDegrees

void setTurnRightDegrees(double angle)
Attempts to turn your Ship by the given angle in degrees towards the right. Remember that Ships can't turn when they're not moving.

Parameters:
angle - The angle in degrees we want to rotate to the right.

setAdjustComponentForShipTurn

void setAdjustComponentForShipTurn(int index,
                                   boolean independent)
Sets whether the component moves dependently from the Ship or not. Can only be called if the turnRemaining on the component equals 0. THOMA_NOTE: Might change this in the future to work even if the turn remaining isn't 0.

Parameters:
index - The index of the component
independent - True for independent movement. False of dependent movement.

setMaxKnots

void setMaxKnots(double maxKnots)
Sets the maximum amount of knots you want to travel per turn.

Parameters:
knots - The amount of knots at which the ship has to travel.

scan

void scan()

getVelocity

double getVelocity()
Returns the velocity the Ship is going at in knots (pixels per second)

Returns:
the velocity the Ship is going at in knots (pixels per second)

setAhead

void setAhead(double distance)
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.

Example:

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

   // Afterwards, move the robot 50 pixels backward
   ahead(-50);
 

Parameters:
distance - the distance to move ahead measured in pixels. If this value is negative, the robot will move back instead of ahead.
See Also:
#back(double), #onHitWall(HitWallEvent), #onHitRobot(HitRobotEvent)

setBack

void setBack(double distance)
Moves your Ship back by the given number of pixels.

Parameters:
distance - The distance you want to move backwards in pixels.

getDistanceRemaining

double getDistanceRemaining()
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.

Returns:
the distance remaining in the robot's current move measured in pixels.

getBodyHeadingRadians

double getBodyHeadingRadians()
Returns the heading of the Ship in Radians. Return value is between 0 and 2*PI, where PI/2 would be equivalent to east.

Returns:
the heading of the Ship in Radians.

getBodyHeadingDegrees

double getBodyHeadingDegrees()
Returns the heading of the Ship in Degrees. Return value is between 0 and 360, where 90 degrees would be equivalent to east.

Returns:
the heading of the Ship in Degrees.

getGunHeatComponent

double getGunHeatComponent(int index)
Returns the gunHeat of the given component. Note: At the moment, you can even get the gunHeat of a Radar, but since it'll always return 0 anyway, I'm not too concerned by this.

Parameters:
index - The index of the component you want to know the gunHeat of.
Returns:
The gunheat of the given component.

getComponentHeadingDegrees

double getComponentHeadingDegrees(int index)
Returns the absolute heading of the component in degrees. Return value is between 0 and 360, where 90 degrees would be equivalent to east. The value is NOT relative to the ship; it's relative to the battlefield.

Parameters:
index - The index of the component you want to know the heading of.
Returns:
The heading of the component in degrees.

getComponentHeadingRadians

double getComponentHeadingRadians(int index)
Returns the absolute heading of the component in radians.

Parameters:
index - The index of the component you want to know the heading of.
Returns:
The heading of the component in radians.

getX

double getX()
Returns the X position of the robot. (0,0) is at the bottom left of the battlefield. NOTE: Returns the X value used by the system. Which is the X value of the pivot.

Returns:
the X position of the ship.
See Also:
getY(), getXMiddle()

getXMiddle

double getXMiddle()
Returns the X coordinate of the middle of the Ship. For the X coordinate of the pivot of the ship:

Returns:
X position of the middle of the ship.
See Also:
getX()

getY

double getY()
Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield. NOTE: Returns the Y value used by the system. Which is the Y value of the pivot.

Returns:
the Y position of the ship.
See Also:
getX(), getYMiddle()

getYMiddle

double getYMiddle()
Returns the Y coordinate of the middle of the Ship. For the Y coordinate of the pivot of the ship:

Returns:
Y position of the middle of the ship.
See Also:
getY()

getBattleFieldWidth

double getBattleFieldWidth()
Returns the width of the current battlefield measured in pixels.

Returns:
the width of the current battlefield measured in pixels.

getBattleFieldHeight

double getBattleFieldHeight()
Returns the height of the current battlefield measured in pixels.

Returns:
the height of the current battlefield measured in pixels.

getBodyTurnRemainingDegrees

double getBodyTurnRemainingDegrees()
Deprecated to avoid confusion 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.

Returns:
the angle remaining in the robots's turn, in degrees
See Also:
getTurnRemainingRadians(), getDistanceRemaining(), getGunTurnRemaining(), getGunTurnRemainingRadians(), getRadarTurnRemaining(), getRadarTurnRemainingRadians()

getBodyTurnRemainingRadians

double getBodyTurnRemainingRadians()
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.

Returns:
the angle remaining in the robot's turn, in radians

getTime

long getTime()
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.

Returns:
the game time/turn of the current round.

getEnergy

double getEnergy()
Returns the robot's current energy.

Returns:
the robot's current energy.

execute

void execute()
Executes any pending actions, or continues executing actions that are in process. This call returns after the actions have been started.

Note that ships must call this function in order to execute pending set* calls like e.g. setAhead(double), setTurnLeftDegrees(double) etc. Otherwise, these calls will never get executed.



Copyright © 2015 Robocode. All Rights Reserved.