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

Difference between revisions of "BZRobots/Protocol"

From BZFlagWiki
Jump to: navigation, search
(Protocol Description)
(Overview)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=Overview=
 
=Overview=
This page describes the BZRobots Enhanced Protocol that is part of the Programmable Computer Player Client project for the [[Google Summer Of Code]].
+
This page describes the [[BZRobots]] Enhanced Protocol that forms the internals of the BZFlag Programmable Computer Player Client
  
=Protocol Description=
+
=Description=
The protocol is linebased, and works on a request-reply basis. Below is a table of all available requests.
+
The [[BZRobots]] client currently consists of two parts called the "backend" and the "frontend". The "backend" is a lightweight game client that communicates with BZFS. It also runs a lightweight line-by-line text-based server, on which commands can be sent to control a robot. The "frontend" is an instance of a BZAdvancedRobot, including the necessary parts to communicate with the "backend".
The backend has something called a ''steady-state'' - this is basically when the backend is idle, and the tank likewise. Some commands will only work in this steady-state (because they will only make sense when the bot is not doing anything), and if one of these commands are sent when the bot is in ''active-state'' the backend will '''not reply''' until the backend has entered ''steady-state'' (and any commands sent after the first command are queued for handling until the ''blocking'' command has been handled). These commands are marked with "'''Yes'''" in the "Steady-state required?"-column.
+
  
'''Frontend To Backend Messages'''
+
==Available Commands==
{| cellspacing="0" border="1"
+
See the [[BZRobots/API]] for the commands currently available to the BZRobots protocol.
!Message syntax
+
!Description
+
!Steady-state required?
+
!Implemented?
+
|-
+
|agent 1
+
|Greets the backend.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|bases
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|constants
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|execute <bot>
+
|Runs a tick of the 'planned actions', and perhaps fires a shot (see setFire).
+
|'''Yes'''
+
!style="background-color: #55ff55"|Yes
+
|-
+
|flags
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|getDistanceRemaining <bot>
+
|Gives a 'distanceRemaining'-reply with how much is left of the currently planned movement.
+
|'''Yes'''
+
!style="background-color: #55ff55"|Yes
+
|-
+
|getGunHeat <bot>
+
|Gives a 'getGunHeat'-reply with how many seconds are left of the gun cooldown.
+
|'''Yes'''
+
!style="background-color: #55ff55"|Yes
+
|-
+
|getTickDuration <bot>
+
|Gives a 'getTickDuration'-reply with how many seconds makes up one tick.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|getTickRemaining <bot>
+
|Gives a 'getTickRemaining'-reply with how many seconds are left of this tick.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|getTurnRemaining <bot>
+
|Gives a 'getTurnRemaining'-reply with how much is left of the currently planned turn.
+
|'''Yes'''
+
!style="background-color: #55ff55"|Yes
+
|-
+
|mytanks
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|obstacles
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|othertanks
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setAhead <bot> <distance>
+
|Sets planned movement (for next 'execute'-s) that moves 'distance' units.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setFire <bot>
+
|Sets a planned shot (for next 'execute')
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setResume <bot>
+
|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. (If you call setAhead, setTurn etc before this, they will be overwritten unless setResume fails)
+
|No
+
!style="background-color: #ff3333"|No
+
|-
+
|setStop <bot> <overwrite>
+
|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.)
+
|No
+
!style="background-color: #ff3333"|No
+
|-
+
|setSpeed <bot> <factor>
+
|Sets next actions speed, value between 0 and 1.0. (for future 'execute'-s)
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setTickDuration <bot> <seconds>
+
|Sets the duration of a tick, in seconds.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setTurnLeft <bot> <degrees>
+
|Sets planned turn (for next 'execute'-s) that turns 'degrees' degrees to the left.
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|setTurnRate <bot> <factor>
+
|Sets next actions turnrate, value between 0 and 1.0. (for next 'execute'-s)
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|shots
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|-
+
|teams
+
|<explain>
+
|No
+
!style="background-color: #55ff55"|Yes
+
|}
+
  
=See Also=
+
==Legacy==
[[BZRobots/About]] - Project Overview
+
Eventually, in an effort to simplify the internals of BZRobots, the "frontend" and "backend" will likely be altogether removed, thereby eliminating the internal protocol. It is recommended to develop bots in C or Python using the published API, rather than attempting to develop a seperate client for the BZRobot backend.
 
+
[[BZRobots/Ideas]] - Feature suggestions / thoughts
+

Latest revision as of 06:14, 4 August 2009

Overview[edit]

This page describes the BZRobots Enhanced Protocol that forms the internals of the BZFlag Programmable Computer Player Client

Description[edit]

The BZRobots client currently consists of two parts called the "backend" and the "frontend". The "backend" is a lightweight game client that communicates with BZFS. It also runs a lightweight line-by-line text-based server, on which commands can be sent to control a robot. The "frontend" is an instance of a BZAdvancedRobot, including the necessary parts to communicate with the "backend".

Available Commands[edit]

See the BZRobots/API for the commands currently available to the BZRobots protocol.

Legacy[edit]

Eventually, in an effort to simplify the internals of BZRobots, the "frontend" and "backend" will likely be altogether removed, thereby eliminating the internal protocol. It is recommended to develop bots in C or Python using the published API, rather than attempting to develop a seperate client for the BZRobot backend.