pymasep.common.state ==================== .. py:module:: pymasep.common.state Classes ------- .. autoapisummary:: pymasep.common.state.State Module Contents --------------- .. py:class:: State(environment, name = None, parent = None, xml_node = None, template=None, src_copy = None) Bases: :py:obj:`pymasep.common.base_object.BaseObject` State or Observation of the environment :param environment: an Environment instance :param name: name of the Agent. :param xml_node: XML used to create the state. :param template: Template of the state. Needed if no xml_node. :param parent: Parent object (see objects hierarchy) :param src_copy: The State to copy. Needed if no xml_node or template. The copy is not made into the constructor. :raise pymasep.common.exception.CreationException: If no XML or no template or src_copy is present .. py:attribute:: agents :type: Set[pymasep.common.agent.Agent] set of agent in the state. Can be different from the environment if the state is a partial observation .. py:attribute:: objects Objects in the state .. py:attribute:: is_final :type: bool :value: False is the state final of an episode? .. py:attribute:: step :type: int :value: 0 current step of the episode. .. py:method:: state() State of the State (hum...). "Init" if one of its objects is in init state. :return: The state of the Object .. py:method:: id_str() Create a string unique ID of the State. Depends on the content of the base object and the id_str of all objects in the state :return: The string unique ID .. py:method:: __eq__(other) Test the equality of two states. Two states are equals if they have the same type and their id_str() are equals. Note : in some extreme cases, two different states can have the same id_str() but should not be equals. This case may occur, for example, with characteristic name `Name` and `Name0` with `Name='00'` and `Name0='0'`. But you have to have a twisted mind to model the state this way. Please don't :) The code will remain simpler :) .. py:method:: add_object(obj) Add an object into the state. The object is added in self.agents if the object is an Agent :param obj: Object to add into state. .. py:method:: to_xml() Transform the State to XML.z See :ref:`serialization` for more information. :return: XML version of the State .. py:method:: from_xml(environment, xml_node) Transform an XML to a State. The instance must be created before (with __init__(), passing the xml_node). See :ref:`serialization` for more information. :param environment: The environment where the State is created. :param xml_node: The XML node that contains the State data. :raise pymasep.common.exception.CreationException: SubElement must be present if initializer is not present. At creation, Initializer must be present for all characteristics if initializer is not present for ObjectState .. py:method:: copy_obs(params) Deep copy the State to a new instance. :param params: Not used in this method.