#!/usr/bin/env python3

import sys

import bottisota
import bottisota.bot

controller = bottisota.bot.Controller()
controller.move_to(bottisota.ARENA_CENTER)

scn_direction = 0
scn_resolution = bottisota.SCN_RESOLUTION_MAX

while True:
    scn_distance, scn_idnum = controller.syscall_scn(scn_direction, scn_resolution)
    if scn_distance:
        scn_resolution //= 2
    elif scn_resolution == bottisota.SCN_RESOLUTION_MAX:
        scn_direction = (scn_direction + bottisota.SCN_RESOLUTION_MAX * 2) % 360
    else:
        scn_resolution = max(1, min(scn_resolution * 2, bottisota.SCN_RESOLUTION_MAX))
