pymasep.communication.message
Classes
Object send between thread or through network. |
Module Contents
- class pymasep.communication.message.Message(msg_type, param_dict, src_sub_app_id)
Object send between thread or through network.
DEFINE: Define the game used by the engine.
Param: ‘game’: name of the game class (doted path)
REGISTER: Register the interface.
Param: ‘id’: id of the interface, ‘queue_id’: id of the queue used by interface to receive messages, ‘role’: ‘InterfaceInfo.ROLE_OBSERVER’ interface is only observer, ‘InterfaceInfo.ROLE_ACTOR’ interface is actor
OBSERVATION: Observation sent by engine to interface,
Param: ‘observation’: State object, ‘additional_information’: dictionary containing additional information. Ex: ‘game_log’, ‘reward’
ACTION: Action sent by interface to engine
Param: ‘action’: Action object
END_GAME: Game is finished (by engine)
Param : None
QUI_GAME: Game is finished (by user)
Param : None
- Parameters:
msg_type (str) – type of message. See above.
param_dict (Optional[dict]) – Parameters of the message. May be None.
src_sub_app_id – SubApplication id that send the message.
- MESSAGE_TYPE_DEFINE = 'define'
I -> E : Init the initial state
- MESSAGE_TYPE_OBSERVATION = 'observation'
E -> I : Observation
- MESSAGE_TYPE_ACTION = 'action'
I -> E : Action
- MESSAGE_TYPE_QUIT_GAME = 'quit'
I -> E : Game is finished (by user)
- MESSAGE_TYPE_REGISTER = 'register'
I -> E : Register interface to engine
- MESSAGE_TYPE_END_GAME = 'end'
E -> I : Game is finished (by engine)
- msg_type
type of the message. See MESSAGE_TYPE_*
- params
parameter of the message
- src_sub_app_id
id of the sub application (interface or engine) source of the message
- to_xml()
Transform the Message to XML.
- Returns:
XML version of the Message
- Return type:
xml.etree.ElementTree.Element
- from_xml(xml_node)
Transform an XML to a Message. The instance must be created before
- Parameters:
xml_node (xml.etree.ElementTree.Element) – The XML node containing the Message
- Return type:
None
- __eq__(other)
Check if two messages are equals
- Returns:
True if two messages are equals
- Return type:
bool
- __str__()
Transform the message to string containing the XML version of the message
- Returns:
A string representing the XML version of the message
- Return type:
str
- to_bytes()
Transform the message to bytes
- Returns:
The message as bytes
- Return type:
bytes
- from_bytes(b)
Transform bytes to a message.
- Parameters:
b (bytes) – Bytes string representing XML
- Return type:
None