A manager inside the GirdWorld that tracks the received and send messages between agents and their teams.
This provides several advantages: - an easier connection between MATRX Core, MATRX API, and the Front-end for messages (e.g. to differentiate between messages send between agents and to teams in the Front-end through a simple api call: ‘get_team_messages’). - an easy way to log communication (as the messages are easily obtained from a GridWorld instance, through some methods).
preprocess_messages(self, tick, messages, all_agent_ids, teams)¶
Preprocess messages for sending, such that they can be understood by the GridWorld.
- For example: if the receiver=None, this means it must be sent to all agents. This function will process
the receiver=None to a seperate message directed at every agent.
Current tick of the gridworld
All messages sent from the agent brains in the gridworld, and received via the api
IDs of all the agents
fetch_chatroom_ID(self, chatroom_type, agent_IDs=, team_name=False)¶
Fetch the ID of a chatroom using various bits of info
Either “private” for private charooms send between 2 agents, or “team” for messages between teams.
- agent_IDslist (optional)
List of the agent IDs part of that chatroom
- team_namestr (optional)
The name of the team, which is used as chatroom name
Fetch all the chatrooms, or only those of which a specific agent is part.
- agent_idstr (optional, default, None)
ID of the agent for which to fetch all accessible chatrooms. if None, all chatrooms are returned.
A dictionary containing a list with all “private” chatrooms, all “teams” chatrooms, and a “global” key, accessible via likewise named keys.
fetch_messages(self, agent_id=None, chatroom_mssg_offsets=None)¶
Fetch messages, optionally filtered by start tick and/or agent id.
- agent_idstring (optional, default=None)
Only messages received by or sent by this agent will be collected. If none, all messages will be returned.
- chatroom_mssg_offsets: dict (optional, default=None)
A dict of chat IDs, with for each ID from which message onward to send new messages.
Dictionary with as key the chatroom IDs, followed by the chatroom objects containing among others the chatroom messages.
copy_message(self, mssg, from_id, to_id)¶
Copy a message while keeping the potentially custom message type and custom message properties. Global and team messages have to be subdivided into individual messages for each receiving agent. This function copies a message while paying attention to any custom message classes used and their custom properties, in addition to making sure the message has a unique message ID.
original message instance. Can be the default Message() class, or a class that inherits from it.
the new sender ID.
the new receiver ID.
the new message instance with the same class and custom properties as mssg, with the provided from_id and to_id.