def attack_mode(self, env): if env.world.puck.owner_player_id is not None: return env.world.puck.owner_player_id == env.me.player_id nearest_hockeyist = shortcuts.nearest_unit( shortcuts.field_hockeyists(env), env.world.puck ) return nearest_hockeyist.player_id == env.me.player_id
def attack_without_puck(self, env): nearest_opponent = shortcuts.nearest_unit( shortcuts.opponent_field_hockeyists(env), env.me) distance = env.me.get_distance_to_unit(nearest_opponent) angle = env.me.get_angle_to_unit(nearest_opponent) if distance > env.game.stick_length: env.move.speed_up = 1.0 env.move.turn = angle if shortcuts.can_strike_unit(env, nearest_opponent): env.move.action = ActionType.STRIKE