23.07.2019

Robocode Robot Downloads

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

  1. Robocode Robot Downloads Pc
  2. Robocode Game

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
  1. 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.
  2. 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
voidaddCustomEvent(Condition condition)
Registers a custom event to be called when a condition is met.
voidclearAllEvents()
Clears out any pending events in the robot's event queue immediately.
voidexecute()
Executes any pending actions, or continues executing actions that are in process.
IAdvancedEventsgetAdvancedEventListener()
Do not call this method!
VectorgetAllEvents()
Returns a vector containing all events currently in the robot's queue.
VectorgetBulletHitBulletEvents()
Returns a vector containing all BulletHitBulletEvents currently in the robot's queue.
VectorgetBulletHitEvents()
Returns a vector containing all BulletHitEvents currently in the robot's queue.
VectorgetBulletMissedEvents()
Returns a vector containing all BulletMissedEvents currently in the robot's queue.
FilegetDataDirectory()
Returns a file representing a data directory for the robot, which can be written to using RobocodeFileOutputStream or RobocodeFileWriter.
FilegetDataFile(String filename)
Returns a file in your data directory that you can write to using RobocodeFileOutputStream or RobocodeFileWriter.
longgetDataQuotaAvailable()
Returns the data quota available in your data directory, i.e. the amount of bytes left in the data directory for the robot.
doublegetDistanceRemaining()
Returns the distance remaining in the robot's current move measured in pixels.
intgetEventPriority(String eventClass)
Returns the current priority of a class of events.
doublegetGunHeadingRadians()
Returns the direction that the robot's gun is facing, in radians.
doublegetGunTurnRemaining()
Returns the angle remaining in the gun's turn, in degrees.
doublegetGunTurnRemainingRadians()
Returns the angle remaining in the gun's turn, in radians.
doublegetHeadingRadians()
Returns the direction that the robot's body is facing, in radians.
VectorgetHitByBulletEvents()
Returns a vector containing all HitByBulletEvents currently in the robot's queue.
VectorgetHitRobotEvents()
Returns a vector containing all HitRobotEvents currently in the robot's queue.
VectorgetHitWallEvents()
Returns a vector containing all HitWallEvents currently in the robot's queue.
doublegetRadarHeadingRadians()
Returns the direction that the robot's radar is facing, in radians.
doublegetRadarTurnRemaining()
Returns the angle remaining in the radar's turn, in degrees.
doublegetRadarTurnRemainingRadians()
Returns the angle remaining in the radar's turn, in radians.
VectorgetRobotDeathEvents()
Returns a vector containing all RobotDeathEvents currently in the robot's queue.
VectorgetScannedRobotEvents()
Returns a vector containing all ScannedRobotEvents currently in the robot's queue.
VectorgetStatusEvents()
Returns a vector containing all StatusEvents currently in the robot's queue.
doublegetTurnRemaining()
Returns the angle remaining in the robots's turn, in degrees.
doublegetTurnRemainingRadians()
Returns the angle remaining in the robot's turn, in radians.
booleanisAdjustGunForRobotTurn()
Checks if the gun is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
booleanisAdjustRadarForGunTurn()
Checks if the radar is set to adjust for the gun turning, i.e. to turn independent from the gun's turn.
booleanisAdjustRadarForRobotTurn()
Checks if the radar is set to adjust for the robot turning, i.e. to turn independent from the robot's body turn.
voidonCustomEvent(CustomEvent event)
This method is called when a custom condition is met.
voidonDeath(DeathEvent event)
This method is called if your robot dies.
voidonSkippedTurn(SkippedTurnEvent event)
This method is called if the robot is using too much time between actions.
voidremoveCustomEvent(Condition condition)
Removes a custom event that was previously added by calling AdvancedRobot.addCustomEvent(Condition).
voidsetAhead(double distance)
Sets the robot to move ahead (forward) by distance measured in pixels when the next execution takes place.
voidsetBack(double distance)
Sets the robot to move back by distance measured in pixels when the next execution takes place.
voidsetEventPriority(String eventClass, int priority)
Sets the priority of a class of events.
voidsetFire(double power)
Sets the gun to fire a bullet when the next execution takes place.
BulletsetFireBullet(double power)
Sets the gun to fire a bullet when the next execution takes place.
voidsetInterruptible(boolean interruptible)
Call this during an event handler to allow new events of the same priority to restart the event handler.
voidsetMaxTurnRate(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).
voidsetMaxVelocity(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).
voidsetResume()
Sets the robot to resume the movement stopped by stop() or AdvancedRobot.setStop(), if any.
voidsetStop()
This call is identical to stop(), but returns immediately, and will not execute until you call AdvancedRobot.execute() or take an action that executes.
voidsetStop(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.
voidsetTurnGunLeft(double degrees)
Sets the robot's gun to turn left by degrees when the next execution takes place.
voidsetTurnGunLeftRadians(double radians)
Sets the robot's gun to turn left by radians when the next execution takes place.
voidsetTurnGunRight(double degrees)
Sets the robot's gun to turn right by degrees when the next execution takes place.
voidsetTurnGunRightRadians(double radians)
Sets the robot's gun to turn right by radians when the next execution takes place.
voidsetTurnLeft(double degrees)
Sets the robot's body to turn left by degrees when the next execution takes place.
voidsetTurnLeftRadians(double radians)
Sets the robot's body to turn left by radians when the next execution takes place.
voidsetTurnRadarLeft(double degrees)
Sets the robot's radar to turn left by degrees when the next execution takes place.
voidsetTurnRadarLeftRadians(double radians)
Sets the robot's radar to turn left by radians when the next execution takes place.
voidsetTurnRadarRight(double degrees)
Sets the robot's radar to turn right by degrees when the next execution takes place.
voidsetTurnRadarRightRadians(double radians)
Sets the robot's radar to turn right by radians when the next execution takes place.
voidsetTurnRight(double degrees)
Sets the robot's body to turn right by degrees when the next execution takes place.
voidsetTurnRightRadians(double radians)
Sets the robot's body to turn right by radians when the next execution takes place.
voidturnGunLeftRadians(double radians)
Immediately turns the robot's gun to the left by radians.
voidturnGunRightRadians(double radians)
Immediately turns the robot's gun to the right by radians.
voidturnLeftRadians(double radians)
Immediately turns the robot's body to the left by radians.
voidturnRadarLeftRadians(double radians)
Immediately turns the robot's radar to the left by radians.
voidturnRadarRightRadians(double radians)
Immediately turns the robot's radar to the right by radians.
voidturnRightRadians(double radians)
Immediately turns the robot's body to the right by radians.
voidwaitFor(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. If distance > 0 the robot is set to move ahead. If distance< 0 the robot is set to move back. If distance = 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. If distance > 0 the robot is set to move back. If distance< 0 the robot is set to move ahead. If distance = 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. If degrees > 0 the robot is set to turn left. If degrees< 0 the robot is set to turn right. If degrees = 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. If degrees > 0 the robot is set to turn right. If degrees< 0 the robot is set to turn left. If degrees = 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 call AdvancedRobot.removeCustomEvent(Condition).

Example:

Parameters:
condition - the condition that must be met.
Throws:
NullPointerException - if the condition parameter has been set to null.
See Also:
Condition, AdvancedRobot.removeCustomEvent(Condition)

removeCustomEvent

Removes a custom event that was previously added by calling AdvancedRobot.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 to null.
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 using RobocodeFileOutputStream 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 using RobocodeFileOutputStream 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:

Diamond
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 interface IAdvancedEvents
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 for
priority - 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 by stop() 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 to stop(), 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 to stop(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. If degrees > 0 the robot's gun is set to turn left. If degrees< 0 the robot's gun is set to turn right. If degrees = 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. If degrees > 0 the robot's gun is set to turn right. If degrees< 0 the robot's gun is set to turn left. If degrees = 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. If degrees > 0 the robot's radar is set to turn left. If degrees< 0 the robot's radar is set to turn right. If degrees = 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. If degrees > 0 the robot's radar is set to turn right. If degrees< 0 the robot's radar is set to turn left. If degrees = 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 a Condition.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 interface IBasicEvents
Overrides:
onDeath in class Robot
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 interface IAdvancedEvents
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. If radians > 0 the robot is set to turn left. If radians< 0 the robot is set to turn right. If radians = 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. If radians > 0 the robot is set to turn right. If radians< 0 the robot is set to turn left. If radians = 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. If radians > 0 the robot will turn right. If radians< 0 the robot will turn left. If radians = 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. If radians > 0 the robot will turn right. If radians< 0 the robot will turn left. If radians = 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. If radians > 0 the robot's gun is set to turn left. If radians< 0 the robot's gun is set to turn right. If radians = 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. If radians > 0 the robot's gun is set to turn left. If radians< 0 the robot's gun is set to turn right. If radians = 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. If radians > 0 the robot's radar is set to turn left. If radians< 0 the robot's radar is set to turn right. If radians = 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. If radians > 0 the robot's radar is set to turn left. If radians< 0 the robot's radar is set to turn right. If radians = 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. If radians > 0 the robot's gun will turn left. If radians< 0 the robot's gun will turn right. If radians = 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. If radians > 0 the robot's gun will turn right. If radians< 0 the robot's gun will turn left. If radians = 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. If radians > 0 the robot's radar will turn left. If radians< 0 the robot's radar will turn right. If radians = 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. If radians > 0 the robot's radar will turn right. If radians< 0 the robot's radar will turn left. If radians = 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. Downloads

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 interface IAdvancedRobot
Returns:
listener to advanced events or null if this robot should not receive the notifications.
OverviewPackageClassTreeDeprecatedIndexHelp
PREV CLASS NEXT CLASSFRAMESNO FRAMESAll Classes SUMMARY: NESTED FIELD CONSTR METHOD DETAIL: FIELD CONSTR METHOD Copyright © 2009 Robocode. All Rights Reserved.
Active2 years, 9 months ago

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 Hat
6,6996 gold badges38 silver badges60 bronze badges
user1255673user1255673

3 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

Frank SollFrank Soll

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_Me
2,2862 gold badges25 silver badges48 bronze badges

The 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 Browne
1,1601 gold badge10 silver badges26 bronze badges

protected by CommunityMay 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?

Not the answer you're looking for? Browse other questions tagged javarobocode or ask your own question.