pymasep.common.environment ========================== .. py:module:: pymasep.common.environment Classes ------- .. autoapisummary:: pymasep.common.environment.Environment Module Contents --------------- .. py:class:: Environment(id_env = None, cfg = None) Represents the environment of the game. This object keeps all dynamic value of the game. :param id_env: the id of the environment. If None, a new uuid will be set :parm cfg: the configuration of the environment .. py:attribute:: id :type: str Environment id. .. py:attribute:: config configuration of the environment. .. py:attribute:: end_episode :type: bool :value: False the current episode is finished .. py:attribute:: current_step :type: int :value: 0 current step of the environment .. py:attribute:: current_episode :type: int :value: 0 current episode of the environment .. py:attribute:: current_state :type: Optional[pymasep.common.state.State] :value: None current state of the environment .. py:attribute:: current_additional_info :type: dict current additional information of the environment, related to the current state. Sort of meta information on the current state .. py:attribute:: agents :type: Set[pymasep.common.agent.Agent] set of agents in the current state .. py:attribute:: controllers :type: Dict[str, pymasep.common.controller.Controller] set of controllers that can be used in the environment .. py:attribute:: _game :type: Optional[pymasep.common.game.Game] :value: None .. py:attribute:: next_action :type: Dict[str, pymasep.common.action.Action] next action to be executed in the current state .. py:attribute:: _level_logger .. py:attribute:: logger logger for the environment tasks .. py:method:: __del__() .. py:property:: game :type: pymasep.common.game.Game Game of the environment. .. py:method:: get_current_coord_method(state = None) Return the current coordination method according to the current game phase in the state :param state: State to check the coordination method. If None, take the current state of the environment. :return: The current coordinate method .. py:method:: get_observation_for_agent(agent) Get the current observation. Current state at the moment :param agent: The agent to get the observation for :return: The current observation .. py:method:: get_additional_info_for_agent() Get the current additional information. Could be filtered in the future (by agent) :return: The current additional information .. py:method:: get_reward_for_agent(agent) Get the current reward for an agent. :param agent: The agent to get the reward :return: The current reward of the agent .. py:method:: get_controller(agent_name, class_controller_) Get the controller of an agent. If the controller is not created, create it. (Maybe I should change the name of this method...) :param agent_name: The agent's name :param class_controller_: the class of the controller to create if it is not created :return: the instance of the agent's controller .. py:method:: calculate_end_episode() Calculate the end of the episode. Modify self.end_episode if the conditions of the episode's end are met. .. py:method:: calculate_next_state() Calculate the next state of the environment. Change the current state. Increase the step .. py:method:: calculate_reward() Calculate the reward from the current_state and add the result to additional info with key 'reward'. For MDP point of view, support only (at the moment) :math:`R(s)` and neither :math:`R(s,a)` nor :math:`R(s,a,s')` .. py:method:: create_base_object(name = None, template = None, xml_node = None, parent = None) Create a base object from a string represent the type :param name: The identification name of the BaseObject. :param template: Template of the created object. If None and no XML is specified, will be the default template for this bo_type :param xml_node: XML node used for creating the base object :param parent: the parent of the current object. May be None. :return: The BaseObject instance .. py:method:: get_type_controller(xml_node = None, template = None, control = None) Get the type of controller according to a template or (exclusive) an XML node. :param xml_node: XML node used to get the controller type. Use the attribute "controller". :param template: The template used to get the controller type. :param control: 'Interface' if the agent is controlled by interface (only inside engine, and if template is used) :return: the class of the controller to use .. py:method:: create_object(name = None, template = None, xml_node = None, parent = None, control = None) Create an object. Add it into the object dictionary (if not already exists) and agent set if the object is Agent :param name: The identification name of the object. Not used if xml_node is used :param template: the template of the class to create the object. Not used if xml_node is used :param xml_node: XML node describing the object to create :param parent: the parent of the current object. Maybe None :param control: 'interface' if the agent is controlled by interface (only inside engine and if template is used) :return: the object instance .. py:method:: create_action(action_type = None, xml_node = None) Create an action :param action_type: The type of the action (Constants in Action class) :param xml_node: XML to create Action :return: The Action created from XML or with just a type .. py:method:: choose_action() Tell all agents to choose their action .. py:method:: clear_all_state_elements() Clear all in the environment