sublee / trueskill

An implementation of the TrueSkill rating system for Python
https://trueskill.org/
Other
742 stars 112 forks source link

Calculating chance to win + draw probability #21

Closed smlbiobot closed 6 years ago

smlbiobot commented 6 years ago

So I see that there is a method for calculating drawing chances, but what about winning chances between two ratings?

Also, I don’t quite understand how to set the draw percentages. Is it supposed to be set to 0.5? I think that I have mistaken what this values mean. Because in our game, it is very unlikely to draw but I have a feeling that this value is used to determine the middle point.

Thanks!

sublee commented 6 years ago

For the first question, you can read https://github.com/sublee/trueskill/issues/1.

smlbiobot commented 6 years ago

The formula agreed by the community to calculate wins using mu and sigma appears to be this:

from trueskill import Rating
import math

def win_probability(rA: Rating, rB: Rating):
    delta_mu = rA.mu - rB.mu
    rsss = math.sqrt(rA.sigma ** 2 + rB.sigma ** 2)
    return env.cdf(delta_mu / rsss)

What is this one for then? Is it for team vs team?

import math
from trueskill import Rating

def win_probability(a, b):                                                      
    deltaMu = sum([x.mu for x in a]) - sum([x.mu for x in b])                   
    sumSigma = sum([x.sigma ** 2 for x in a]) + sum([x.sigma ** 2 for x in b])  
    playerCount = len(a) + len(b)                                               
    denominator = math.sqrt(playerCount * (BETA * BETA) + sumSigma)             
    return env.cdf(deltaMu / denominator)
sublee commented 6 years ago

Yes, that is for a team vs. team game. I prefer the second one. I've just introduced the snippet in the documentation.

smlbiobot commented 6 years ago

ok great — thanks for this btw! I have been looking for a usable elo / glicko library and then accidentally ran into yours — and given that we planned to implement team vs team in the future this is so very useful. I’ll close this now. Great work!