This wiki is archived and useful information is being migrated to the main bzflag.org website

Editing BZRobots/API

Jump to: navigation, search

Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to copy and paste your text into a text file and save it for later.

The administrator who locked it offered this explanation: Archived wiki

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 2: Line 2:
 
This page describes the API for the BZRobots Programmable Computer Player Client.
 
This page describes the API for the BZRobots Programmable Computer Player Client.
  
 
+
'''Available Methods'''
The [[BZRobots]] API is based heavily on the [http://robocode.sourceforge.net/ robocode] project. It is class-based, meaning that a robot is built by extending from one of the following two classes:
+
{| cellspacing="0" border="1"
* Robot (An easy-to-use robot with a simplified API, e.g. degree units, etc.)
+
!Method
* AdvancedRobot (A robot with more advanced features in the API, e.g. radian units, etc.)
+
!Description
 
+
!Steady-state required?
 
+
The main control loop is created by overriding the class method ''run'', and then using the methods shown below to control the robot. These control methods fit into two categories 'blocking', and 'non-blocking'. A blocking function, once called, will not return until either the requested action has completed, or the amount of time allotted for a "turn" or "tick" has passed - whichever comes later.
+
 
+
Non-blocking functions will return immediately, allowing for additional processing, but their actions do not take effect immediately; rather, they will take place when the ''execute'' method is called. After a blocking function has been called, various "events" that have been generated during that turn may be processed by the various event methods, if they have been overridden.
+
 
+
 
+
If you are new to BZRobots, but have Robocode experience, you may want to take a look at [[BZRobots/API_BZRobots_vs_Robocode]]
+
 
+
 
+
Unless otherwise specified, all units are in map units (distance), degrees (angles), and seconds (time)
+
 
+
=API Methods=
+
'''Note:''' ''As BZRobots currently supports bot scripts written in three different languages, the following is language independent description of the methods available for bot development. Actual usage will vary depending on the language used''
+
 
+
{| cellpadding=4 {{Prettytable}}
+
 
|-
 
|-
! colspan=7 {{Hl3}} | ==Robot/AdvancedRobot Methods==
+
|Execute
 +
|Runs a tick of the 'planned actions', and perhaps fires a shot (see SetFire).
 +
|'''Yes'''
 
|-
 
|-
| {{Hl3}} |'''Method'''
+
|GetBattleFieldSize
| {{Hl3}} |'''Description'''  
+
|Gives a 'BattleFieldSize'-reply with the size of the map in "units". (the map is size x size, and coordinates run from -size/2 to size/2)
| {{Hl3}} |'''Blocking''' 
+
|No
| {{Hl3}} |'''Robot'''
+
| {{Hl3}} |'''Advanced<br>Robot'''
+
| {{Hl3}} |'''Robocode<br>Compatible'''
+
| {{Hl3}} |'''Functional<br>Status'''
+
 
|-
 
|-
| void ahead(double distance)
+
|GetDistanceRemaining
| Moves the robot ahead by ''distance''
+
|Gives a 'DistanceRemaining'-reply with how much is left of the currently planned movement.
! bgcolor="#00BB00" | Y
+
|'''Yes'''
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| void back(double distance)
+
|GetGunHeat
| Moves the robot back by ''distance''  
+
|Gives a 'GunHeat'-reply with how many seconds are left of the gun cooldown.
! bgcolor="#00BB00" | Y
+
|'''Yes'''
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| void clearAllEvents()
+
|GetHeading
| Clears the event queue; any events will be disgarded
+
|Gives a 'Heading'-reply with heading of the tank.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| void doNothing()
+
|GetHeight
| Clears the event queue; any events will be disgarded
+
|Gives a 'Height'-reply with height of the tank.
! bgcolor="#BB0000" | Y
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| void execute()
+
|GetLength
| Causes any action queued by setAhead, setTurnRight, etc. to take place, ending the "turn"
+
|Gives a 'Length'-reply with height of the tank.
! bgcolor="#00BB00" | Y
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| void fire(double power)
+
|GetTickDuration
| Fires a single shot
+
|Gives a 'TickDuration'-reply with how many seconds makes up one tick.
! bgcolor="#00BB00" | Y
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| Bullet *fireBullet(double power)
+
|GetTickRemaining
| Fires a single shot, returning a reference to the fired shot
+
|Gives a 'TickRemaining'-reply with how many seconds are left of this tick.
! bgcolor="#00BB00" | Y
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#BBBB00" | 50%
+
 
|-
 
|-
| list<Event> getAllEvents()
+
|GetTurnRemaining
| Returns a list of all events currently in the queue
+
|Gives a 'TurnRemaining'-reply with how much is left of the currently planned turn.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
 
|-
 
|-
| double getBattleFieldLength()
+
|GetWidth
| Returns the length of the battle field
+
|Gives a 'Width'-reply with width of the tank.
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getBattleFieldWidth()
+
|GetX
| Returns the width of the battle field
+
|Gives a 'X'-reply with x-coordinate of the tank. (0, 0) is "lower left" corner.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| list<Event> getBulletHitBulletEvents()
+
|GetY
| Returns a list of BulletHitBulletEvent currently in the queue
+
|Gives a 'Y'-reply with y-coordinate of the tank. (0, 0) is "lower left" corner.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
 
|-
 
|-
| list<Event> getBulletHitEvents()
+
|GetZ
| Returns a list of BulletHitEvent currently in the queue
+
|Gives a 'Z'-reply with z-coordinate of the tank. 0 is ground level.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
 
|-
 
|-
| list<Event> getBulletMissedEvents()
+
|IdentifyFrontend <version>
| Returns a list of all BulletMissedEvent currently in the queue
+
|Greets the backend. (specifying protocol-version <version>, under development: 0001)
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
 
|-
 
|-
| double getDistanceRemaining()
+
|SetAhead <distance>
| Returns the distance remaining from a setAhead/setBack
+
|Sets planned movement (for next 'execute'-s) that moves 'distance' units.
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getEnergy()
+
|SetFire
| For robocode compatibly - robot's current "energy" (Always 16)  
+
|Sets a planned shot (for next 'execute')
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
 
|-
 
|-
| double getGunCoolingRate()
+
|SetResume
| Returns the time it takes to reload a single shot
+
|Overwrites and restores the bots current actions (distance and turn) from a previous call to SetStop. This will fail if there are no previous SetStop-calls. Will not restore until you 'execute'. (If you call SetAhead, SetTurn etc before this, they will be overwritten unless SetResume fails)
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getGunHeading()
+
|SetStop <overwrite>
| For robocode compatibly - robot's gun heading (Always matches robot heading)
+
|Stores and clears the bots current actions (distance and turn). If you've previously called SetStop and not SetResume, this will fail unless you've Set overwrite to true. Does not store & clear until you call 'execute'. (You can call SetAhead, SetTurn etc after this, and they will become the 'new' values, instead of 0.)
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getGunHeadingRadians()
+
|SetSpeed <factor>
| For robocode compatibly - robot's gun heading (Always matches robot heading)
+
|Sets next actions speed, value between 0 and 1.0. (for future 'execute'-s)
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getGunHeat()
+
|SetTickDuration <seconds>
| Returns the time until the gun will be ready to fire
+
|Sets the duration of a tick, in seconds.
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getGunTurnRemaining()
+
|SetTurnLeft <degrees>
| For robocode compatibly - (Always returns 0)
+
|Sets planned turn (for next 'execute'-s) that turns 'degrees' degrees to the left.
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
 
|-
 
|-
| double getGunTurnRemainingRadians()
+
|SetTurnRate <factor>
| For robocode compatibly - (Always returns 0)
+
|Sets next actions turnrate, value between 0 and 1.0. (for next 'execute'-s)
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
 
! bgcolor="#00BB00" | Y
+
|}
! bgcolor="#00BB00" | Y
+
 
! bgcolor="#555555" | N/A
+
'''Frontend To Backend Messages - To Be Implemented'''
 +
{| cellspacing="0" border="1"
 +
!Message syntax
 +
!Description
 +
!Steady-state required?
 
|-
 
|-
| double getHeading()
+
|GetConstants
| Returns the current heading of the robot
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getHeadingRadians()
+
|GetFlags
| Returns the current heading of the robot in radians
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getHeight()
+
|GetMyTanks
| Returns the height (Z-size) of the robot
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getLength()
+
|GetNumRounds
| Returns the length (Y-size) of the robot
+
|To be defined (or removed?)
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| string getName()
+
|GetObstacles
| Returns the name (Callsign) of the robot
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| int getNumRounds()
+
|GetOtherTanks
| For robocode compatibly - number of battle rounds (Always '''1''')
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| int getOthers()
+
|GetRoundNum
| Returns the number of other robots/tanks currently in the battle
+
|Returns the number of times the bot has died (or?).
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getRadarHeading()
+
|GetShots
| For robocode compatibly - robot's radar heading (Always matches robot heading)
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getRadarHeadingRadians()
+
|GetSpeed
| For robocode compatibly - robot's radar heading (Always matches robot heading)
+
|Returns the current velocity, as per default - or as per last SetSpeed.
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
 
|-
 
|-
| double getRadarTurnRemaining()
+
|GetTeams
| For robocode compatibly - (Always returns 0)
+
|<explain>
! bgcolor="#BB0000" | N
+
|No
! bgcolor="#00BB00" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
 
|-
 
|-
| double getRadarTurnRemainingRadians()
+
|GetTime
| For robocode compatibly - (Always returns 0)
+
|RoboCode: "Returns the game time of the current round, where the time is equal to the current turn in the round." - Will most likely return number of times you've 'execute'-d. Alternatively; return elapsed seconds / tickDuration (but tickDuration can change), or elapsed seconds.
! bgcolor="#BB0000" | N
+
|'''Yes'''
! bgcolor="#00BB00" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| list<Event> getRobotDeathEvents()
+
| Returns a list of all RobotDeathEvent currently in the queue
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
|-
+
| int getRoundNum()
+
| For robocode compatibly - current battle round (Always '''1''')
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| list<Event> getScannedRobotEvents()
+
| Returns a list of all ScannedRobotEvent currently in the queue
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
|-
+
| list<Event> getStatusEvents()
+
| Returns a list of all StatusEvent currently in the queue
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 5%
+
|-
+
| double getTime()
+
| Returns the current game time  
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getTurnRemaining()
+
| Returns the distance remaining from a setTurnLeft/setTurnRight
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getTurnRemainingRadians()
+
| Returns the distance remaining from a setTurnLeft/setTurnRight in radians
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getVelocity()
+
| Returns the speed of the robot (excluding the Z-speed)
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getWidth()
+
| Returns the width (X-size) of the robot
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getX()
+
| Returns the current X coordinate of the robot
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getY()
+
| Returns the current Y coordinate of the robot
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| double getZ()
+
| Returns the current Z coordinate of the robot
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| bool isAdjustGunForRobotTurn
+
| For robocode compatibility - always true
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| bool isAdjustRadarForGunTurn
+
| For robocode compatibility - always true
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| bool isAdjustRadarForRobotTurn
+
| For robocode compatibility - always true
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void resume()
+
| Resumes any movements saved by a previous call to ''stop''
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void scan()
+
| Prompts a radar scan, resulting in onScannedRobot events
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setAdjustGunForRobotTurn(bool independent)
+
| For robocode compatibly - but has no effect when false
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void setAdjustRadarForGunTurn(bool independent)
+
| For robocode compatibly - but has no effect when false
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void setAdjustRadarForRobotTurn(bool independent)
+
| For robocode compatibly - but has no effect when false
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void setAhead(double distance)
+
| Specifies that the robot should move forward by ''distance'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setBack(double distance)
+
| Specifies that the robot should move backwad by ''distance'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setFire(double power)
+
| Specifies that the robot should fire a bullet of ''power'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| Bullet *setFireBullet(double power)
+
| Specifies that the robot should fire a bullet of ''power'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#BBBB00" | 50%
+
|-
+
| void setMaxTurnRate(double maxTurnRate)
+
| Sets a limit on the maximum turn rate of the robot at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setMaxVelocity(double maxVelocity)
+
| Sets a limit on the maximum speed of the robot at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setResume()
+
| Immediately resumes any motion halted by setStop
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void setStop(bool overwrite = false)
+
| Immediately stops any motion until resumed by setResume
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void void setTurnGunLeft(double degrees)
+
| For robocode compatablity - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnGunLeftRadians(double radians)
+
| For robocode compatablity - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnGunRight(double degrees)
+
| For robocode compatablity - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnGunRightRadians(double radians)
+
| For robocode compatablity - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnLeft(double degrees)
+
| Sets the robot to turn left by ''degrees'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void void setTurnLeftRadians(double radians)
+
| Sets the robot to turn left by ''radians'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void void setTurnRadarLeft(double degrees)
+
| For robocode compatibility - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnRadarLeftRadians(double radians)
+
| For robocode compatibility - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnRadarRight(double degrees)
+
| For robocode compatibility - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnRadarRightRadians(double radians)
+
| For robocode compatibility - has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void void setTurnRight(double degrees)
+
| Sets the robot to turn right by ''degrees'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void void setTurnRightRadians(double radians)
+
| Sets the robot to turn right by ''radians'' at the next execute()
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void stop(bool overwrite = false)
+
| Stops the robot, saving any current movements
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void turnGunRight(double degrees)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnGunLeft(double degrees)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnLeft(double degrees)
+
| Turns the robot left ''degrees'' degrees
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void turnLeftRadians(double radians)
+
| Turns the robot left ''radians'' radians
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void turnRadarRight(double degrees)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnRadarLeft(double degrees)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnRadarLeftRadians(double radians)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnRadarRight(double degrees)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnRadarRightRadians(double radians)
+
| For robocode compatibly - but has no effect
+
! bgcolor="#BB0000" | N
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void turnRight(double degrees)
+
| Turns the robot right ''degrees'' degrees
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void turnRightRadians(double radians)
+
| Turns the robot right ''radians'' radians
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | N
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
! colspan=7 {{Hl3}} | ==Robot/AdvancedRobot Event Handlers==
+
|-
+
| {{Hl3}} |'''Method'''
+
| {{Hl3}} |'''Description'''
+
| {{Hl3}} |'''Blocking''' 
+
| {{Hl3}} |'''Robot'''
+
| {{Hl3}} |'''Advanced<br>Robot'''
+
| {{Hl3}} |'''Robocode<br>Compatible'''
+
| {{Hl3}} |'''Functional<br>Status'''
+
|-
+
| void onBattleEnded(BattleEndedEvent e)
+
| Called at the end of a league match, or the server shutting down
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 10%
+
|-
+
| void onBulletFired(BulletFiredEvent e)
+
| Called when another robot/tank fires a bullet
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
! bgcolor="#BB0000" | 10%
+
|-
+
| void onBulletHit(BulletHitEvent e)
+
| Called when a bullet fired by the robot hits another robot
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | 80%
+
|-
+
| void onBulletHitBullet(BulletHitBulletEvente)
+
| For robocode compatibility - will never take place
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void onBulletMissed(BulletMissedEvent e)
+
| Called when a bullet fired by the robot expires or hits a wall
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 10%
+
|-
+
| void onDeath(DeathEvent e)
+
| Called when the robot dies
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void onHitByBullet(HitByBulletEvent e)
+
| Called when the robot is hit by a bullet
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BB0000" | 25%
+
|-
+
| void onHitRobot(HitRobotEvente)
+
| For robocode compatibility - will never be called
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
|-
+
| void onHitWall(HitWallEvent e)
+
| Called when the robot runs into a wall or object
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#22BB00" | 90%
+
|-
+
| void onRobotDeath(RobotDeathEvent e)
+
| Called when the robot is killed
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void onScannedRobot(ScannedRobotEvent e)
+
| Called each turn as the robot's radar "sees" another robot
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void onSpawn(SpawnEvent e)
+
| Called when the robot spawns
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | 100%
+
|-
+
| void onStatus(StatusEvent e)
+
| Called at the beginning of each "turn", before the main loop is run
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | 95%
+
|-
+
| void onWin(WinEvent e)
+
| Called when the robot (or it's team) wins a league match
+
! bgcolor="#555555" | N/A
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#00BB00" | Y
+
! bgcolor="#BBBB00" | Y
+
! bgcolor="#BB0000" | 10%
+
 
|-
 
|-
 +
|GetBases
 +
|<explain>
 +
|No
 +
 
|}
 
|}
  
 
=See Also=
 
=See Also=
  
* [[BZRobots/API_BZRobots_vs_Robocode]] - Differences between Robocode and BZRobots
+
[[BZRobots/Ideas]] - Ideas for a possible future release
* [[BZRobots/Ideas]] - Ideas for a possible future release
+

Please note that all contributions to BZFlagWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see BZFlagWiki:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)

Templates used on this page: