Skip to main content

Helper classes for the Team Match Communication Protocol.

Project description


Helper classes for the Team Match Communication Protocol

Learn more about TMCP.

How to use

Start by creating an instance of the TMCPHandler. You should pass in your agent.

from tmcp import TMCPHandler

class MyBot(BaseAgent):
    def initialize_agent(self):
        self.tmcp_handler = TMCPHandler(self)

Usage is also very straightforward:

from tmcp import TMCPMessage, ActionType

    def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
        # Receive and parse all new matchcomms messages into TMCPMessage objects.
        new_messages: List[TMCPMessage] = self.tmcp_handler.recv()
        # Handle TMCPMessages.
        for message in new_messages:
            if message.action_type == ActionType.BALL:

        # You can send messages like this.

        # Or you can create them and send them more directly:
        my_message = TMCPMessage.ball_action(, self.index, estimated_time_of_arrival)

The handler will throttle your messages if you send them too quickly. If you want to make sure all of your messages are sent, you can create a backlog like this:

# During initialization, create a backlog list.
self.backlog = []

# Sending returns false if a message was not sent.
if not self.tmcp_handler.send(message):

# In your main loop, check whether you have any messages in the backlog.
if self.backlog:
    backlog_message = self.backlog.pop(0)
    # Try sending the message again. If it doesn't work, return it to the backlog.
    if not self.tmcp_handler.send(backlog_message):
        self.backlog.insert(0, backlog_message)

Avoiding breaking changes

This package is regularly updated according to the latest TMCP specification. To avoid your bot breaking during tournaments, you can use a virtual_environment and pin a specific version of this package.

In your requirements.txt:


In your bot.cfg:

use_virtual_environment = true
requirements_file = ./requirements.txt

If you don't want to do this, you can also disable the handler if a different version of the package is used. This will not send or receive any messages, but will pretend as if it was sending all and receiving none.

from tcmp import TCMP_VERSION

if TCMP_VERSION != [0, 7]:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tmcp, version 0.7.3
Filename, size File type Python version Upload date Hashes
Filename, size tmcp-0.7.3.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page