Skip to content

Instantly share code, notes, and snippets.

@waprin
Created August 13, 2018 16:32
Show Gist options
  • Save waprin/71f8c9848ceffcd297626cd860e4cd25 to your computer and use it in GitHub Desktop.
Save waprin/71f8c9848ceffcd297626cd860e4cd25 to your computer and use it in GitHub Desktop.
analyze opponents
print('------------Opponents---------------------')
hero_wins = collections.defaultdict(int)
hero_totals = collections.defaultdict(int)
hero_matches = collections.defaultdict(list)
for match in wisp_matches:
for hero in match.opponent_picks:
hero_totals[hero] += 1
if not match.liquid_win:
hero_wins[hero] += 1
hero_matches[hero].append(match.match)
win_percent = collections.defaultdict(float)
for k, v in hero_wins.items():
win_percent[k] = (v/hero_totals[k])
sorted_percent = collections.OrderedDict(sorted(win_percent.items(), key=itemgetter(1), reverse=True))
for k, v in sorted_percent.items():
print('Hero {} has won {} out of {} games against Liquid IO for a win percent of {} (matches {})'.format(
k, hero_wins[k], hero_totals[k], v, hero_matches[k]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment