def winner(teams): match_results = match_result.match_result(teams) if match_results[0] > match_results[1]: return [match_results, teams[0]] if match_results[1] > match_results[0]: return [match_results, teams[1]] if match_results[1] == match_results[0]: #get attach/defense weights weights = match_result.get_weights() if weights[teams[0]][0] > weights[teams[1]][1]: #teams[0] wins in penalty shootout return [match_results, teams[0]] else: return [match_results, teams[1]]
def winner(teams): match_results=match_result.match_result(teams) if match_results[0]>match_results[1]: return [match_results,teams[0]] if match_results[1]>match_results[0]: return [match_results,teams[1]] if match_results[1]==match_results[0]: #get attach/defense weights weights=match_result.get_weights() if weights[teams[0]][0]>weights[teams[1]][1]: #teams[0] wins in penalty shootout return [match_results,teams[0]] else: return [match_results,teams[1]]
def group(a): wdl_tuple = [] pts_tuple = [] for i in a: wdl_tuple.append([i, [0, 0, 0]]) pts_tuple.append([i, 0]) #convert tuple to dictionary pts = dict(pts_tuple) wdl = dict(wdl_tuple) #now generate fixtures and calculate results for i in range(len(a)): for j in range(len(a)): if j > i: scores(match_result([a[i], a[j]]), [a[i], a[j]], pts, wdl) #print a[i]," v ",a[j]," ",match_result([a[i],a[j]]) return [sorted(pts, key=pts.get), wdl]
def group(a): wdl_tuple=[] pts_tuple=[] for i in a: wdl_tuple.append([i,[0,0,0]]) pts_tuple.append([i,0]) #convert tuple to dictionary pts=dict(pts_tuple) wdl=dict(wdl_tuple) #now generate fixtures and calculate results for i in range(len(a)): for j in range(len(a)): if j>i: scores(match_result([a[i],a[j]]),[a[i],a[j]],pts,wdl) #print a[i]," v ",a[j]," ",match_result([a[i],a[j]]) return [sorted(pts, key=pts.get),wdl]
PASSWORD = os.getenv("PASSWORD") cookies = {"USERID": USERID, "PASSWORD": PASSWORD} matchIds = [] players_set = set() if len(sys.argv) < 2: sys.exit( "Input file name is missing\nUsage example: python dailygammon-championship input.txt" ) with open(sys.argv[1]) as file: matchIds = file.readlines() matchIds = [mid[:7] for mid in matchIds] matchfiles = [matchfile(mid, cookies) for mid in matchIds] results = [match_result(f) for f in matchfiles] for i in results: if "players" in i: players_set.add(i["players"][0]) players_set.add(i["players"][1]) players = list(players_set) players = sorted(players, key=str.lower) results_df = pd.DataFrame(index=players, columns=players) for i in range(results_df.shape[0]): results_df.iloc[i, i] = "----" columns = ["finished", "won", "lost", "+", "-", "total"] summary_df = pd.DataFrame(index=players, columns=columns)