Remote agent: Difference between revisions

Content added Content deleted
(Something I'm working on.)
 
(Define stream protocol.)
Line 57: Line 57:


== Commands ==
== Commands ==
=== ahead ===
=== forward ===
* Moves ahead one space. Costs one turn if successful.
* Moves ahead one space. Costs one turn if successful.
* Will respond with a 'color' event indicating the color property of the now-current sector.
* Will respond with a 'color' event indicating the color property of the now-current sector.
Line 112: Line 112:
=== 'agent full' ===
=== 'agent full' ===
* When sent, indicates that the agent already has a ball, and that a 'get' command failed.
* When sent, indicates that the agent already has a ball, and that a 'get' command failed.

= Stream Protocol =
The stream protocol is simple. Every command is a single byte sent from the agent to the simulator, no line feed, no carriage return. Every event is a single byte sent from the simulator to the agent, no line feed, no carriage return. For the sake of simplicity, all bytes fall within the range of [65,90], which corresponds to [A,Z] in ASCII, as well as in UTF-8.

== Greeting ==
The first byte is sent by the server to the agent, indicating that it's ready: '''A''' (65)

The second byte is sent by the agent to the server, indicating that it's ready: '''A''' (65)

The purpose of the handshake is to prevent the agent from sending commands before the server can service them, and to allow the server to identify which command set the agent intends to use. The former is important because I would like to eventually run the server via inetd on Rosetta Code's server, and I don't want to open myself up to an accidental DDOS if the server is under heavy load. The latter is important because I'd like to be able to do other things with the same port in the future, and the agent's reply byte differentiates this simulation game from others.

== Order of events ==
While all commands will trigger an event, the order that events are sent is undefined, with the exception that the '''stop''' event will signify that processing has finished; the '''stop''' event is the last event sent in response to ''any'' command, including any command that triggers the '''game over''' event.

== Commands and event codes ==

{|border=1
|-
|name||type||character||decimal||hex
|-
|'''f'''orward||command||F||70||0x46
|-
|c'''l'''ockwise||command||L||76||0x4C
|-
|c'''o'''unterclockwise||command||O||79||0x4F
|-
|'''g'''et||command|||G||71||0x47
|-
|'''d'''rop||command||D||68||0x44
|-
|'''g'''ame over||event||G||71||0x47
|-
|'''s'''top||event||S||83||0x53
|-
|'''c'''olor||event||C||67||0x43
|-
|'''b'''all||event||B||66||0x42
|-
|b'''u'''mp||event||U||85||0x55
|-
|'''n'''o ball in sector||event||N||78||0x4E
|-
|n'''o''' ball in agent||event||O||79||0x4F
|-
|sector '''f'''ull||event||F||70||0x46
|-
|agent f'''u'''ll||event||U||85||0x55
|}