Exemplo n.º 1
0
    def __init__(self, match_id: int):
        ''' Calls the API and creates a match representation from result.

        Args:
            match_id: Dota match ID
        '''

        if not isinstance(match_id, int):
            raise TypeError('`match_id` must have type int.')
        else:
            self.id = match_id

        response = api.get_match_details(match_id=match_id)

        # TODO: check supported modes, rewrote this
        if response['game_mode'] != 2 and response['game_mode'] != 16:
            raise NotImplementedError(
                'Sorry, Match currently' +
                ' does not support {}'.format(response['game_mode_name']) +
                ' game mode.')

        self.radiant = Heroes()
        self.dire = Heroes()
        self.radiant_win = response['radiant_win']

        # select picks and add heroes to appropriate teams
        for pick in filter(lambda x: x['is_pick'], response['picks_bans']):
            if pick['team'] == 0:
                self.radiant.add(Hero(pick['hero_id']))
            else:
                self.dire.add(Hero(pick['hero_id']))
Exemplo n.º 2
0
                hero1, hero2 = sorted([next_hero_id, picked_hero])
                total_connection += winrate.loc[hero1][hero2]

            for enemy in against:
                total_connection -= lose_rate.loc[next_hero_id][enemy]

            if total_connection > best_connection:
                best_hero = next_hero_id
                best_connection = total_connection

    return best_hero.item()


# In[25]:

pick = Heroes()
pick.add(Hero.from_name(''))

ban = Heroes()
ban.add(Hero.from_name('Shadow Fiend'))
ban.add(Hero.from_name('Invoker'))

against = Heroes()
against.add(Hero.from_name('Slardar'))
against.add(Hero.from_name('Witch Doctor'))

while len(pick) < 5:
    next_hero = get_next_hero(list(pick.get_ids()),
                              ban=list(ban.get_ids()),
                              against=list(against.get_ids()))
    pick.add(Hero(next_hero))