pymasep.common.action

Classes

Action

This class represents an action that can be done by an agent.

Module Contents

class pymasep.common.action.Action(environment, action_type=None, xml_node=None, src_copy=None)

This class represents an action that can be done by an agent.

Parameters:
  • environment – the environment where the action is created.

  • action_type (Optional[int]) – Type of the action. None, if xml_node.

  • xml_node (xml.etree.ElementTree.Element) – XML used to create the Action.

  • src_copy (Optional[Action]) – The Action will be copied. See copy_obs().

Raises:

pymasep.common.exception.CreationException – Raised when xml_node, action_type and src_copy are None.

environment
type: int | None

type of the action. May be initialized later if the action is created from xml

params

parameters of the actions

add_parameter(name, value)

Add a parameter to the action.

Parameters:
  • name (str) – Name of the parameter.

  • value (Any) – Value of the parameter. Must be XML serializable.

Return type:

None

id_str()

Create a string unique ID of the Action. Depends on the content of the Action (parameters).

Returns:

The string unique ID

Return type:

str

to_xml()

Transform the Action to XML. See Serialization for more information.

Returns:

XML version of the Action

Return type:

xml.etree.ElementTree.Element

from_xml(environment, xml_node)

Transform an XML to an Action. The instance must be created before. See Serialization for more information.

Parameters:
  • environment – The environment where the Action is created.

  • xml_node (xml.etree.ElementTree.Element) – The XML node that contains the Action values and parameters.

Return type:

None

__str__()
Return type:

str

copy_obs(params)

Deep copy an action into a new instance (with its parameters).

Parameters:

params (dict) – Not directly used in this method but passed to the action parameters copy.