Improved single and duo output

This commit is contained in:
John Drake 2026-02-16 21:45:27 -05:00
parent eaa1ed1898
commit f91cd9de53

View file

@ -169,15 +169,15 @@ for player,roles in players_to_roles.items():
# D doesn't include farm and O doesn't include cap
role_relationships = {'defense':['tank','hd','lof','hof','ld','flex','shrike','snipe'],'offense':['shrike','ho','snipe','flex','lo','snipe']}
any_roles_to_players['defense'] = list()
print("any_roles_to_players['defense']:",any_roles_to_players['defense'])
print("any_roles_to_players['offense']:",any_roles_to_players['offense'])
# print("any_roles_to_players['defense']:",any_roles_to_players['defense'])
# print("any_roles_to_players['offense']:",any_roles_to_players['offense'])
for (role, related_roles) in role_relationships.items():
if role not in any_roles_to_players:
any_roles_to_players[role] = list()
for related_role in related_roles:
any_roles_to_players[role].append(any_roles_to_players[related_role])
print("expanded any_roles_to_players['defense']:",any_roles_to_players['defense'])
print("any_roles_to_players['offense']:",any_roles_to_players['offense'])
# print("expanded any_roles_to_players['defense']:",any_roles_to_players['defense'])
# print("any_roles_to_players['offense']:",any_roles_to_players['offense'])
player_to_win_count = dict()
player_to_match_count = dict()
@ -218,64 +218,25 @@ for match_result in match_results:
duo_to_win_count[player_name_duo]+=1
# Print conditional probabilities
player_to_win_rate = dict()
match_count_high_threshold = 40
match_count_low_threshold = 27
for matchkvp in player_to_match_count.items():
if matchkvp[1] < match_count_high_threshold:
continue
player_to_win_rate[matchkvp[0]] = player_to_win_count[matchkvp[0]] / matchkvp[1]
player_to_win_rate_sorted = list(player_to_win_rate.items())
player_to_win_rate_sorted.sort(key=lambda p: p[1], reverse=True)
print('Higher confidence Best (and worst) player win rates:\n','\n'.join([str(x) for x in player_to_win_rate_sorted]))
player_to_win_rate = dict()
for matchkvp in player_to_match_count.items():
if matchkvp[1] > match_count_high_threshold or matchkvp[1] < match_count_low_threshold:
continue
player_to_win_rate[matchkvp[0]] = player_to_win_count[matchkvp[0]] / matchkvp[1]
player_to_win_rate_sorted = list(player_to_win_rate.items())
player_to_win_rate_sorted.sort(key=lambda p: p[1], reverse=True)
print('Lower confidence Best (and worst) player win rates:\n','\n'.join([str(x) for x in player_to_win_rate_sorted]))
player_match_counts = list(player_to_match_count.values())
player_match_counts.sort()
top_single_tenth_match_count = player_match_counts[len(player_match_counts)*9//10]
top_players = [(p, player_to_win_count[p] / player_to_match_count[p]) for p in player_to_match_count.keys() if p in player_to_match_count and player_to_match_count[p] >= top_single_tenth_match_count]
top_players.sort(key=lambda p: p[1], reverse=True)
print('Higher confidence singles',[p[0]+' '+format(p[1],'.2f') for p in top_players[:5]])
print('')
duo_match_counts = list(duo_to_match_count.values())
duo_match_counts.sort()
top_duo_match_count = duo_match_counts[len(duo_match_counts)*99//100]
top_duos = [(p, duo_to_win_count[p] / duo_to_match_count[p]) for p in duo_to_match_count.keys() if p in duo_to_match_count and duo_to_match_count[p] >= top_duo_match_count]
top_duos.sort(key=lambda p: p[1], reverse=True)
# As above but per role
for role, players in first_roles_to_players.items():
# print([str((p,player_to_match_count[p])) for p in players if p in player_to_match_count])
player_match_counts = [player_to_match_count[p] for p in players if p in player_to_match_count]
player_match_counts.sort()
print('Higher confidence duos',[str(p[0])+' '+format(p[1],'.2f') for p in top_duos[:5]])
top_third_match_count = player_match_counts[len(player_match_counts)*2//3]
middle_third_match_count = player_match_counts[len(player_match_counts)//3]
# print('Role:',role,'player match counts:',player_match_counts,'top third cutoff:',top_third_match_count,'middle third cutoff:',middle_third_match_count)
significant_players = [(p, player_to_win_count[p] / player_to_match_count[p]) for p in players if p in player_to_match_count and player_to_match_count[p] >= top_third_match_count]
significant_players.sort(key=lambda p: p[1], reverse=True)
print('Higher confidence',role,[p[0]+' '+format(p[1],'.2f') for p in significant_players])
significant_players = [(p, player_to_win_count[p] / player_to_match_count[p]) for p in players if p in player_to_match_count and player_to_match_count[p] >= middle_third_match_count and player_to_match_count[p] < top_third_match_count]
significant_players.sort(key=lambda p: p[1], reverse=True)
print('Middle confidence',role,[p[0]+' '+format(p[1],'.2f') for p in significant_players])
significant_players = [(p, player_to_win_count[p] / player_to_match_count[p]) for p in players if p in player_to_match_count and player_to_match_count[p] < middle_third_match_count and player_to_match_count[p] > 1]
significant_players.sort(key=lambda p: p[1], reverse=True)
print('Lower confidence',role,[p[0]+' '+format(p[1],'.2f') for p in significant_players])
print()
print()
duo_to_win_rate = dict()
duo_count_threshold = 22
for matchkvp in duo_to_match_count.items():
if matchkvp[1] < duo_count_threshold:
continue
duo_to_win_rate[matchkvp[0]] = duo_to_win_count[matchkvp[0]] / matchkvp[1]
duo_to_win_rate_sorted = list(duo_to_win_rate.items())
duo_to_win_rate_sorted.sort(key=lambda p: p[1], reverse=True)
print('Duo win rates (n >= ',duo_count_threshold,'):\n','\n'.join([str(x) for x in duo_to_win_rate_sorted]))
print()