Пример #1
0
print('[%s] Initialized %i players and %i games' % (str(datetime.now()), len(players), ngames), flush=True)

# {{{ Compute new ratings, devs and performances
for p in players.values():
    new_ratings, new_devs = update(
        array(
            [p['prev_ratings']['M'], p['prev_ratings']['P'], 
            p['prev_ratings']['T'], p['prev_ratings']['Z']]
        ),
        array([p['prev_devs']['M'], p['prev_devs']['P'], p['prev_devs']['T'], p['prev_devs']['Z']]),
        array(p['opp_r']), array(p['opp_d']), array(p['opp_c']), 
        array(p['wins']), array(p['losses']), p['player'].tag, False
    )

    perfs = performance(
        array(p['opp_r']), array(p['opp_d']), array(p['opp_c']), array(p['wins']), array(p['losses'])
    )

    p.update({
        'new_ratings': { 'M': new_ratings[0], 'P': new_ratings[1], 'T': new_ratings[2], 'Z': new_ratings[3] },
        'new_devs': { 'M': new_devs[0], 'P': new_devs[1], 'T': new_devs[2], 'Z': new_devs[3] },
        'perfs': { 'M': perfs[0], 'P': perfs[1], 'T': perfs[2], 'Z': perfs[3] },
    })
# }}}

# {{{ Prepare to commit
extant_ids = {r.player_id for r in Rating.objects.filter(period=period)}
computed_ids = {p['player'].id for p in players.values()}
insert_ids = computed_ids - extant_ids
update_ids = computed_ids & extant_ids
delete_ids = extant_ids - computed_ids
Пример #2
0
        array([p["prev_ratings"]["M"], p["prev_ratings"]["P"], p["prev_ratings"]["T"], p["prev_ratings"]["Z"]]),
        array([p["prev_devs"]["M"], p["prev_devs"]["P"], p["prev_devs"]["T"], p["prev_devs"]["Z"]]),
        array(p["opp_r"]),
        array(p["opp_d"]),
        array(p["opp_c"]),
        array(p["wins"]),
        array(p["losses"]),
        p["player"].tag,
        False,
    )

    perfs = performance(
        array(p["opp_r"]),
        array(p["opp_d"]),
        array(p["opp_c"]),
        array(p["wins"]),
        array(p["losses"]),
        p["player"].tag,
        False,
    )

    p.update(
        {
            "new_ratings": {"M": new_ratings[0], "P": new_ratings[1], "T": new_ratings[2], "Z": new_ratings[3]},
            "new_devs": {"M": new_devs[0], "P": new_devs[1], "T": new_devs[2], "Z": new_devs[3]},
            "perfs": {"M": perfs[0], "P": perfs[1], "T": perfs[2], "Z": perfs[3]},
        }
    )
# }}}

# {{{ Prepare to commit
Пример #3
0
print('[%s] Initialized %i players and %i games' % (str(datetime.now()), len(players), ngames), flush=True)

# {{{ Compute new ratings, devs and performances
for p in players.values():
    new_ratings, new_devs = update(
        array(
            [p['prev_ratings']['M'], p['prev_ratings']['P'], 
            p['prev_ratings']['T'], p['prev_ratings']['Z']]
        ),
        array([p['prev_devs']['M'], p['prev_devs']['P'], p['prev_devs']['T'], p['prev_devs']['Z']]),
        array(p['opp_r']), array(p['opp_d']), array(p['opp_c']), 
        array(p['wins']), array(p['losses']), p['player'].tag, False
    )

    perfs = performance(
        array(p['opp_r']), array(p['opp_d']), array(p['opp_c']), array(p['wins']), array(p['losses']),
        p['player'].tag, False
    )

    p.update({
        'new_ratings': { 'M': new_ratings[0], 'P': new_ratings[1], 'T': new_ratings[2], 'Z': new_ratings[3] },
        'new_devs': { 'M': new_devs[0], 'P': new_devs[1], 'T': new_devs[2], 'Z': new_devs[3] },
        'perfs': { 'M': perfs[0], 'P': perfs[1], 'T': perfs[2], 'Z': perfs[3] },
    })
# }}}

# {{{ Prepare to commit
extant_ids = {r.player_id for r in Rating.objects.filter(period=period)}
computed_ids = {p['player'].id for p in players.values()}
insert_ids = computed_ids - extant_ids
update_ids = computed_ids & extant_ids
delete_ids = extant_ids - computed_ids
Пример #4
0
    # Collect match information
    num_games = get_matches(cplayers, period)
    print('Initialized: {0} players and {1} games. Updating...'.format(len(cplayers), num_games))

    # Update ratings
    num_retplayers = 0
    num_newplayers = 0
    for cp in cplayers.values():
        (newr, newd) = update(cp.get_rating_array(), cp.get_dev_array(),
                array(cp.oppr), array(cp.oppd), array(cp.oppc), array(cp.W), array(cp.L),
                cp.player.tag, False)

        cp.new_rating = array_to_dict(newr)
        cp.new_dev = array_to_dict(newd)

        perf = performance(array(cp.oppr), array(cp.oppd), array(cp.oppc), array(cp.W), array(cp.L))

        cp.comp_rat = array_to_dict(perf)

        # Count player as returning or new
        if len(cp.W) > 0 and cp.prev_rating_obj:
            num_retplayers += 1
        elif len(cp.W) > 0:
            num_newplayers += 1
    #sys.exit(0)

    # Get a table of existing rating objects
    existing = set()
    for i in Rating.objects.filter(period=period).values('player_id'):
        existing.add(i['player_id'])
Пример #5
0
# {{{ Compute new ratings, devs and performances
for p in players.values():
    new_ratings, new_devs = update(
        array([
            p['prev_ratings']['M'], p['prev_ratings']['P'],
            p['prev_ratings']['T'], p['prev_ratings']['Z']
        ]),
        array([
            p['prev_devs']['M'], p['prev_devs']['P'], p['prev_devs']['T'],
            p['prev_devs']['Z']
        ]), array(p['opp_r']), array(p['opp_d']), array(p['opp_c']),
        array(p['wins']), array(p['losses']), p['player'].tag, False)

    perfs = performance(array(p['opp_r']),
                        array(p['opp_d']), array(p['opp_c']), array(p['wins']),
                        array(p['losses']), p['player'].tag, False)

    p.update({
        'new_ratings': {
            'M': new_ratings[0],
            'P': new_ratings[1],
            'T': new_ratings[2],
            'Z': new_ratings[3]
        },
        'new_devs': {
            'M': new_devs[0],
            'P': new_devs[1],
            'T': new_devs[2],
            'Z': new_devs[3]
        },