thebotslam

How do I find enemies with the scanner?

Search, then lock on

from bot import Chassis, Scanner, wait

chassis = Chassis(0)
scanner = Scanner(1)

sweep = 0
while True:
    if scanner.ping(0):
        b = scanner.bearing(0)
        scanner.sense = b      # keep the arc on it
        log("contact @ {}", b)
    else:
        sweep += 30            # nothing: look at the next 30 degrees
        if sweep >= 180:
            sweep -= 360
        scanner.sense = sweep
    wait()

Moving the arc 30° a tick covers the whole circle in 12 ticks, a little over half a second.

What the scanner tells you

Friend, foe or wall?

A contact is anything solid in line of sight within 30 m: an enemy, a teammate, a block or a wall. Some ways to tell them apart:

Tips