Robocode Robot Downloads
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.
- Author:
- Mathew A. Nelson (original), Flemming N. Larsen (contributor), Robert D. Maupin (contributor), Pavel Savara (contributor)
- See Also:
- robocode.sourceforge.net, Building your first robot,
JuniorRobot
,Robot
,TeamRobot
,Droid
- The Pikachu robot is a Robocode robot that tracks an enemy robot’s energy level. If the energy level of the enemy drops, Pikachu assumes that the enemy fired a bullet and changes direction. Then Pikachu locates the enemy using its radar, aims its gun, and fires.
- Robocode is an open source educational game started by Mathew Nelson (originally provided by IBM).Currently contributions are being made by various people; officially Flemming N. Larsen is working on Robocode to keep it current and fix the bugs.The game is designed to help people learn to program in Java and enjoy the experience. It is very easy to start - a simple robot can be written in just.
Field Summary |
---|
SetBack public void setBack(double distance) 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 AdvancedRobot.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.
Fields inherited from class robocode._RobotBase |
---|
out |
Constructor Summary |
---|
AdvancedRobot() |
Method Summary | |
---|---|
void | addCustomEvent(Condition condition) Registers a custom event to be called when a condition is met. |
void | clearAllEvents() Clears out any pending events in the robot's event queue immediately. |
void | execute() Executes any pending actions, or continues executing actions that are in process. |
IAdvancedEvents | getAdvancedEventListener() Do not call this method! |
Vector | getAllEvents() Returns a vector containing all events currently in the robot's queue. |
Vector | getBulletHitBulletEvents() Returns a vector containing all BulletHitBulletEvents currently in the robot's queue. |
Vector | getBulletHitEvents() Returns a vector containing all BulletHitEvents currently in the robot's queue. |
Vector | getBulletMissedEvents() Returns a vector containing all BulletMissedEvents currently in the robot's queue. |
File | getDataDirectory() Returns a file representing a data directory for the robot, which can be written to using RobocodeFileOutputStream or RobocodeFileWriter . |
File | getDataFile(String filename) Returns a file in your data directory that you can write to using RobocodeFileOutputStream or RobocodeFileWriter . |
long | getDataQuotaAvailable() Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot. |
double | getDistanceRemaining() Returns the distance remaining in the robot's current move measured in pixels. |
int | getEventPriority(String eventClass) Returns the current priority of a class of events. |
double | getGunHeadingRadians() Returns the direction that the robot's gun is facing, in radians. |
double | getGunTurnRemaining() Returns the angle remaining in the gun's turn, in degrees. |
double | getGunTurnRemainingRadians() Returns the angle remaining in the gun's turn, in radians. |
double | getHeadingRadians() Returns the direction that the robot's body is facing, in radians. |
Vector | getHitByBulletEvents() Returns a vector containing all HitByBulletEvents currently in the robot's queue. |
Vector | getHitRobotEvents() Returns a vector containing all HitRobotEvents currently in the robot's queue. |
Vector | getHitWallEvents() Returns a vector containing all HitWallEvents currently in the robot's queue. |
double | getRadarHeadingRadians() Returns the direction that the robot's radar is facing, in radians. |
double | getRadarTurnRemaining() Returns the angle remaining in the radar's turn, in degrees. |
double | getRadarTurnRemainingRadians() Returns the angle remaining in the radar's turn, in radians. |
Vector | getRobotDeathEvents() Returns a vector containing all RobotDeathEvents currently in the robot's queue. |
Vector | getScannedRobotEvents() Returns a vector containing all ScannedRobotEvents currently in the robot's queue. |
Vector | getStatusEvents() Returns a vector containing all StatusEvents currently in the robot's queue. |
double | getTurnRemaining() Returns the angle remaining in the robots's turn, in degrees. |
double | getTurnRemainingRadians() Returns the angle remaining in the robot's turn, in radians. |
boolean | isAdjustGunForRobotTurn() Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. |
boolean | isAdjustRadarForGunTurn() Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn. |
boolean | isAdjustRadarForRobotTurn() Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. |
void | onCustomEvent(CustomEvent event) This method is called when a custom condition is met. |
void | onDeath(DeathEvent event) This method is called if your robot dies. |
void | onSkippedTurn(SkippedTurnEvent event) This method is called if the robot is using too much time between actions. |
void | removeCustomEvent(Condition condition) Removes a custom event that was previously added by calling AdvancedRobot.addCustomEvent(Condition) . |
void | setAhead(double distance) Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place. |
void | setBack(double distance) Sets the robot to move back by distance measured in pixels when the next execution takes place. |
void | setEventPriority(String eventClass, int priority) Sets the priority of a class of events. |
void | setFire(double power) Sets the gun to fire a bullet when the next execution takes place. |
Bullet | setFireBullet(double power) Sets the gun to fire a bullet when the next execution takes place. |
void | setInterruptible(boolean interruptible) Call this during an event handler to allow new events of the same priority to restart the event handler. |
void | setMaxTurnRate(double newMaxTurnRate) Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than Rules.MAX_TURN_RATE (10 degress/turn). |
void | setMaxVelocity(double newMaxVelocity) Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than Rules.MAX_VELOCITY (8 pixels/turn). |
void | setResume() Sets the robot to resume the movement stopped by stop() or AdvancedRobot.setStop() , if any. |
void | setStop() This call is identical to stop() , but returns immediately, and will not execute until you call AdvancedRobot.execute() or take an action that executes. |
void | setStop(boolean overwrite) This call is identical to stop(boolean) , but returns immediately, and will not execute until you call AdvancedRobot.execute() or take an action that executes. |
void | setTurnGunLeft(double degrees) Sets the robot's gun to turn left by degrees when the next execution takes place. |
void | setTurnGunLeftRadians(double radians) Sets the robot's gun to turn left by radians when the next execution takes place. |
void | setTurnGunRight(double degrees) Sets the robot's gun to turn right by degrees when the next execution takes place. |
void | setTurnGunRightRadians(double radians) Sets the robot's gun to turn right by radians when the next execution takes place. |
void | setTurnLeft(double degrees) Sets the robot's body to turn left by degrees when the next execution takes place. |
void | setTurnLeftRadians(double radians) Sets the robot's body to turn left by radians when the next execution takes place. |
void | setTurnRadarLeft(double degrees) Sets the robot's radar to turn left by degrees when the next execution takes place. |
void | setTurnRadarLeftRadians(double radians) Sets the robot's radar to turn left by radians when the next execution takes place. |
void | setTurnRadarRight(double degrees) Sets the robot's radar to turn right by degrees when the next execution takes place. |
void | setTurnRadarRightRadians(double radians) Sets the robot's radar to turn right by radians when the next execution takes place. |
void | setTurnRight(double degrees) Sets the robot's body to turn right by degrees when the next execution takes place. |
void | setTurnRightRadians(double radians) Sets the robot's body to turn right by radians when the next execution takes place. |
void | turnGunLeftRadians(double radians) Immediately turns the robot's gun to the left by radians. |
void | turnGunRightRadians(double radians) Immediately turns the robot's gun to the right by radians. |
void | turnLeftRadians(double radians) Immediately turns the robot's body to the left by radians. |
void | turnRadarLeftRadians(double radians) Immediately turns the robot's radar to the left by radians. |
void | turnRadarRightRadians(double radians) Immediately turns the robot's radar to the right by radians. |
void | turnRightRadians(double radians) Immediately turns the robot's body to the right by radians. |
void | waitFor(Condition condition) Does not return until a condition is met, i.e. when a Condition.test() returns true . |
Methods inherited from class robocode._AdvancedRobot |
---|
endTurn, getGunHeadingDegrees, getHeadingDegrees, getMaxWaitCount, getRadarHeadingDegrees, getWaitCount, setTurnGunLeftDegrees, setTurnGunRightDegrees, setTurnLeftDegrees, setTurnRadarLeftDegrees, setTurnRadarRightDegrees, setTurnRightDegrees, turnGunLeftDegrees, turnGunRightDegrees, turnLeftDegrees, turnRadarLeftDegrees, turnRadarRightDegrees, turnRightDegrees |
Methods inherited from class robocode.Robot |
---|
ahead, back, doNothing, finalize, fire, fireBullet, getBasicEventListener, getBattleFieldHeight, getBattleFieldWidth, getEnergy, getGraphics, getGunCoolingRate, getGunHeading, getGunHeat, getHeading, getHeight, getInteractiveEventListener, getName, getNumRounds, getOthers, getPaintEventListener, getRadarHeading, getRobotRunnable, getRoundNum, getTime, getVelocity, getWidth, getX, getY, onBattleEnded, onBulletHit, onBulletHitBullet, onBulletMissed, onHitByBullet, onHitRobot, onHitWall, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragged, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelMoved, onPaint, onRobotDeath, onScannedRobot, onStatus, onWin, resume, run, scan, setAdjustGunForRobotTurn, setAdjustRadarForGunTurn, setAdjustRadarForRobotTurn, setAllColors, setBodyColor, setBulletColor, setColors, setColors, setDebugProperty, setGunColor, setRadarColor, setScanColor, stop, stop, turnGunLeft, turnGunRight, turnLeft, turnRadarLeft, turnRadarRight, turnRight |
Methods inherited from class robocode._Robot |
---|
getBattleNum, getGunCharge, getGunImageName, getLife, getNumBattles, getRadarImageName, getRobotImageName, setGunImageName, setRadarImageName, setRobotImageName |
Methods inherited from class robocode._RobotBase |
---|
setOut, setPeer |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface robocode.robotinterfaces.IBasicRobot |
---|
getBasicEventListener, getRobotRunnable, setOut, setPeer |
Constructor Detail |
---|
AdvancedRobot
Method Detail |
---|
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.
- See Also:
getTurnRemaining()
,getTurnRemainingRadians()
,getGunTurnRemaining()
,getGunTurnRemainingRadians()
,getRadarTurnRemaining()
,getRadarTurnRemainingRadians()
getTurnRemaining
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()
getGunTurnRemaining
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.
- Returns:
- the angle remaining in the gun's turn, in degrees
- See Also:
getGunTurnRemainingRadians()
,getDistanceRemaining()
,getTurnRemaining()
,getTurnRemainingRadians()
,getRadarTurnRemaining()
,getRadarTurnRemainingRadians()
getRadarTurnRemaining
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.
- Returns:
- the angle remaining in the radar's turn, in degrees
- See Also:
getRadarTurnRemainingRadians()
,getDistanceRemaining()
,getGunTurnRemaining()
,getGunTurnRemainingRadians()
,getRadarTurnRemaining()
,getRadarTurnRemainingRadians()
setAhead
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 AdvancedRobot.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.
Example:
- Parameters:
distance
- the distance to move measured in pixels. Ifdistance
> 0 the robot is set to move ahead. Ifdistance
< 0 the robot is set to move back. Ifdistance
= 0 the robot is set to stop its movement.- See Also:
ahead(double)
,back(double)
,AdvancedRobot.setBack(double)
setBack
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 AdvancedRobot.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.
Example:
- Parameters:
distance
- the distance to move measured in pixels. Ifdistance
> 0 the robot is set to move back. Ifdistance
< 0 the robot is set to move ahead. Ifdistance
= 0 the robot is set to stop its movement.- See Also:
back(double)
,ahead(double)
,AdvancedRobot.setAhead(double)
setTurnLeft
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's body to the left. Ifdegrees
> 0 the robot is set to turn left. Ifdegrees
< 0 the robot is set to turn right. Ifdegrees
= 0 the robot is set to stop turning.- See Also:
setTurnLeftRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,turnRight(double)
,turnRightRadians(double)
,setTurnRight(double)
,setTurnRightRadians(double)
setTurnRight
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's body to the right. Ifdegrees
> 0 the robot is set to turn right. Ifdegrees
< 0 the robot is set to turn left. Ifdegrees
= 0 the robot is set to stop turning.- See Also:
setTurnRightRadians(double)
,turnRight(double)
,turnRightRadians(double)
,turnLeft(double)
,turnLeftRadians(double)
,setTurnLeft(double)
,setTurnLeftRadians(double)
setFire
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 Rules.MIN_BULLET_POWER
and Rules.MAX_BULLET_POWER
.
Note that the gun cannot fire if the gun is overheated, meaning that Robot.getGunHeat()
returns a value > 0.
An event is generated when the bullet hits a robot, wall, or another bullet.
Example:
- Parameters:
power
- the amount of energy given to the bullet, and subtracted from the robot's energy.- See Also:
AdvancedRobot.setFireBullet(double)
,fire(double)
,fireBullet(double)
,getGunHeat()
,getGunCoolingRate()
,onBulletHit(BulletHitEvent)
,onBulletHitBullet(BulletHitBulletEvent)
,onBulletMissed(BulletMissedEvent)
setFireBullet
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 Rules.MIN_BULLET_POWER
and Rules.MAX_BULLET_POWER
.
Note that the gun cannot fire if the gun is overheated, meaning that Robot.getGunHeat()
returns a value > 0.
A event is generated when the bullet hits a robot (BulletHitEvent
), wall (BulletMissedEvent
), or another bullet (BulletHitBulletEvent
).
Example:
- Parameters:
power
- the amount of energy given to the bullet, and subtracted from the robot's energy.- 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. - See Also:
AdvancedRobot.setFire(double)
,Bullet
,fire(double)
,fireBullet(double)
,getGunHeat()
,getGunCoolingRate()
,onBulletHit(BulletHitEvent)
,onBulletHitBullet(BulletHitBulletEvent)
,onBulletMissed(BulletMissedEvent)
addCustomEvent
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 callAdvancedRobot.removeCustomEvent(Condition)
. Example:
- Parameters:
condition
- the condition that must be met.- Throws:
NullPointerException
- if the condition parameter has been set tonull
.- See Also:
Condition
,AdvancedRobot.removeCustomEvent(Condition)
removeCustomEvent
Removes a custom event that was previously added by callingAdvancedRobot.addCustomEvent(Condition)
. Example:
- Parameters:
condition
- the condition that was previous added and that must be removed now.- Throws:
NullPointerException
- if the condition parameter has been set tonull
.- See Also:
Condition
,AdvancedRobot.addCustomEvent(Condition)
clearAllEvents
- Clears out any pending events in the robot's event queue immediately.
- See Also:
AdvancedRobot.getAllEvents()
execute
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. AdvancedRobot.setAhead(double)
, AdvancedRobot.setFire(double)
, AdvancedRobot.setTurnLeft(double)
etc. Otherwise, these calls will never get executed.
In this example the robot will move while turning:
getAllEvents
Returns a vector containing all events currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all events currently in the robot's queue
- See Also:
Event
,AdvancedRobot.clearAllEvents()
,AdvancedRobot.getStatusEvents()
,AdvancedRobot.getScannedRobotEvents()
,AdvancedRobot.getBulletHitEvents()
,AdvancedRobot.getBulletMissedEvents()
,AdvancedRobot.getBulletHitBulletEvents()
,AdvancedRobot.getRobotDeathEvents()
getBulletHitBulletEvents
Returns a vector containing all BulletHitBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all BulletHitBulletEvents currently in the robot's queue
- See Also:
onBulletHitBullet(BulletHitBulletEvent)
,BulletHitBulletEvent
,AdvancedRobot.getAllEvents()
getBulletHitEvents
Returns a vector containing all BulletHitEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all BulletHitEvents currently in the robot's queue
- See Also:
onBulletHit(BulletHitEvent)
,BulletHitEvent
,AdvancedRobot.getAllEvents()
getBulletMissedEvents
Returns a vector containing all BulletMissedEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all BulletMissedEvents currently in the robot's queue
- See Also:
onBulletMissed(BulletMissedEvent)
,BulletMissedEvent
,AdvancedRobot.getAllEvents()
getDataDirectory
Returns a file representing a data directory for the robot, which can be written to usingRobocodeFileOutputStream
or RobocodeFileWriter
. The system will automatically create the directory for you, so you do not need to create it by yourself.
- Returns:
- a file representing the data directory for your robot
- See Also:
AdvancedRobot.getDataFile(String)
,RobocodeFileOutputStream
,RobocodeFileWriter
getDataFile
Returns a file in your data directory that you can write to usingRobocodeFileOutputStream
or RobocodeFileWriter
. 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 (~195 KB).
See the sample.SittingDuck
to see an example of how to use this method.
- Parameters:
filename
- the file name of the data file for your robot- Returns:
- a file representing the data file for your robot
- See Also:
AdvancedRobot.getDataDirectory()
,RobocodeFileOutputStream
,RobocodeFileWriter
getDataQuotaAvailable
- Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.
- Returns:
- the amount of bytes left in the robot's data directory
- See Also:
AdvancedRobot.getDataDirectory()
,AdvancedRobot.getDataFile(String)
getEventPriority
Returns the current priority of a class of events. An event priority is a value from 0 - 99. The higher value, the higher priority.Example:
The default priorities are, from highest to lowest:
- Parameters:
eventClass
- the name of the event class (string)- Returns:
- the current priority of a class of events
- See Also:
AdvancedRobot.setEventPriority(String, int)
getHitByBulletEvents
Returns a vector containing all HitByBulletEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all HitByBulletEvents currently in the robot's queue
- See Also:
onHitByBullet(HitByBulletEvent)
,HitByBulletEvent
,AdvancedRobot.getAllEvents()
getHitRobotEvents
Returns a vector containing all HitRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all HitRobotEvents currently in the robot's queue
- See Also:
onHitRobot(HitRobotEvent)
,HitRobotEvent
,AdvancedRobot.getAllEvents()
getHitWallEvents
Returns a vector containing all HitWallEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all HitWallEvents currently in the robot's queue
- See Also:
onHitWall(HitWallEvent)
,HitWallEvent
,AdvancedRobot.getAllEvents()
getRobotDeathEvents
Returns a vector containing all RobotDeathEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all RobotDeathEvents currently in the robot's queue
- See Also:
onRobotDeath(RobotDeathEvent)
,RobotDeathEvent
,AdvancedRobot.getAllEvents()
getScannedRobotEvents
Returns a vector containing all ScannedRobotEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all ScannedRobotEvents currently in the robot's queue
- See Also:
onScannedRobot(ScannedRobotEvent)
,ScannedRobotEvent
,AdvancedRobot.getAllEvents()
getStatusEvents
Returns a vector containing all StatusEvents currently in the robot's queue. You might, for example, call this while processing another event.Example:
- Returns:
- a vector containing all StatusEvents currently in the robot's queue
- Since:
- 1.6.1
- See Also:
onStatus(StatusEvent)
,StatusEvent
,AdvancedRobot.getAllEvents()
isAdjustGunForRobotTurn
Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. This call returns true
if the gun is set to turn independent of the turn of the robot's body. Otherwise, false
is returned, meaning that the gun is set to turn with the robot's body turn.
- Returns:
true
if the gun is set to turn independent of the robot turning;false
if the gun is set to turn with the robot turning- See Also:
setAdjustGunForRobotTurn(boolean)
,AdvancedRobot.isAdjustRadarForRobotTurn()
,AdvancedRobot.isAdjustRadarForGunTurn()
isAdjustRadarForRobotTurn
Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn. This call returns true
if the radar is set to turn independent of the turn of the robot. Otherwise, false
is returned, meaning that the radar is set to turn with the robot's turn.
- Returns:
true
if the radar is set to turn independent of the robot turning;false
if the radar is set to turn with the robot turning- See Also:
setAdjustRadarForRobotTurn(boolean)
,AdvancedRobot.isAdjustGunForRobotTurn()
,AdvancedRobot.isAdjustRadarForGunTurn()
isAdjustRadarForGunTurn
Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn. This call returns true
if the radar is set to turn independent of the turn of the gun. Otherwise, false
is returned, meaning that the radar is set to turn with the gun's turn.
- Returns:
true
if the radar is set to turn independent of the gun turning;false
if the radar is set to turn with the gun turning- See Also:
setAdjustRadarForGunTurn(boolean)
,AdvancedRobot.isAdjustGunForRobotTurn()
,AdvancedRobot.isAdjustRadarForRobotTurn()
onCustomEvent
This method is called when a custom condition is met. See the sample robots for examples of use, e.g. the sample.Target
robot.
- Specified by:
onCustomEvent
in interfaceIAdvancedEvents
- Parameters:
event
- the custom event that occurred- See Also:
AdvancedRobot.addCustomEvent(robocode.Condition)
,CustomEvent
,Event
setEventPriority
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.
Example:
The default priorities are, from highest to lowest:
Note that you cannot change the priority for events with the special priority value -1 or 100 (reserved) as these event 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).
- Parameters:
eventClass
- the name of the event class (string) to set the priority forpriority
- the new priority for that event class- Since:
- 1.5, the priority of DeathEvent was changed from 100 to -1 in order to let robots process pending events on its event queue before it dies. When the robot dies, it will not be able to process events.
- See Also:
AdvancedRobot.getEventPriority(String)
,AdvancedRobot.setInterruptible(boolean)
setInterruptible
Call this during an event handler to allow new events of the same priority to restart the event handler.Example:
- Overrides:
setInterruptible
in class_Robot
- Parameters:
interruptible
-true
if the event handler should be interrupted if new events of the same priority occurs;false
otherwise- See Also:
AdvancedRobot.setEventPriority(String, int)
,onScannedRobot(ScannedRobotEvent)
setMaxTurnRate
- Sets the maximum turn rate of the robot measured in degrees if the robot should turn slower than
Rules.MAX_TURN_RATE
(10 degress/turn). - Parameters:
newMaxTurnRate
- the new maximum turn rate of the robot measured in degrees. Valid values are 0 -Rules.MAX_TURN_RATE
- See Also:
turnRight(double)
,turnLeft(double)
,AdvancedRobot.setTurnRight(double)
,AdvancedRobot.setTurnLeft(double)
,AdvancedRobot.setMaxVelocity(double)
setMaxVelocity
- Sets the maximum velocity of the robot measured in pixels/turn if the robot should move slower than
Rules.MAX_VELOCITY
(8 pixels/turn). - Parameters:
newMaxVelocity
- the new maximum turn rate of the robot measured in pixels/turn. Valid values are 0 -Rules.MAX_VELOCITY
- See Also:
Robot.ahead(double)
,AdvancedRobot.setAhead(double)
,Robot.back(double)
,AdvancedRobot.setBack(double)
,AdvancedRobot.setMaxTurnRate(double)
setResume
Sets the robot to resume the movement stopped bystop()
or AdvancedRobot.setStop()
, if any. This call returns immediately, and will not execute until you call AdvancedRobot.execute()
or take an action that executes.
- See Also:
resume()
,stop()
,stop(boolean)
,AdvancedRobot.setStop()
,AdvancedRobot.setStop(boolean)
,AdvancedRobot.execute()
setStop
This call is identical tostop()
, but returns immediately, and will not execute until you call AdvancedRobot.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)
;
- See Also:
stop()
,stop(boolean)
,resume()
,AdvancedRobot.setResume()
,AdvancedRobot.setStop(boolean)
,AdvancedRobot.execute()
setStop
This call is identical tostop(boolean)
, but returns immediately, and will not execute until you call AdvancedRobot.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)
.
- Parameters:
overwrite
-true
if the movement saved from a previous stop should be overwritten;false
otherwise.- See Also:
stop()
,stop(boolean)
,resume()
,AdvancedRobot.setResume()
,AdvancedRobot.setStop()
,AdvancedRobot.execute()
setTurnGunLeft
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's gun to the left. Ifdegrees
> 0 the robot's gun is set to turn left. Ifdegrees
< 0 the robot's gun is set to turn right. Ifdegrees
= 0 the robot's gun is set to stop turning.- See Also:
setTurnGunLeftRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,setTurnGunRight(double)
,setTurnGunRightRadians(double)
,setAdjustGunForRobotTurn(boolean)
setTurnGunRight
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's gun to the right. Ifdegrees
> 0 the robot's gun is set to turn right. Ifdegrees
< 0 the robot's gun is set to turn left. Ifdegrees
= 0 the robot's gun is set to stop turning.- See Also:
setTurnGunRightRadians(double)
,turnGunRight(double)
,turnGunRightRadians(double)
,turnGunLeft(double)
,turnGunLeftRadians(double)
,setTurnGunLeft(double)
,setTurnGunLeftRadians(double)
,setAdjustGunForRobotTurn(boolean)
setTurnRadarLeft
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's radar to the left. Ifdegrees
> 0 the robot's radar is set to turn left. Ifdegrees
< 0 the robot's radar is set to turn right. Ifdegrees
= 0 the robot's radar is set to stop turning.- See Also:
setTurnRadarLeftRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,setTurnRadarRight(double)
,setTurnRadarRightRadians(double)
,setAdjustRadarForRobotTurn(boolean)
,setAdjustRadarForGunTurn(boolean)
setTurnRadarRight
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.
Example:
- Parameters:
degrees
- the amount of degrees to turn the robot's radar to the right. Ifdegrees
> 0 the robot's radar is set to turn right. Ifdegrees
< 0 the robot's radar is set to turn left. Ifdegrees
= 0 the robot's radar is set to stop turning.- See Also:
setTurnRadarRightRadians(double)
,turnRadarRight(double)
,turnRadarRightRadians(double)
,turnRadarLeft(double)
,turnRadarLeftRadians(double)
,setTurnRadarLeft(double)
,setTurnRadarLeftRadians(double)
,setAdjustRadarForRobotTurn(boolean)
,setAdjustRadarForGunTurn(boolean)
waitFor
Does not return until a condition is met, i.e. when aCondition.test()
returns true
. This call executes immediately.
See the sample.Crazy
robot for how this method can be used.
- Parameters:
condition
- the condition that must be met before this call returns- See Also:
Condition
,Condition.test()
onDeath
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.
- Specified by:
onDeath
in interfaceIBasicEvents
- Overrides:
onDeath
in classRobot
- Parameters:
event
- the death event set by the game- See Also:
DeathEvent
,Event
onSkippedTurn
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.
- Specified by:
onSkippedTurn
in interfaceIAdvancedEvents
- Parameters:
event
- the skipped turn event set by the game- See Also:
SkippedTurnEvent
,Event
getHeadingRadians
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 / 4 means West.
- Overrides:
getHeadingRadians
in class_AdvancedRadiansRobot
- Returns:
- the direction that the robot's body is facing, in radians.
- See Also:
_AdvancedRobot.getHeadingDegrees()
,AdvancedRobot.getGunHeadingRadians()
,AdvancedRobot.getRadarHeadingRadians()
setTurnLeftRadians
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.
Example:
- Overrides:
setTurnLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the left. Ifradians
> 0 the robot is set to turn left. Ifradians
< 0 the robot is set to turn right. Ifradians
= 0 the robot is set to stop turning.- See Also:
setTurnLeft(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,setTurnRight(double)
,setTurnRightRadians(double)
setTurnRightRadians
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.
Robocode Robot Downloads Pc
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.
Example:
- Overrides:
setTurnRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the right. Ifradians
> 0 the robot is set to turn right. Ifradians
< 0 the robot is set to turn left. Ifradians
= 0 the robot is set to stop turning.- See Also:
setTurnRight(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,setTurnLeft(double)
,setTurnLeftRadians(double)
turnLeftRadians
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.
Example:
- Overrides:
turnLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the left. Ifradians
> 0 the robot will turn right. Ifradians
< 0 the robot will turn left. Ifradians
= 0 the robot will not turn, but execute.- See Also:
Robot.turnLeft(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
turnRightRadians
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.
Example:
- Overrides:
turnRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's body to the right. Ifradians
> 0 the robot will turn right. Ifradians
< 0 the robot will turn left. Ifradians
= 0 the robot will not turn, but execute.- See Also:
Robot.turnRight(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
getGunHeadingRadians
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 / 4 means West.
- Overrides:
getGunHeadingRadians
in class_AdvancedRadiansRobot
- Returns:
- the direction that the robot's gun is facing, in radians.
- See Also:
_AdvancedRobot.getGunHeadingDegrees()
,AdvancedRobot.getHeadingRadians()
,AdvancedRobot.getRadarHeadingRadians()
getRadarHeadingRadians
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 / 4 means West.
- Overrides:
getRadarHeadingRadians
in class_AdvancedRadiansRobot
- Returns:
- the direction that the robot's radar is facing, in radians.
- See Also:
_AdvancedRobot.getRadarHeadingDegrees()
,AdvancedRobot.getHeadingRadians()
,AdvancedRobot.getGunHeadingRadians()
setTurnGunLeftRadians
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.
Example:
- Overrides:
setTurnGunLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the left. Ifradians
> 0 the robot's gun is set to turn left. Ifradians
< 0 the robot's gun is set to turn right. Ifradians
= 0 the robot's gun is set to stop turning.- See Also:
setTurnGunLeft(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,setTurnGunRight(double)
,setTurnGunRightRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
setTurnGunRightRadians
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.
Example:
- Overrides:
setTurnGunRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the right. Ifradians
> 0 the robot's gun is set to turn left. Ifradians
< 0 the robot's gun is set to turn right. Ifradians
= 0 the robot's gun is set to stop turning.- See Also:
setTurnGunRight(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,setTurnGunLeft(double)
,setTurnGunLeftRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
setTurnRadarLeftRadians
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.
Example:
- Overrides:
setTurnRadarLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the left. Ifradians
> 0 the robot's radar is set to turn left. Ifradians
< 0 the robot's radar is set to turn right. Ifradians
= 0 the robot's radar is set to stop turning.- See Also:
setTurnRadarLeft(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,setTurnRadarRight(double)
,setTurnRadarRightRadians(double)
,Robot.setAdjustRadarForRobotTurn(boolean)
,Robot.setAdjustRadarForGunTurn(boolean)
setTurnRadarRightRadians
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.
Example:
- Overrides:
setTurnRadarRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the right. Ifradians
> 0 the robot's radar is set to turn left. Ifradians
< 0 the robot's radar is set to turn right. Ifradians
= 0 the robot's radar is set to stop turning.- See Also:
setTurnRadarRight(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,setTurnRadarLeft(double)
,setTurnRadarLeftRadians(double)
,Robot.setAdjustRadarForRobotTurn(boolean)
,Robot.setAdjustRadarForGunTurn(boolean)
turnGunLeftRadians
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.
Example:
- Overrides:
turnGunLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the left. Ifradians
> 0 the robot's gun will turn left. Ifradians
< 0 the robot's gun will turn right. Ifradians
= 0 the robot's gun will not turn, but execute.- See Also:
Robot.turnGunLeft(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
turnGunRightRadians
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.
Example:
- Overrides:
turnGunRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's gun to the right. Ifradians
> 0 the robot's gun will turn right. Ifradians
< 0 the robot's gun will turn left. Ifradians
= 0 the robot's gun will not turn, but execute.- See Also:
Robot.turnGunRight(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnRadarLeftRadians(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnRadarRightRadians(double)
,Robot.setAdjustGunForRobotTurn(boolean)
turnRadarLeftRadians
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.
Example:
- Overrides:
turnRadarLeftRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the left. Ifradians
> 0 the robot's radar will turn left. Ifradians
< 0 the robot's radar will turn right. Ifradians
= 0 the robot's radar will not turn, but execute.- See Also:
Robot.turnRadarLeft(double)
,Robot.turnRadarRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.setAdjustRadarForRobotTurn(boolean)
,Robot.setAdjustRadarForGunTurn(boolean)
turnRadarRightRadians
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.
Example:
- Overrides:
turnRadarRightRadians
in class_AdvancedRadiansRobot
- Parameters:
radians
- the amount of radians to turn the robot's radar to the right. Ifradians
> 0 the robot's radar will turn right. Ifradians
< 0 the robot's radar will turn left. Ifradians
= 0 the robot's radar will not turn, but execute.- See Also:
Robot.turnRadarRight(double)
,Robot.turnRadarLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnLeft(double)
,AdvancedRobot.turnLeftRadians(double)
,Robot.turnRight(double)
,AdvancedRobot.turnRightRadians(double)
,Robot.turnGunLeft(double)
,AdvancedRobot.turnGunLeftRadians(double)
,Robot.turnGunRight(double)
,AdvancedRobot.turnGunRightRadians(double)
,Robot.setAdjustRadarForRobotTurn(boolean)
,Robot.setAdjustRadarForGunTurn(boolean)
getGunTurnRemainingRadians
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.
- Overrides:
getGunTurnRemainingRadians
in class_AdvancedRadiansRobot
- Returns:
- the angle remaining in the gun's turn, in radians
- See Also:
AdvancedRobot.getGunTurnRemaining()
,getTurnRemaining()
,AdvancedRobot.getTurnRemainingRadians()
,getRadarTurnRemaining()
,AdvancedRobot.getRadarTurnRemainingRadians()
getRadarTurnRemainingRadians
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.
- Overrides:
getRadarTurnRemainingRadians
in class_AdvancedRadiansRobot
- Returns:
- the angle remaining in the radar's turn, in radians
- See Also:
AdvancedRobot.getRadarTurnRemaining()
,getTurnRemaining()
,AdvancedRobot.getTurnRemainingRadians()
,getGunTurnRemaining()
,AdvancedRobot.getGunTurnRemainingRadians()
getTurnRemainingRadians
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.
- Overrides:
getTurnRemainingRadians
in class_AdvancedRadiansRobot
- Returns:
- the angle remaining in the robot's turn, in radians
- See Also:
AdvancedRobot.getTurnRemaining()
,getGunTurnRemaining()
,AdvancedRobot.getGunTurnRemainingRadians()
,getRadarTurnRemaining()
,AdvancedRobot.getRadarTurnRemainingRadians()
getAdvancedEventListener
Do not call this method! This method is called by the game to notify this robot about advanced robot event. Hence, this method must be implemented so it returns your IAdvancedEvents
listener.
- Specified by:
getAdvancedEventListener
in interfaceIAdvancedRobot
- Returns:
- listener to advanced events or
null
if this robot should not receive the notifications.
Overview | Package | Class | Tree | Deprecated | Index | Help |
I came to ask about Robocode robots. I have a code for my robots and against 26 of my friends it came 11th. However, I want to try to make it better. I have looked over websites and adjusted my code so it can move unpredictably. This helped it come 1st once in ten rounds. Could you please give me some ideas and tips to help improve this robot please? I can then edit my robot and see how it does. I want the robot to remain in extends Robot though.
The Guy with The Hat3 Answers
Robocode Game
First write the OnScannedRobot method.
Don't use random values because it is inaccurate.
The radar points at the same angulation of the gun. So, when the radar points at robot and scan it, the robot is firing.
The method onScanned() is called when the radar scan a robot.
So, now we write the run() method.
We write only in the loop. So, the loop repeat the same operations in each second.
To scan all the zone, we rotate the gun at 360 degrees.
Now, the robot will go ahead 25 pixels per second.
Sooner or later the robot will reach the wall of the map.
The robot can be blocked when reaches the wall.
We'll resolve using onHitWall() method.
You want to create a coward robot :D? Use the onHitByBullet() method to get away if the energy is low. When the robot is stricken by a bullet, this method is called.
visit this page to watch all robocode API http://robocode.sourceforge.net/docs/robocode/
:D goodbye, Frank
Instead of just turning randomly turn so that your side faces a robot that you scan. This way you can move side to side easily and dodge the bullets. You can either move sideways randomly or only move when you register a change in the other robots energy level because that could mean that they fired at you.
Also you should have a better way of targeting the enemy. When you see them you fire so by the time the bullet reaches them they have probably moved. You can use basic trigonometry to guess where the enemy will be when the bullet reaches them.
Yep_It's_MeYep_It's_MeThe robowiki has information on all the top bots - that should help you out. I've done a bit of robocoding and found that wave surfing along with a pattern-matching gun is probably as good as you're going to get against most bots, but it took me months to grok pattern matching and wave surfing to enough of an extent to cobble together a half-decent implementation. Even then, I didn't retain enough of the knowledge to re-implement it when the code was lost.
Chris BrowneChris Browneprotected by Community♦May 31 '13 at 19:30
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?