Interface IBot
Interface for a bot that extends the core API with convenient methods for movement, turning, and firing the gun.
Inherited Members
Namespace: Robocode.TankRoyale.BotApi
Assembly: api.dll
Syntax
[PublicAPI]
public interface IBot : IBaseBot
Properties
| Edit this page View SourceDistanceRemaining
The distance remaining till the bot has finished moving after having called SetForward(double), SetBack(double), Forward(double), or Back(double) When the distance remaining has reached 0, the bot has finished its current move.
When the distance remaining is positive, the bot is moving forward. When the distance remaining is negative, the bot is moving backward.
Declaration
double DistanceRemaining { get; }
Property Value
| Type | Description |
|---|---|
| double | The remaining distance to move before its current movement is completed. If PositiveInfinity the bot will move forward infinitely. If NegativeInfinity the bot will move backward infinitely. |
See Also
| Edit this page View SourceGunTurnRemaining
The remaining turn in degrees till the gun has finished turning after having called SetTurnGunLeft(double), SetTurnGunRight(double), TurnGunLeft(double), or TurnGunRight(double)". When the turn remaining has reached 0, the gun has finished turning.
When the turn remaining is positive, the bot is turning to the left (along the unit circle). When the turn remaining is negative, the bot is turning to the right.
Declaration
double GunTurnRemaining { get; }
Property Value
| Type | Description |
|---|---|
| double | The remaining degrees to turn the gun before its current turning is completed. If PositiveInfinity the gun will turn left infinitely. If NegativeInfinity the gun will turn right infinitely. |
See Also
| Edit this page View SourceIsRunning
Checks if this bot is running.
Declaration
bool IsRunning { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
RadarTurnRemaining
The remaining turn in degrees till the radar has finished turning after having called SetTurnRadarLeft(double), SetTurnRadarRight(double), TurnRadarLeft(double), or TurnRadarRight(double). When the turn remaining has reached 0, the radar has finished turning.
When the turn remaining is positive, the bot is turning to the left (along the unit circle). When the turn remaining is negative, the bot is turning to the right.
Declaration
double RadarTurnRemaining { get; }
Property Value
| Type | Description |
|---|---|
| double | The remaining degrees to turn the radar before its current turning is completed. If PositiveInfinity the radar will turn left infinitely. If NegativeInfinity the radar will turn right infinitely. |
See Also
| Edit this page View SourceTurnRemaining
The remaining turn in degrees till the bot has finished turning after having called SetTurnLeft(double), SetTurnRight(double), TurnLeft(double), or TurnRight(double). When the turn remaining has reached 0, the bot has finished turning.
When the turn remaining is positive, the bot is turning to the left (along the unit circle). When the turn remaining is negative, the bot is turning to the right.
Declaration
double TurnRemaining { get; }
Property Value
| Type | Description |
|---|---|
| double | The remaining degrees to turn before its current turning is completed. If PositiveInfinity the bot will turn left infinitely. If NegativeInfinity the bot will turn right infinitely. |
See Also
Methods
| Edit this page View SourceBack(double)
Moves the bot backward until it has traveled a specific distance from its current position, or it is moving into an obstacle. The speed is limited by MaxSpeed.
When the bot is moving forward, the Acceleration determines the acceleration of the bot that adds 1 additional unit to the speed per turn while accelerating. However, the bot is faster at braking. The Deceleration determines the deceleration of the bot that subtracts 2 units from the speed per turn.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to TargetSpeed, SetForward(double), and SetBack(double) methods.
Declaration
void Back(double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| double | distance | Is the distance to move backward. If negative, the bot will move forward. If PositiveInfinity the bot will move backward infinitely. If NegativeInfinity the bot will move forward infinitely. |
See Also
| Edit this page View SourceFire(double)
Fire the gun in the direction as the gun is pointing.
note
Your bot is spending energy when firing a bullet, the amount of energy used for firing the bullet is taken from the bot. The amount of energy loss is equal to the firepower.
If the bullet hits an opponent bot, you will gain energy from the bullet hit. When hitting another bot, your bot will be rewarded and retrieve an energy boost of 3x firepower.
The gun will only fire when the firepower is at MinFirepower or higher. If the firepower is more than MaxFirepower, the power will be truncated to the MaxFirepower.
Whenever the gun is fired, the gun is heated and needs to cool down before it can fire again. The gun heat must be zero before the gun can fire (see GunHeat. The gun heat generated by firing the gun is 1 + (firepower / 5). Hence, the more firepower used the longer it takes to cool down the gun. The gun cooling rate can be read from GunCoolingRate.
The amount of energy used for firing the gun is subtracted from the bot's total energy. The amount of damage dealt by a bullet hitting another bot is 4x firepower, and if the firepower is greater than 1 it will do an additional 2 x (firepower - 1) damage.
The firepower is truncated to MinFirepower and MaxFirepower if the firepower exceeds these values.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to setting SetFire(double).
Declaration
void Fire(double firepower)
Parameters
| Type | Name | Description |
|---|---|---|
| double | firepower | Is the amount of energy spent on firing the gun. You cannot spend more energy than available from the bot. The bullet power must be > MinFirepower. |
See Also
| Edit this page View SourceForward(double)
Moves the bot forward until it has traveled a specific distance from its current position, or it is moving into an obstacle. The speed is limited by MaxSpeed.
When the bot is moving forward, the Acceleration determine the acceleration of the bot that adds 1 additional unit to the speed per turn while accelerating. However, the bot is faster at braking. The Deceleration determines the deceleration of the bot that subtracts 2 units from the speed per turn.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to TargetSpeed, SetForward(double), and SetBack(double) methods.
Declaration
void Forward(double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| double | distance | Is the distance to move forward. If negative, the bot will move backward. If PositiveInfinity the bot will move forward infinitely. If NegativeInfinity the bot will move backward infinitely. |
See Also
| Edit this page View SourceRescan()
Scan (again) with the radar. This method is useful if the radar has not been turning and thereby will not be able to automatically scan bots. This method is useful when the bot movement has stopped, e.g. when Stop() has been called. The last radar direction and sweep angle will be used for rescanning for bots.
Declaration
void Rescan()
See Also
| Edit this page View SourceResume()
Resume the movement prior to calling the SetStop() or Stop() method. This method has no effect, if it has already been called.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
Declaration
void Resume()
See Also
| Edit this page View SourceRun()
The Run() method is used for running a program for the bot like:
public void Run()
{
while (IsRunning)
{
Forward(100);
TurnGunLeft(360);
Back(100);
TurnGunRight(360);
}
}
note
The program runs in a loop in this example (as long as the bot is running), meaning that it will start moving forward as soon as TurnGunRight(double) has executed.
When running a loop that could potentially run forever. The best practice is to check if the bot is still running to stop and exit the loop. This gives the game a chance of stopping the thread running the loop in the code behind. If the thread is not stopped correctly, the bot may behave strangely in new rounds.
Declaration
void Run()
See Also
| Edit this page View SourceSetBack(double)
Set the bot to move backward until it has traveled a specific distance from its current position, or it is moving into an obstacle. The speed is limited by MaxSpeed
When the bot is moving forward, the Acceleration determines the acceleration of the bot that adds 1 additional unit to the speed per turn while accelerating. However, the bot is faster at braking. The Deceleration determines the deceleration of the bot that subtracts 2 units from the speed per turn.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior setting TargetSpeed as the SetForward(double) and SetBack(double) methods sets the TargetSpeed for each turn until DistanceRemaining reaches 0.
Declaration
void SetBack(double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| double | distance | Is the distance to move backward. If negative, the bot will move forward. If PositiveInfinity the bot will move backward infinitely. If NegativeInfinity the bot will move forward infinitely. |
See Also
| Edit this page View SourceSetForward(double)
Set the bot to move forward until it has traveled a specific distance from its current position, or it is moving into an obstacle. The speed is limited by MaxSpeed.
When the bot is moving forward, the Acceleration determines the acceleration of the bot that adds 1 additional unit to the speed per turn while accelerating. However, the bot is faster at braking. The Deceleration determines the deceleration of the bot that subtracts 2 units from the speed per turn.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior setting TargetSpeed as the SetForward(double) and SetBack(double) methods sets the TargetSpeed for each turn until DistanceRemaining reaches 0.
Declaration
void SetForward(double distance)
Parameters
| Type | Name | Description |
|---|---|---|
| double | distance | Is the distance to move forward. If negative, the bot will move backward. If PositiveInfinity the bot will move forward infinitely. If NegativeInfinity the bot will move backward infinitely. |
See Also
| Edit this page View SourceSetTurnGunLeft(double)
Set the gun to turn to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when GunTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxGunTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnGunRight(double).
Declaration
void SetTurnGunLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the gun will turn right. If PositiveInfinity the gun will turn left infinitely. If NegativeInfinity the gun will turn right infinitely. |
See Also
| Edit this page View SourceSetTurnGunRight(double)
Set the gun to turn to the right (following the decreasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when GunTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxGunTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnGunLeft(double).
Declaration
void SetTurnGunRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the gun will turn left. If PositiveInfinity the gun will turn right infinitely. If NegativeInfinity the gun will turn left infinitely. |
See Also
| Edit this page View SourceSetTurnLeft(double)
Set the bot to turn to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when TurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnRight(double).
Declaration
void SetTurnLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the bot will turn right. If PositiveInfinity the bot will turn left infinitely. If NegativeInfinity the bot will turn right infinitely. |
See Also
| Edit this page View SourceSetTurnRadarLeft(double)
Set the radar to turn to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when RadarTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxRadarTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnRadarRight(double).
Declaration
void SetTurnRadarLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the radar will turn right. If PositiveInfinity the radar will turn left infinitely. If NegativeInfinity the radar will turn right infinitely. |
See Also
SetTurnRadarRight(double)
Turn the radar to the right (following the decreasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when RadarTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxRadarTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnRadarLeft(double) and SetTurnRadarRight(double).
Declaration
void SetTurnRadarRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the radar will turn left. If PositiveInfinity the radar will turn right infinitely. If NegativeInfinity the radar will turn left infinitely. |
See Also
SetTurnRight(double)
Set the bot to turn to the right (following the decreasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when TurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxTurnRate.
This method will first be executed when Go() is called making it possible to call other set methods before execution. This makes it possible to set the bot to move, turn the body, radar, gun, and also fire the gun in parallel in a single turn when calling Go(). But notice that this is only possible to execute multiple methods in parallel by using setter methods only prior to calling Go().
If this method is called multiple times, the last call before Go() is executed, counts.
This method will cancel the effect of prior calls to SetTurnLeft(double).
Declaration
void SetTurnRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the bot will turn left. If PositiveInfinity the bot will turn right infinitely. If NegativeInfinity the bot will turn left infinitely. |
See Also
| Edit this page View SourceStop()
Stop all movement including turning the gun and radar. The remaining movement is saved for a call to SetResume() or Resume(). This method has no effect, if it has already been called.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
Declaration
void Stop()
See Also
| Edit this page View SourceStop(bool)
Stop all movement including turning the gun and radar. The remaining movement is saved for a call to SetResume() or Resume().
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
Declaration
void Stop(bool overwrite)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | overwrite | overwrite is set to |
See Also
| Edit this page View SourceTurnGunLeft(double)
Turn the gun to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when GunTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxGunTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnGunLeft(double) and SetTurnGunRight(double)
Declaration
void TurnGunLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the gun will turn right. If PositiveInfinity the gun will turn left infinitely. If NegativeInfinity the gun will turn right infinitely. |
See Also
| Edit this page View SourceTurnGunRight(double)
Turn the gun to the right (following the decreasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when GunTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxGunTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnGunLeft(double) and SetTurnGunRight(double).
Declaration
void TurnGunRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the gun will turn left. If PositiveInfinity the gun will turn right infinitely. If NegativeInfinity the gun will turn left infinitely. |
See Also
| Edit this page View SourceTurnLeft(double)
Turn the bot to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when TurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnLeft(double) and SetTurnRight(double)
Declaration
void TurnLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the bot will turn right. If PositiveInfinity the bot will turn left infinitely. If NegativeInfinity the bot will turn right infinitely. |
See Also
| Edit this page View SourceTurnRadarLeft(double)
Turn the radar to the left (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when RadarTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxRadarTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnRadarLeft(double) and SetTurnRadarRight(double).
Declaration
void TurnRadarLeft(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn left. If negative, the radar will turn right. If PositiveInfinity the radar will turn left infinitely. If NegativeInfinity the radar will turn right infinitely. |
See Also
TurnRadarRight(double)
Turn the radar to the right (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when RadarTurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxRadarTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnRadarLeft(double) and SetTurnRadarRight(double).
Declaration
void TurnRadarRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the radar will turn left. If PositiveInfinity the radar will turn right infinitely. If NegativeInfinity the radar will turn left infinitely. |
See Also
TurnRight(double)
Turn the bot to the right (following the increasing degrees of the unit circle) until it turned the specified amount of degrees. That is, when TurnRemaining is 0. The amount of degrees to turn each turn is limited by MaxTurnRate.
This call is executed immediately by calling Go() in the code behind. This method will block until it has been completed, which can take one to several turns. New commands will first take place after this method is completed. If you need to execute multiple commands in parallel, use setter methods instead of this blocking method.
This method will cancel the effect of prior calls to SetTurnLeft(double) and SetTurnRight(double)
Declaration
void TurnRight(double degrees)
Parameters
| Type | Name | Description |
|---|---|---|
| double | degrees | Is the amount of degrees to turn right. If negative, the bot will turn left. If PositiveInfinity the bot will turn right infinitely. If NegativeInfinity the bot will turn left infinitely. |
See Also
| Edit this page View SourceWaitFor(Condition)
Blocks until a condition is met, i.e. when a Test() returns true.
Declaration
void WaitFor(Condition condition)
Parameters
| Type | Name | Description |
|---|---|---|
| Condition | condition |