identify which players are agents (not observers or computers). Errors if flattened.
515621
def agents(self):
        """"""
        ret = []
        for player in self.players:
            if player.isComputer: continue
            try:
                if player.observer: continue
            except: pass
            ret.append(player)
        return ret
1242372
def ignore_user_agent(user_agent):
    
    if user_agent:
        for ua in MOBI_USER_AGENT_IGNORE_LIST:
            if ua and ua.lower() in user_agent.lower():
                return True
    return False
1213075
def list_agents(self):
        ''''''
        t = text_helper.Table(fields=("Agent ID", "Agent class", "State"),
                              lengths=(40, 25, 15))

        return t.render((a._descriptor.doc_id, a.log_category,
                         a._get_machine_state().name)
                        for a in self._agents)
1334315
def start_match(self):
        

        agent_configs_dict = {}
        loadout_configs_dict = {}
        for agent in self.agents:
            i, agent_config, loadout_config = agent.get_configs()
            agent_configs_dict[i] = agent_config
            loadout_configs_dict[i] = loadout_config
        agent_configs = {}
        loadout_configs = {}
        index = 0
        for i in range(MAX_PLAYERS):
            if i in agent_configs_dict:
                agent_configs[index] = agent_configs_dict[i]
                loadout_configs[index] = loadout_configs_dict[i]
                index += 1
        self.setup_manager = SetupManager()
        self.setup_manager.load_config(self.overall_config, self.overall_config_path, agent_configs, loadout_configs)
        self.setup_manager.connect_to_game()
        self.setup_manager.launch_ball_prediction()
        self.setup_manager.launch_quick_chat_manager()
        self.setup_manager.launch_bot_processes()
        self.setup_manager.start_match()
        self.launch_in_progress = False
        self.setup_manager.infinite_loop()
981303
def detectGamingHandheld(self):
        
        return UAgentInfo.devicePlaystation in self.__userAgent \
            and UAgentInfo.devicePlaystationVita in self.__userAgent
422638
function getPlayerCounters(player, attacker, game) {
  return player.hand
    .map((card) => {
      return card.validCounters ? card.validCounters(player, attacker, game) : []
    })
    .reduce((acc, array) => {
      return acc.concat(array)
    }, [])
    .sort((counterA, counterB) => counterB.weight - counterA.weight)
}
609143
def _verify_agents(self):
        
        #print('verifying...')
        nmes = []
        for agt_num, a in enumerate(self.agents):
            #print('agent#', agt_num, 'is type', type(a))
            nmes.append(a.name)
        if len(nmes) == len(set(nmes)):
            return True
        print('Error - you need to pass unique list of agent names to simulator')
        return False
841484
def next_player(self):
        
        logging.warning('turn={}, players={}'.format(
            self.game._cur_turn,
            self.game.players
        ))
        return self.game.players[(self.game._cur_turn + 1) % len(self.game.players)]
1251152
def team_players(self, team):
        """"""
        keys = 'shirtNumber name position nationality dateOfBirth'.split()
        data = [{key: player[key] for key in keys} for player in team]
        self.generate_output({'players': data})
16402
def inference(self, state_arr, limit=1000):
        '''
        
        '''
        self.__inferencing_flag = True

        agent_x, agent_y = np.where(state_arr[0] == 1)
        agent_x, agent_y = agent_x[0], agent_y[0]
        self.__create_enemy(self.__map_arr)
        result_list = [(agent_x, agent_y, 0.0)]
        result_val_list = [agent_x, agent_y]
        for e in range(self.__enemy_num):
            result_val_list.append(self.__enemy_pos_list[e][0])
            result_val_list.append(self.__enemy_pos_list[e][1])
        result_val_list.append(0.0)
        result_list.append(tuple(result_val_list))

        self.t = 0
        while self.t < limit:
            next_action_arr = self.extract_possible_actions(state_arr)
            next_q_arr = self.function_approximator.inference_q(next_action_arr)
            action_arr, q = self.select_action(next_action_arr, next_q_arr)
            self.__move_enemy(action_arr)

            agent_x, agent_y = np.where(action_arr[0] == 1)
            agent_x, agent_y = agent_x[0], agent_y[0]
            
            result_val_list = [agent_x, agent_y]
            for e in range(self.__enemy_num):
                result_val_list.append(self.__enemy_pos_list[e][0])
                result_val_list.append(self.__enemy_pos_list[e][1])
            try:
                result_val_list.append(q[0])
            except IndexError:
                result_val_list.append(q)

            result_list.append(tuple(result_val_list))

            # Update State.
            state_arr = self.update_state(state_arr, action_arr)

            # Epsode.
            self.t += 1
            # Check.
            end_flag = self.check_the_end_flag(state_arr)
            if end_flag is True:
                break

        return result_list
996742
def run(self):
        
        self.logger.debug('initializing agent')
        self.game_interface.load_interface()

        self.prepare_for_run()

        # Create Ratelimiter
        rate_limit = rate_limiter.RateLimiter(GAME_TICK_PACKET_POLLS_PER_SECOND)
        last_tick_game_time = None  # What the tick time of the last observed tick was
        last_call_real_time = datetime.now()  # When we last called the Agent

        # Get bot module
        agent, agent_class_file = self.load_agent()

        last_module_modification_time = os.stat(agent_class_file).st_mtime

        # Run until main process tells to stop, or we detect Ctrl+C
        try:
            while not self.terminate_request_event.is_set():
                self.pull_data_from_game()
                # game_tick_packet = self.game_interface.get
                # Read from game data shared memory

                # Run the Agent only if the game_info has updated.
                tick_game_time = self.get_game_time()
                should_call_while_paused = datetime.now() - last_call_real_time >= MAX_AGENT_CALL_PERIOD
                if tick_game_time != last_tick_game_time or should_call_while_paused:
                    last_tick_game_time = tick_game_time
                    last_call_real_time = datetime.now()

                    # Reload the Agent if it has been modified or if reload is requested from outside.
                    try:
                        new_module_modification_time = os.stat(agent_class_file).st_mtime
                        if new_module_modification_time != last_module_modification_time or self.reload_request_event.is_set():
                            self.reload_request_event.clear()
                            last_module_modification_time = new_module_modification_time
                            # Clear the render queue on reload.
                            if hasattr(agent, 'renderer') and isinstance(agent.renderer, RenderingManager):
                                agent.renderer.clear_all_touched_render_groups()
                            agent, agent_class_file = self.reload_agent(agent, agent_class_file)
                    except FileNotFoundError:
                        self.logger.error(f"Agent file {agent_class_file} was not found. Will try again.")
                        time.sleep(0.5)
                    except Exception:
                        self.logger.error("Reloading the agent failed:\n" + traceback.format_exc())
                        time.sleep(0.5)  # Avoid burning CPU / logs if this starts happening constantly

                    # Call agent
                    try:
                        self.call_agent(agent, self.agent_class_wrapper.get_loaded_class())
                    except Exception as e:
                        self.logger.error("Call to agent failed:\n" + traceback.format_exc())

                # Ratelimit here
                rate_limit.acquire()
        except KeyboardInterrupt:
            self.terminate_request_event.set()

        # Shut down the bot by calling cleanup functions.
        if hasattr(agent, 'retire'):
            try:
                agent.retire()
            except Exception as e:
                self.logger.error("Retiring the agent failed:\n" + traceback.format_exc())
        if hasattr(agent, 'renderer') and isinstance(agent.renderer, RenderingManager):
            agent.renderer.clear_all_touched_render_groups()
        # Zero out the inputs, so it's more obvious that the bot has stopped.
        self.game_interface.update_player_input(PlayerInput(), self.index)
        self.quick_chat_quit_event.set()  # Shut down quick chat.

        # If terminated, send callback
        self.termination_complete_event.set()
832810
def check_player_collision(self):
        """"""
        player_tiles = r.TileMapManager.active_map.grab_collisions(self.char.coords)
        enemy_tiles = r.TileMapManager.active_map.grab_collisions(self.coords)

        #Check to see if any of the tiles are the same. If so, there is a collision.
        for ptile in player_tiles:
            for etile in enemy_tiles:
                if r.TileMapManager.active_map.pixels_to_tiles(ptile.coords) == r.TileMapManager.active_map.pixels_to_tiles(etile.coords):
                    return True

        return False
134760
def get_agents(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.AgentList(self._results, runtime=self._runtime)
558818
def players_from_fantasypros_cheatsheet(file):
    

    with open(file, newline='') as csvfile:
        # Note - considered using a generator for this, but I don't want to hold the file open
        # for a long time and it's pretty small anyway.
        players = []
        playerindex = 0
        playerreader = reader(csvfile, delimiter=',')
        linecount = 0
        for row in playerreader:
            if linecount > 1:
                raw_name = row[0]
                name = raw_name[:raw_name.find('(') - 1]
                position_text = raw_name[raw_name.find('(') + 1:raw_name.find('-') - 1]
                position = Position[position_text]
                value = int(row[2].replace('$', ''))
                players.append(Player(name, position, value, linecount-2))
                playerindex += 1
            linecount += 1
    return players
1122413
def parse_player_info(self, player):
        
        if not player.ishltv:
            self.player_info[player.name] = {
                "user_id": player.userID,
                "guid": player.guid,
                "bot": player.fakeplayer,
            }
237172
def check_teams
      return if @teams.size == 0
      member = Hash.new
      @teams.each do |t|
        t.members.each do |m|
          raise "member #{m} of team '#{t.name}' is not a valid player number for this tournament" unless @player[m]
          raise "member #{m} of team '#{t.name}' is already a member of team #{member[m]}" if member[m]
          member[m] = t.name
        end
      end
      @player.keys.each do |p|
        raise "player #{p} is not a member of any team" unless member[p]
      end
    end
1132536
def teams(self):
        """"""
        teams = {}
        default_team = 1
        for i in range(1, self._header.replay.num_players):
            attributes = self._header.initial.players[i].attributes
            team = self._header.lobby.teams[i - 1]
            if team == 1:
                team = default_team
                default_team += 1
            if team not in teams:
                teams[team] = {'player_numbers': []}
            teams[team]['player_numbers'].append(attributes.player_color + 1)
        return list(teams.values())