Skip to content

Weightings not respected when supplied as dictionary #9

Description

@bernd-wechner

In this sample:

    # Multi Player example
    print("\nMultiplayer example")

    class Player(object):
        def __init__(self, name, rating, team):
            self.name = name
            self.rating = rating
            self.team = team

    p1 = Player('Player A', Rating(), 0)
    p2 = Player('Player B', Rating(), 0)
    p3 = Player('Player C', Rating(), 1)

    print(p1.rating, p2.rating, p3.rating)

    teams = [{p1: p1.rating, p2: p2.rating}, {p3: p3.rating}]
    ranks = [1, 2]
    weights = {(0, p1): 1, (0, p2): 1, (1, p3): 1}

    rated = trueskill.rate(teams, ranks, weights=weights)

    p1.rating = rated[p1.team][p1]
    p2.rating = rated[p2.team][p2]
    p3.rating = rated[p3.team][p3]

    print(p1.rating, p2.rating, p3.rating)

The result is:

    Multiplayer example
    trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333)
    trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=24.396, sigma=8.075)

All the weights were 1. Now give p2 a weight of 0.5:

    weights = {(0, p1): 1, (0, p2): 0.5, (1, p3): 1}

The result is identical:

If the weights are supplied as a list of tuples instead:

    weights = weights = [(1, 0.5), (1,)]    # for p1, p2, p3 respectively

Then the results reflect the weights:

    Multiplayer example
    trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333)
    trueskill.Rating(mu=26.764, sigma=7.685) trueskill.Rating(mu=25.882, sigma=8.176) trueskill.Rating(mu=23.236, sigma=7.685)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions