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

Difference between revisions of "BZRobots/API BZRobots vs Robocode"

From BZFlagWiki
Jump to: navigation, search
(Differences between Robocode and BZRobots)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=Overview=
 
=Overview=
This page is to describe the changes that have been made to the RoboCode-compliant part of the API to accomodate how BZFlag works.
+
This page is to describe the changes that have been made to the RoboCode-compliant part of the API to accommodate how BZFlag works.
  
= API Changes =
+
= Differences between Robocode and BZRobots =
== Behaviour changes ==
+
* '''execute()''' - No longer "blocks" until the action is completed - it returns immediately unless you're currently completing an action. This also goes for other functions, see their relevant protocol messages in [[BZRobots/Protocol]] ("Steady-state required?"). This is because BZFlag is realtime (and RoboCode isn't).
+
  
== Name changes ==
+
== Game model ==
* '''getHeight()''' - Renamed to '''getLength()'''. This is because "height" in three dimensions refers to an different axis than what getHeight in two dimensions (and RoboCode) refers to.
+
* Robocode game model assumes you have only one life; in BZFlag, you get to respawn
 +
** onWin/onBattleEnded are applicable to a league match only
 +
** onDeath simply means you die, but you will spawn shortly after
 +
** There is a new onSpawn/SpawnEvent in the BZRobots API
  
== API Additions ==
+
== Time-based-movement ==
 +
* Robocode 'turns' are in discrete ticks; BZFlag is real-time, which has the following implications:
 +
** Time is in decimal seconds; instead of turn 0,1,2, you get 1.5 seconds, 1.8 seconds, 2.34 seconds, etc.
 +
** Because of the above, getTime() returns a double instead of a long
 +
** Blocking functions such as execute have a small time delay, dependent on how long you executed
 +
** For now, there is no limitation on how long you may execute your "turn"
  
* '''getZ()''' - Returns the Z position of a tank
+
== Fixed Radar and Gun ==
 +
* Robocode has movable radar and gun; BZFlag does not
 +
** setAdjustGunForRobotTurn and similar have no effect
 +
** turnGunLeft/turnRadarRight/etc. have no effect
 +
** getGunHeading/getRadarHeading will always match the robot's getHeading
 +
** BZFlag's radar effectively sweeps 360 degrees each 'tick/turn'
  
* '''getLength()''' - Previously the "height" in the RoboCode API, this returns the length of a tank from the tip of the barrel to the rear of the tank.
+
== 3rd dimension ==
 +
* Robocode is 2D, but BZFlag is 3D; this means that:
 +
** Methods named xxxHeight are renamed to xxxLength.
 +
** Methods named xxxHeight will return a Z-dimension
 +
** Objects having a getX() and getY() now have a getZ() as well
 +
** For simplicity, getVelocity() still refers only to X-Y velocity
 +
 
 +
== Energy ==
 +
* Robocode bots have "energy"; BZFlag does not
 +
** The API now has onBulletFired(BulletFiredEvent e) so you can detect a fired shot
 +
** A bullet's energy will always be 3, regardless
 +
** A robot's getEnergy always returns 16 (Per the [http://robowiki.net/wiki/Robocode/FAQ Robocode Damage Formula] with a bullet power of 3, since a single shot kills)
 +
** Changing ''power'' in void fire(double power) and similar will have no effect
 +
 
 +
== Bullets ==
 +
* In Robocode, bullet speed is a function of energy, but in BZFlag bullet velocity is fixed
  
 
=See Also=
 
=See Also=
* [[BZRobots/About]]
+
* [[BZRobots/API]]
* [[BZRobots/Protocol]]
+

Latest revision as of 21:20, 17 August 2009

Overview[edit]

This page is to describe the changes that have been made to the RoboCode-compliant part of the API to accommodate how BZFlag works.

Differences between Robocode and BZRobots[edit]

Game model[edit]

  • Robocode game model assumes you have only one life; in BZFlag, you get to respawn
    • onWin/onBattleEnded are applicable to a league match only
    • onDeath simply means you die, but you will spawn shortly after
    • There is a new onSpawn/SpawnEvent in the BZRobots API

Time-based-movement[edit]

  • Robocode 'turns' are in discrete ticks; BZFlag is real-time, which has the following implications:
    • Time is in decimal seconds; instead of turn 0,1,2, you get 1.5 seconds, 1.8 seconds, 2.34 seconds, etc.
    • Because of the above, getTime() returns a double instead of a long
    • Blocking functions such as execute have a small time delay, dependent on how long you executed
    • For now, there is no limitation on how long you may execute your "turn"

Fixed Radar and Gun[edit]

  • Robocode has movable radar and gun; BZFlag does not
    • setAdjustGunForRobotTurn and similar have no effect
    • turnGunLeft/turnRadarRight/etc. have no effect
    • getGunHeading/getRadarHeading will always match the robot's getHeading
    • BZFlag's radar effectively sweeps 360 degrees each 'tick/turn'

3rd dimension[edit]

  • Robocode is 2D, but BZFlag is 3D; this means that:
    • Methods named xxxHeight are renamed to xxxLength.
    • Methods named xxxHeight will return a Z-dimension
    • Objects having a getX() and getY() now have a getZ() as well
    • For simplicity, getVelocity() still refers only to X-Y velocity

Energy[edit]

  • Robocode bots have "energy"; BZFlag does not
    • The API now has onBulletFired(BulletFiredEvent e) so you can detect a fired shot
    • A bullet's energy will always be 3, regardless
    • A robot's getEnergy always returns 16 (Per the Robocode Damage Formula with a bullet power of 3, since a single shot kills)
    • Changing power in void fire(double power) and similar will have no effect

Bullets[edit]

  • In Robocode, bullet speed is a function of energy, but in BZFlag bullet velocity is fixed

See Also[edit]