def run(self): ''' here's what really matters... ''' print "STARTING run() - AlgorithmAiming" commands = Command(self.client_token) stop = False while not stop: if self.game_state is None: print "GAME STATE IS NONE!!!!" continue self.copy_real_game_state() if self.game_state.fast_exists() and not self.game_state.enemies_exist(): stop_command = commands.getStopCommand( self.game_state.get_fast_tank_id(), 'FIRE', ) self.send_command(stop_command) if self.game_state.slow_exists() and not self.game_state.enemies_exist(): stop_command = commands.getStopCommand( self.game_state.get_slow_tank_id(), "FIRE", ) self.send_command(stop_command) if self.game_state.fast_exists(): distance_to_target, position_of_target = self.game_state.get_closest_enemy_to_fast() # get the turret rotation #target_point = self.game_state.get_target_point_for_tank_at_for_fast(position_of_target) turret_angle = self.__get_target_angle(self.game_state.get_position_for_fast_exact(), position_of_target) change_turret_angle = turret_angle - self.game_state.get_fast_tank_turret_angle() turret_rotate_command = commands.getTurretRotateCommand( self.game_state.get_fast_tank_id(), change_turret_angle ) self.send_command(turret_rotate_command) # send the fire command if self.game_state.enemies_exist() and change_turret_angle < math.pi / 6: tank_fire_command = commands.getFireCommand(self.game_state.get_fast_tank_id()) else: # stop the fire command!!! tank_fire_command = commands.getStopCommand( self.game_state.get_fast_tank_id(), 'FIRE', ) self.send_command(tank_fire_command) tank_forward_command = commands.getMoveCommand( self.game_state.get_fast_tank_id(), 10, direction="FWD" ) #print "SENDING: " + str(tank_forward_command) self.send_command(tank_forward_command) # go forward if self.game_state.slow_exists(): distance_to_target, position_of_target = self.game_state.get_closest_enemy_to_slow() # get the turret rotation #target_point = self.game_state.get_target_point_for_tank_at_for_slow(position_of_target) turret_angle = self.__get_target_angle(self.game_state.get_position_for_slow_exact(), position_of_target) change_turret_angle = turret_angle - self.game_state.get_slow_tank_turret_angle() turret_rotate_command = commands.getTurretRotateCommand( self.game_state.get_slow_tank_id(), change_turret_angle ) self.send_command(turret_rotate_command) # send the fire command if self.game_state.enemies_exist() and change_turret_angle < math.pi / 6: tank_fire_command = commands.getFireCommand(self.game_state.get_slow_tank_id()) else: tank_fire_command = commands.getStopCommand( self.game_state.get_slow_tank_id(), "FIRE" ) self.send_command(tank_fire_command) tank_forward_command = commands.getMoveCommand( self.game_state.get_slow_tank_id(), 10, direction="FWD" ) #print "SENDING: " + str(tank_forward_command) self.send_command(tank_forward_command)