Skip to content

Instantly share code, notes, and snippets.

@Debilski
Created May 30, 2012 21:55
Show Gist options
  • Save Debilski/2839185 to your computer and use it in GitHub Desktop.
Save Debilski/2839185 to your computer and use it in GitHub Desktop.
Pelita network spec

Pelita network messaging specification

Message format

A message is always sent as a JSON object. The following keys are allowed and denote different types of messages.

Request message

The combination of keys __uuid__, __action__, __data__ specifies a request. A request expects reply with the same __uuid__ value to be returned in a certain time frame.

Reply message

The combination of keys __uuid__, __return__ specifies a reply to the message with the same __uuid__ value. There may not be more than one reply for a given request.

Notification message

The combination of key __action__, __data__ specifies a notification. A notification message is therefore identical to a request message but lacks the __uuid__ attribute.

Error message

Currently not specified.

Values

  • __uuid__: string, which is supposed to be unique for each request. The current de-facto implementation uses random UUIDs for this purpose; advanced schemes might also include some address specification.

  • __action__: string, specifies the action to be taken.

  • __data__: object, specifies named arguments for a given __action__. If missing, it is assumed to be {}.

  • __return__: unrestricted.

Timeouts

Each request must be replied to in a certain time frame. If no reply is received, the server may raise an exception and any later replies with the specified __uuid__ will be ignored.

Error handling

Currently not specified.

Messages

team_name, request

  • __data__: {}
  • __reply__: string, the name of the team.

set_initial, request

  • __data__: {team_id: , universe:}
  • __reply__: null, reply needed for synchronisation.

get_move, request

  • __data__: {bot_id:, universe:}
  • __reply__: array, specifying the movement vector [dx, dy].

exit, notification

  • __data__: {}

observe, notification

  • __data__: TODO

Data formats

universe

  • TODO

bot_id

  • integer
@Debilski
Copy link
Author

strings should be unicode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment