thebotslam

How do my bots share information with their teammates?

The radio

A radio is a part (3 kg) that goes on the spare mount, so in the standard loadout it's channel 3. Each teammate needs one too.

from bot import Scanner, Radio, cpu, wait

scanner = Scanner(1)
radio = Radio(3)
SEEN = 1  # the team's code for "I see something"

while True:
    x, y, z = radio.read()
    if scanner.ping(0) and cpu.tick % 10 == 0:
        radio.send(SEEN, x, y, scanner.bearing(0))
    m = radio.receive()
    if len(m) == 4 and m[0] == SEEN:
        log("teammate at {}, {} sees something at {}", m[1], m[2], m[3])
    wait()

What the numbers mean is up to your team. A good habit: make the first number say what kind of message it is.

The team notepad

The notepad needs no part: import it with from bot import notepad. There are no strings, so characters are numbers, their codes: ord("A") is 65.

from bot import notepad, wait

while True:
    if notepad.char(0) == ord("B"):
        log("plan B")
    wait()

Which to use?

Use the radio for things that change fast: positions and targets. Use the notepad for slower shared state, and anything to keep for the next match. It costs cycles (about 25 a character read, up to 360 to write a number), so keep it short.