Module Contents

class PatrollingAgentBrain(waypoints, move_speed=0)

Bases: matrx.agents.AgentBrain

A simple agent that moves along a given path.


Resets the agent’s to be visited waypoints.

This method is called each time a new world is created or the same world is reset. This prevents the agent to remember that it already moved and visited some waypoints.

filter_observations(self, state)

Instead of filtering any observations, it just returns the given state.

This means that the agent has no fancy observation mechanisms.


The state object already filtered on the sensing range of the agent.


The unchanged State instance.

decide_on_action(self, state)

Makes use of the navigator to decide upon the next move action to get one step closer to the next waypoint.


The State instance returned from filter_observations. In the case of this agent, that is the unchanged instance from the grid world who filtered only on the sensing range of this agent.


The name of the next action.


A dictionary containing any additional arguments for the action to perform. This agent provides the duration how long its move action should take.


Provides a dictionary of data for any Logger

This method functions to relay data from an agent’s decision logic (this AgentBrain class) through the GridWorld into a Logger. Here it can be further processed and stored.


A dictionary with keys identifiable names and the data as its value.

send_message(self, message)

Sends a Message from this agent to others

Method that allows you to construct a message that will be send to either a specified agent, a team of agents or all agents.


A message object that needs to be send. Should be of type Message. It’s to_id can contain a single recipient, a list of recipients or None. If None, it is send to all other agents.

is_action_possible(self, action, action_kwargs)

Checks if an action would be possible.

This method can be called from the AgentBrain to check if a certain action is possible to perform with the current state of the GridWorld. It requires as input an action name and its arguments (if any), same as the decide_on_action method should return.

This method does not guarantees that if the action is return by the brain it actually succeeds, as other agents may intervene.


The name of an Action class.


A dictionary with keys any action arguments and as values the actual argument values.


True if the action can be performed, False otherwise.


An ActionResult object containing the success or failure of the action, and (if failed) the reason why.

create_context_menu_for_other(self, agent_id_who_clicked, clicked_object_id, click_location)

Generate options for a context menu for a specific object/location that a user NOT controlling this human agent opened.

Thus: another human agent selected this agent, opened a context menu by right clicking on an object or location. This function is called. It should return actions, messages, or other info for what this agent can do relevant to that object / location. E.g. pick it up, move to it, display information on it, etc.

Example usecase: tasking another agent that is not yourself, e.g. to move to a specific location.

For the default MATRX visualization, the context menu is opened by right clicking on an object. This function should generate a list of options (actions, messages, or something else) which relate to that object or location. Each option is in the shape of a text shown in the context menu, and a message which is send to this agent if the user actually clicks that context menu option.


The ID of the (human) agent that selected this agent and requested for a context menu.


A string indicating the ID of an object. Is None if the user clicked on a background tile (which has no ID).


A list containing the [x,y] coordinates of the object on which the user right clicked.


A list containing context menu items. Each context menu item is a dict with a ‘OptionText’ key, which is the text shown in the menu for the option, and a ‘Message’ key, which is the message instance that is sent to this agent when the user clicks on the context menu option.