def get_pairings(tourn, config): virtual = config.virtual if hasattr(config, "virtual") else 0.5 use_utpr = config.utpr if hasattr(config, "utpr") else False use_2015 = config.wc2015 if hasattr(config, "wc2015") else False stpr = rate(tourn.seeds, tourn, virtual) if use_utpr: utpr = rate({p: 1500 for p in tourn.seeds}, tourn, virtual) def order(p): return (tourn.losses[p], -utpr[p], -stpr[p]) else: def order(p): return (tourn.losses[p], -stpr[p]) tourn.player_order = {p: order(p) for p in tourn.players} sorted_players = sorted(tourn.players, key=order) tourn.stpr = stpr tourn.ranks = {p: rank for rank, p in enumerate(sorted_players, start=1)} if use_2015: scale = Swiss_2015_Scale(tourn) else: scale = Swiss_Scale(tourn) pairings, bye = weighted_pairing(tourn, scale) return pairings, bye
def get_pairings(tourn, config): lives = config.lives virtual = config.virtual if hasattr(config, "virtual") else 0.5 use_utpr = config.utpr if hasattr(config, "utpr") else False use_2015 = config.wc2015 if hasattr(config, "wc2015") else False stpr = rate(tourn.seeds, tourn, virtual) if use_utpr: utpr = rate({p: 1500 for p in tourn.seeds}, tourn, virtual) def order(p): return (tourn.losses[p], -utpr[p], -stpr[p]) else: def order(p): return (tourn.losses[p], -stpr[p]) tourn.player_order = {p: order(p) for p in tourn.players} sorted_players = sorted(tourn.players, key=order) tourn.ranks = {p: rank for rank, p in enumerate(sorted_players, start=1)} tourn.stpr = stpr tourn.players = set([p for p in tourn.players if tourn.losses[p] < lives]) if use_2015: scale = FTE_2015_Scale(lives, tourn) else: scale = FTE_Scale(lives, tourn) pairings, bye = weighted_pairing(tourn, scale) return pairings, bye
def get_pairings(tourn, virtual=0.5, use_utpr=False): stpr = rate(tourn.seeds, tourn, virtual) if use_utpr: utpr = rate({p: 1500 for p in tourn.seeds}, tourn, virtual) def order(p): return (tourn.losses[p], -utpr[p], -stpr[p]) else: def order(p): return (tourn.losses[p], -stpr[p]) tourn.player_order = {p: order(p) for p in tourn.players} sorted_players = sorted(tourn.players, key=order) tourn.ranks = {p: rank for rank, p in enumerate(sorted_players, start=1)} scale = Swiss_Scale(tourn) pairings, bye = weighted_pairing(tourn, scale) return pairings, bye
def print_final_ranking(tourn, virtual, use_utpr=False): stpr = rate(tourn.seeds, tourn, virtual) if use_utpr: utpr = rate({p: 1500 for p in tourn.seeds}, tourn, virtual) def order(p): return (-(tourn.wins[p] + tourn.byes[p]), -utpr[p], -stpr[p]) else: def order(p): return (-(tourn.wins[p] + tourn.byes[p]), -stpr[p]) players = sorted(tourn.seeds, key=order) print "# Final ranks" for rank, p in enumerate(players, start=1): pord = order(p) print "#", rank, p, -pord[0], for rating in pord[1:]: print -rating, print
def get_pairings(tourn, virtual=0.5): rounds = tourn.rounds if rounds is None: if tourn.played.values(): raise ValueError("Round information not found for tournament.") rounds = 0 elif rounds < tourn.played.most_common(1)[0][1]: p = tourn.played.most_common(1)[0][0] raise ValueError( "Games played by player %s is larger than number of rounds" % (p,)) stpr = rate(tourn.seeds, tourn, virtual) tourn.score = dict() for p in tourn.players: tourn.score[p] = tourn.wins[p] + ((rounds - tourn.played[p]) * 0.5) def order(p): return (-tourn.score[p], -stpr[p]) tourn.player_order = {p: order(p) for p in tourn.players} sorted_players = sorted(tourn.players, key=order) tourn.ranks = {p: rank for rank, p in enumerate(sorted_players, start=1)} scale = Swiss_Scale(tourn) pairings, bye = weighted_pairing(tourn, scale) return pairings, bye