pymasep.common.intention

Classes

Intention

An intention is a desired action. This class stores all intentions of an agent

Module Contents

class pymasep.common.intention.Intention(environment, name=None, parent=None, xml_node=None, template=None, src_copy=None)

Bases: pymasep.common.base_object.BaseObject

An intention is a desired action. This class stores all intentions of an agent

The intention is attached to the agent when it has been validated by the game rules.

Parameters:
  • environment – the environment

  • name (Optional[str]) – name of the BaseObject

  • xml_node (Optional[xml.etree.ElementTree.Element]) – XML used to create the object.

  • template – Template of the base object. Needed if no xml_node.

  • parent – Parent object (see objects hierarchy)

  • src_copy (Optional[Intention]) – The Intention to copy. Needed if no xml_node or template. The copy is not made into the constructor.

Raises:

pymasep.common.exception.CreationException – If no XML or no template or src_copy is present

name: str = 'intention'

the name of the object intention

intentions = []

list of intentions. The order reflects the desired order of the agent

state: str = 'run'

State of the BaseObject. None if the object is just created. “Init” if it misses something (input from user) to finish the creation. “Run” is the BaseObject is operational.

Returns:

The state of the BaseObject

add_intention(intention)

add an intention to the agent intentions list

Parameters:

intention (pymasep.common.action.Action) – the intention (an action) to add

Return type:

None

id_str()

Create an str unique ID of the Intention.

Returns:

the string unique ID

Return type:

str

to_xml()

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

Returns:

XML version of the Intention

Return type:

xml.etree.ElementTree.Element

from_xml(environment, xml_node)

Transform an XML to an Intention. The instance must be created before (with __init__(), passing the xml_node). See Serialization for more information.

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

  • xml_node (xml.etree.ElementTree.Element) – The XML node that contains the intention data.

Return type:

None

copy_obs(params)

Deep copy the Intention to a new instance.

Parameters:

params (dict) – Not used in this method.

Note : this method copy the reference of the parent. The parent should do the parent copy and assignment