From 727c447bfa8aaa3dc0a19fb041eced96ff2b7c13 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 10 Sep 2017 16:07:18 -0700 Subject: [PATCH 1/3] fixing an iteration issue --- app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index c44aa00..b642f9b 100644 --- a/app.py +++ b/app.py @@ -203,6 +203,7 @@ def build_team(summoner_data, picked_list, banned_list, generation_size): population = do_math.mutate(population, summoner_data, picked_list, banned_list) new_health = do_math.grade_generation(population) - dream_team = population[0] + sorted_end = [(do_math.fitness(candidate), candidate) for candidate in population] + sorted_end = [team_tuple[1] for team_tuple in sorted(sorted_end, reverse=True)] - return dream_team + return sorted_end[0] From c6d93b3754b702d7e50b71b61f10426a792dc63b Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 10 Sep 2017 20:03:10 -0700 Subject: [PATCH 2/3] adding stubs for new api capabilities --- app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index b642f9b..71ec224 100644 --- a/app.py +++ b/app.py @@ -186,9 +186,9 @@ def gather_info(summoners, champ_count, champ_id_to_name, region): summoner_id, summoner_name, account_id = get_data.get_summoner_data(player, region) champ_points_pair = get_data.get_summoners_mastery(summoner_id, summoner_name, champ_count, region) champ_counters = get_data.lanes_and_roles(account_id, summoner_name, champ_points_pair, champ_id_to_name, region) - get_data.percentages(champ_counters) + champ_counters, total_games = get_data.percentages(champ_counters) summoner_data[summoner_name] = get_data.data_compile(summoner_name, champ_counters, - champ_id_to_name, champ_points_pair) + champ_id_to_name, champ_points_pair, total_games) return summoner_data From 0c8cb7f11f93ffa722efe5b8699194be333eb4fd Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 10 Sep 2017 20:04:41 -0700 Subject: [PATCH 3/3] prepping for new data made available by the api. just need to borrow some code from tdxmm in order to grab all match history and i should be good to go --- get_data.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/get_data.py b/get_data.py index 422dc9a..b30ffa3 100644 --- a/get_data.py +++ b/get_data.py @@ -57,8 +57,8 @@ def lanes_and_roles(account_id, summoner_name, champ_points_pair, champ_id_to_na try: list_of_games = lane_response['matches'] for game in list_of_games: - # Skip TT games - if game['queue'] == 41: + # Skip non-SR games + if game['queue'] not in [2, 14, 4, 6, 42, 400, 410, 420, 430, 440]: continue champ_id = game['champion'] if 'lane' in game: @@ -103,20 +103,22 @@ def percentages(champ_counters): # Get percentage of games played in each role per champion (eg 33% top, 50% jungle, 17% support) # Bonus points if you can tell us what champions might fit that above percentage distribution + total_games = dict() for id_key, count_dict in champ_counters.items(): - role_games = 0 - for role_name, role_count in count_dict.items(): - role_games += role_count - for role_name, role_count in count_dict.items(): - if role_games > 0: - champ_counters[id_key][role_name] /= float(role_games) + champ_games = 0 + for role_count in count_dict.values(): + champ_games += role_count + for role_name in count_dict.keys(): + if champ_games > 0: + champ_counters[id_key][role_name] /= float(champ_games) else: - champ_counters[id_key][role_name] /= float(1) + champ_counters[id_key][role_name] = 0 + total_games[id_key] = champ_games - return champ_counters + return champ_counters, total_games -def data_compile(summoner_name, champ_counters, champ_id_to_name, champ_points_pair): +def data_compile(summoner_name, champ_counters, champ_id_to_name, champ_points_pair, total_games): # Compile all the data that we have pulled so far into one place structured_data = [] @@ -136,7 +138,7 @@ def data_compile(summoner_name, champ_counters, champ_id_to_name, champ_points_p if role.upper() not in ['DUO_CARRY', 'DUO_SUPPORT', 'JUNGLE', 'MID', 'TOP']: continue name = champ_id_to_name[str(champ_id)] - points = int(percentage * multiplier * champ_points_pair[champ_id]) + points = int((percentage * multiplier * champ_points_pair[champ_id]) / total_games[champ_id]) champ_tuple = Champ(name, champ_id, role, points, summoner_name) structured_data.append(champ_tuple)