pymasep.common.agent
Classes
Agent that act inside the environment |
Module Contents
- class pymasep.common.agent.Agent(environment, name=None, parent=None, template=None, xml_node=None, src_copy=None)
Bases:
pymasep.common.object.ObjectAgent that act inside the environment
- Parameters:
environment – an Environment instance
name (str) – name of the Agent.
xml_node (Optional[xml.etree.ElementTree.ElementTree]) – XML used to create the agent.
template – Template of the agent. Needed if no xml_node.
parent – Parent object (see objects hierarchy)
src_copy (Optional[Agent]) – The Agent to copy. Needed if no xml_node or template. The copy is not made into the constructor, see copy_obs()
- Raises:
pymasep.common.exception.CreationException – If no XML or no template is present
- action = None
next action of the agent
- observation = None
current observation of the agent
- reward = None
current reward of the agent, if pertinent
- controller = None
controller of the agent
- control = None
sub app id that control the agent (an interface or the engine)
- intention = None
current intention of the agent
- belief
belief of the agent
- choose_action()
Choose the next action of the agent using its controller
- Return type:
None
- set_observation_reward(observation, reward=None)
Set the observation and the reward of the agent.
- Parameters:
observation – Observation of the agent (as a State)
reward (Optional[pymasep.utils.Any]) – reward of the agent.
- Return type:
None
- id_str()
Create a string unique ID of the Agent. Depends on the content of the base object and the id_str of all characteristics in object_state, and the intention of the agent
- Returns:
The string unique ID
- Return type:
str
- to_xml()
Transform the Agent to XML. See Serialization for more information. :return: XML version of the Agent
- Return type:
xml.etree.ElementTree.Element
- from_xml(environment, xml_node)
Transform an XML to an Agent. The instance must be created before (with __init__(), passing the xml_node). See Serialization for more information.
- Parameters:
environment – The environment where the Agent is created.
xml_node (xml.etree.ElementTree.Element) – The XML node containing the Agent content.
- Raises:
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
- Return type:
None
- copy_obs(params)
Deep copy the agent into a new instance (with sub BaseObjects, except the Belief)
- Parameters:
params (dict) – The agent needs the full name of the agent that observes (key: obs_agt_fname)
Note : this method copy the reference of the parent. The parent should do the parent copy and assignment. Belief is the same (same reference) in the observation (for the agent that observes) and in the state.