Пример #1
0
def index(request):
    if request.POST:
        elo.update(request.POST)

    player_list = Player.objects.order_by("ELO").reverse()
    player_list_alpha = Player.objects.order_by("player_name")
    return render_to_response('pingpong/index.html', {'player_list': player_list, 'player_list_alpha':player_list_alpha},
        context_instance=RequestContext(request))
Пример #2
0
def _compare(song1: Song, song2: Song):
    """
	Compares two songs, printing their names to console and adjusting their ratings based on input.
	:param song1: first song
	:param song2: second song
	"""
    print(song1)
    print('vs.')
    print(song2)

    update(song1, song2, _get_input(), _MIN_K)
    print('Elo:', song1.elo, song2.elo)
    print()

    all_songs.remove(song1)
    all_songs.remove(song2)
    _insert([song1, song2])
Пример #3
0
def fetch():
    ratings = dict()

    ts = challonge.tournaments.index(created_after="2015-04-03")
    for t in ts:
        if not t["started-at"]:
            continue
        tid = t["id"]
        names = dict()
        ps = challonge.participants.index(tid)
        for p in ps:
            pid = p["id"]
            pn = p["name"]
            assert pid not in names or pn == names[pid]
            names[pid] = pn
        ms = challonge.matches.index(tid)
        for m in ms:
            id1 = m["player1-id"]
            if not id1:
                continue
            p1 = names[id1]
            id2 = m["player2-id"]
            if not id2:
                continue
            p2 = names[id2]
            ss = m["scores-csv"]

            ## EXCEPTIONS FOR INCORRECT RECORDINGS
            if p1 == "Fest" and p2 == "Nook" and ss == "2-0":
                ss = "0-2"
            if p1 == "Bean" and p2 == "Nook" and ss == "0-222":
                ss = "0-2"
            if p1 == "Ai" and p2 == "Justin" and ss == "0-69":
                ss = "0-2"
            if p1 == "Meero" and p2 == "Lyme" and ss == "0-0":
                ss == "0-2"

            # print p1, p2, ss
            if not p1 or not p2 or not ss:
                continue
            if len(ss) != 3 or ss[1] != '-' or \
               not ss[0].isdigit() or not ss[2].isdigit():
                # print >> stderr, "warning: invalid score", ss, "for", \
                #    p1, "v", p2, "in", t["name"]
                continue
            s = int(ss[0]) - int(ss[2])
            if s < -3 or s > 3:
                def pin(s0):
                    global s
                    #print >> stderr, "warning: score", s, "adjusted to", s0, \
                    #    "for", p1, "v", p2, "in", t["name"]
                    s = s0
                if s < -3:
                    pin(-3)
                if s > 3:
                    pin(3)
            if p1 not in ratings:
                ratings[p1] = 1000
            if p2 not in ratings:
                ratings[p2] = 1000
            p1r = ratings[p1]
            p2r = ratings[p2]
            sn = (s + 3.0) / 6.0
            ratings[p1] = elo.update(p1r, p2r, sn)
            ratings[p2] = elo.update(p2r, p1r, 1.0 - sn)
            def d(p, pr):
                return p + ":" + str(pr) + "->" + str(ratings[p])
            # print >> stderr, "update", sn, d(p1, p1r), d(p2, p2r)

    ## ONLY PRINTS OUT THOSE WHO ARE IN TOP N
    results = []
    rank = 1
    for p in sorted(ratings, key=ratings.__getitem__, reverse=True):
        if p in topN:
            results.append(PlayerStats(rank, p, ratings[p]))
            rank += 1
    return results
Пример #4
0
#!/usr/bin/python2
# Copyright (c) 2015 Benjamin and Barton Massey
# [This program is licensed under the GPL version 3 or later.]
# Please see the file COPYING in the source
# distribution of this software for license terms.

# Elo Rating update calculator
# for Smash match (assumes 5-game match)
# http://en.wikipedia.org/wiki/Elo_rating_system

from sys import argv
import elo

# Current rating of a.
ra = int(argv[1])
# Current rating of b.
rb = int(argv[2])
# Score difference in the match (0..1).
s = float(argv[3])

# Normalized actual score of a.
ns = (s + 3) / 6

# Print adjusted Elo rating of a.
print elo.update(ra, rb, s)