def __init__(self): try: from debug_client import DebugClient except ImportError: # no debug module, maybe running on the russianaicup.ru server self.debug = None else: self.debug = DebugClient() self.green = Color(r=0.0, g=1.0, b=0.0)
class MyStrategy: #pylint: disable=old-style-class, too-few-public-methods ''' Main class defining the strategy ''' def __init__(self): try: from debug_client import DebugClient except ImportError: # no debug module, maybe running on the russianaicup.ru server self.debug = None else: self.debug = DebugClient() self.green = Color(r=0.0, g=1.0, b=0.0) def move(self, me, world, game, move): #pylint: disable=invalid-name """ @type me: Car @type world: World @type game: Game @type move: Move """ if self.debug: # call this the very first thing in your move() # to sync replays played in local runner and in repeater self.debug.syncronize(world) if self.debug: self.debug.use_tile_coords(game) with self.debug.pre() as dbg: dbg.fill_circle(100.0, 100.0, 50.0, (1.0, 0.0, 0.0)) # show the waypoints for idx, waypoint in enumerate(world.waypoints, 1): wayX, wayY = waypoint dbg.fill_rect(wayX, wayY, wayX + 1, wayY + 1, (0.9, 0.9, 0.9)) dbg.text(wayX + 0.5, wayY + 0.5, idx, (0.2, 0.5, 0.2)) self.debug.use_tile_coords(False) with self.debug.post() as dbg: dbg.circle(game.world_width * game.track_tile_size - 100, game.world_height * game.track_tile_size - 100, 50.0, self.green) dbg.text(me.x, me.y, 'wooo woo', (0.0, 0.0, 1.0)) move.engine_power = 1.0 move.throw_projectile = True move.spill_oil = True if world.tick > game.initial_freeze_duration_ticks: move.use_nitro = True
def __init__(self): self.reload = True self.freeze = False self.debug_client = DebugClient() self.input_event = EventEmitter() self.strategies = [] if sys.argv.__len__() == 4: self.remote_process_client = RemoteProcessClient( sys.argv[1], int(sys.argv[2])) self.token = sys.argv[3] else: self.remote_process_client = RemoteProcessClient( "127.0.0.1", 31001) self.token = "0000000000000000"
class MyStrategy: # pylint: disable=old-style-class, too-few-public-methods ''' Main class defining the strategy ''' def __init__(self): try: from debug_client import DebugClient # no debug module, maybe running on the russianaicup.ru server except ImportError: self.debug = None else: self.debug = DebugClient() self.green = Color(r=0.0, g=1.0, b=0.0) def move(self, me, world, game, move): # pylint: disable=invalid-name """ @type me: Car @type world: World @type game: Game @type move: Move """ if self.debug: self.debug.use_tile_coords(game) with self.debug.pre() as dbg: dbg.fill_circle(100.0, 100.0, 50.0, (1.0, 0.0, 0.0)) # show the waypoints for idx, waypoint in enumerate(world.waypoints, 1): wayX, wayY = waypoint dbg.fill_rect( wayX, wayY, wayX + 1, wayY + 1, (0.9, 0.9, 0.9)) dbg.text(wayX + 0.5, wayY + 0.5, idx, (0.2, 0.5, 0.2)) self.debug.use_tile_coords(False) with self.debug.post() as dbg: dbg.circle(game.world_width * game.track_tile_size - 100, game.world_height * game.track_tile_size - 100, 50.0, self.green) dbg.text(me.x, me.y, 'wooo woo', (0.0, 0.0, 1.0)) move.engine_power = 1.0 move.throw_projectile = True move.spill_oil = True if world.tick > game.initial_freeze_duration_ticks: move.use_nitro = True
import copy import random import math from collections import deque, namedtuple Squad = namedtuple('Squad', "id vehicle_types arena") import numpy as np from scipy.cluster.vq import kmeans2 as kmeans try: from debug_client import DebugClient except: debug = None else: debug = DebugClient() class Bfs: dr = [0, 0, 0, -1, 1] dc = [0, -1, 1, 0, 0] def in_corner(self, p): if p[0] == 1 or p[1] == 1: return False return True def check_done(self, ar): for unit in range(3): if not self.in_corner(ar[unit]): return False