Module Contents

class Capability

Denotes an capability of an agent.

Base class for agent capabilities.


Currently only used for the matrx.agents.capabilities.capability.SenseCapability. Might be extended in the future to include other type of capabilities.

class SenseCapability(detectable_objects)

Bases: matrx.agents.capabilities.capability.Capability

Denotes what an agent can see within a certain range.

An instance of this class describes to an agent what it can perceive within what ranges. It is used by a matrx.grid_world.GridWorld instance to construct the agent’s state.

To limit agents to sense objects more granulary then the given object types allow for, you can extend classes with your own classes. For example, one can extend the SquareBlock class into a custom class called MySquareBlock. This allows you to specify these two types separately to an agent for perception.


An example of a SenseCapability that defines the perception of all agents separate from SquareBlock objects. No other objects are perceived.

>>> from matrx.objects import AgentBody, SquareBlock
>>> SenseCapability({AgentBody: 10, SquareBlock: 25})

An example of a SenseCapability that sets the perception range of all objects.

>>> SenseCapability({None: 25})

An example of a SenseCapability that sets the range of perceiving all other agents to 25 but the perception of all other objects to 10.

>>> from matrx.objects import AgentBody
>>> SenseCapability({AgentBody: 25, None: 10})

Returns the sense capabilities.

sense_capabilities: dict

A dictionary with as keys the object types and values the distances.

The key None denotes all object types.

create_sense_capability(objects_to_perceive, range_to_perceive_them_in)

Creates a sense capability based that denotes what object types can be perceived from what range.


Various types of objects that the agent can perceive. An empty list is interpreted as all objects being detectable with infinite range by the agent.


The range for the object in objects_to_perceive from which the agent can perceive that object type. So range_to_perceive_them_in[4] denotes the range from which the agent can detect the object at objects_to_perceive[4].