Skip to main content

tmcp

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:
                print(message.time)
        
        ...

        # You can send messages like this.
        self.tmcp_handler.send_boost_action(pad_index)

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

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):
    self.backlog.append(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 major breaking changes

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

In your requirements.txt:

tmcp==1.*

In your bot.cfg:

[Locations]
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 tmcp import TMCP_VERSION

if TMCP_VERSION[0] != 1:
    my_handler.disable()

Metadata

Release files for tmcp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tmcp 1.0.0
File Size Uploaded Provenance
tmcp-1.0.0.tar.gz 5.9 kB Without provenance Details

Release files / tmcp-1.0.0.tar.gz

Download URL tmcp-1.0.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5817eea9ed0f3e69c00d20a0efbe00fe0d64acb74063a033f92f4d9ed91044f9
BLAKE2b-256 checksum
How to use checksums
19aad2481b6f76ad46b96de416cdcdb9b2c23888c5a23da312fced8fe65edb19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.7

Security for tmcp 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page