pymasep.communication.message ============================= .. py:module:: pymasep.communication.message Classes ------- .. autoapisummary:: pymasep.communication.message.Message Module Contents --------------- .. py:class:: 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 :param msg_type: type of message. See above. :param param_dict: Parameters of the message. May be None. :param src_sub_app_id: SubApplication id that send the message. .. py:attribute:: MESSAGE_TYPE_DEFINE :value: 'define' I -> E : Init the initial state .. py:attribute:: MESSAGE_TYPE_OBSERVATION :value: 'observation' E -> I : Observation .. py:attribute:: MESSAGE_TYPE_ACTION :value: 'action' I -> E : Action .. py:attribute:: MESSAGE_TYPE_QUIT_GAME :value: 'quit' I -> E : Game is finished (by user) .. py:attribute:: MESSAGE_TYPE_REGISTER :value: 'register' I -> E : Register interface to engine .. py:attribute:: MESSAGE_TYPE_END_GAME :value: 'end' E -> I : Game is finished (by engine) .. py:attribute:: msg_type type of the message. See MESSAGE_TYPE_* .. py:attribute:: params parameter of the message .. py:attribute:: src_sub_app_id id of the sub application (interface or engine) source of the message .. py:method:: to_xml() Transform the Message to XML. :return: XML version of the Message .. py:method:: from_xml(xml_node) Transform an XML to a Message. The instance must be created before :param xml_node: The XML node containing the Message .. py:method:: __eq__(other) Check if two messages are equals :return: True if two messages are equals .. py:method:: __str__() Transform the message to string containing the XML version of the message :return: A string representing the XML version of the message .. py:method:: to_bytes() Transform the message to bytes :return: The message as bytes .. py:method:: from_bytes(b) Transform bytes to a message. :param b: Bytes string representing XML