matrx.agents.agent_utils.state_tracker

Module Contents

class StateTracker(agent_id, knowledge_decay=10, fov_occlusion=True)

The tracker of agent observations over ticks.

Deprecated since version 2.0.7: StateTracker will be removed in a future MATRX version where it will be fully replaced by State.

set_knowledge_decay(self, knowledge_decay)

Sets the number of ticks the tracker should memorize unobserved objects.

Parameters
knowledge_decayint

The number of ticks an unobserved object is memorized.

get_memorized_state(self)

Returns the memorized state so far.

Returns
dict

The dictionary containing all current and memorized observations.

update(self, state)

Updates this tracker with the new observations.

This method also removes any past observations that are needed to be forgotten by now.

Parameters
statedict

The state dictionary containing an agent’s current observations.

Returns
dict

The dictionary containing all current and memorized observations.

get_traversability_map(state=None, inverted=True)

Returns a map where the agent can move to. Traversability is binary.

This map is based on the provided state dictionary that might represent the observations of an agent. Since these observations can be limited in sense of range and accuracy, the map might not be truthful to what is actually possible. This mimics the fact that an agent only knows what it can observe and infer from those observations.

Parameters
invertedbool (Default: False)

Whether the map should be inverted (signalling where the agent cannot move to).

statedict

The dictionary representing the agent’s (memorized) observations to be used to create the map.

Returns
array

An array of shape (width,height) equal to the grid world’s size. Contains a 1 on each (x,y) coordinate where the agent can move to (a 0 when inverted) and a 0 where it cannot move to (a 1 when inverted).

list

A list of lists with the width and height of the gird world as size. Contains on each (x,y) coordinate the object ID if any according to the provided state dictionary.

get_weighted_traversability_map(state=None)

Returns a weighted map where the agent can move to.

This map is based on the provided state dictionary that might represent the observations of an agent. Since these observations can be limited in sense of range and accuracy, the map might not be truthful to what is actually possible. This mimics the fact that an agent only knows what it can observe and infer from those observations. Traversability is weighted based on the the traversability of that object, and in addition the traversability_penatly property (if available) which describes the (speed) penatly of moving over this object. The traversability_penatly is between 0 (no penalty) and 1 (max penalty)

Parameters
invertedbool (Default: False)

Whether the map should be inverted (signalling where the agent cannot move to).

statedict

The dictionary representing the agent’s (memorized) observations to be used to create the map.

Returns
array

An array of shape (width,height) equal to the grid world’s size. Contains a 0 on each (x,y) coordinate where the agent can move to 1 where it cannot move to. Contains any integer between 0 and 1 that indicates a preference.

list

A list of lists with the width and height of the gird world as size. Contains on each (x,y) coordinate the object ID if any according to the provided state dictionary.