Anche se non è disponibile, qualcosa del genere non è troppo difficile da implementare. Ecco un esempio con un sistema di valutazione estremamente stupido e semplice che vuole solo darti un'idea. Ma non penso che usare la formula Elo sia molto più difficile.
EDIT: modifico la mia implementazione per utilizzare la formula Elo (esclusi i piani) fornita dalla formula qui
def get_exp_score_a(rating_a, rating_b):
return 1.0 /(1 + 10**((rating_b - rating_a)/400.0))
def rating_adj(rating, exp_score, score, k=32):
return rating + k * (score - exp_score)
class ChessPlayer(object):
def __init__(self, name, rating):
self.rating = rating
self.name = name
def match(self, other, result):
exp_score_a = get_exp_score_a(self.rating, other.rating)
if result == self.name:
self.rating = rating_adj(self.rating, exp_score_a, 1)
other.rating = rating_adj(other.rating, 1 - exp_score_a, 0)
elif result == other.name:
self.rating = rating_adj(self.rating, exp_score_a, 0)
other.rating = rating_adj(other.rating, 1 - exp_score_a, 1)
elif result == 'Draw':
self.rating = rating_adj(self.rating, exp_score_a, 0.5)
other.rating = rating_adj(other.rating, 1 - exp_score_a, 0.5)
Funziona come segue:
>>> bob = ChessPlayer('Bob', 1600)
>>> john = ChessPlayer('John', 1900)
>>> bob.rating
1600
>>> john.rating
1900
>>> bob.match(john, 'Bob')
>>> bob.rating
1627.1686541692377
>>> john.rating
1872.8313458307623
>>> mark = ChessPlayer('Mark', 2100)
>>> mark.match(bob, 'Draw')
>>> mark.rating
2085.974306956907
>>> bob.rating
1641.1943472123305
Ecco la mia implementazione originale di Python:
class ChessPlayer(object):
def __init__(self, name, rating):
self.rating = rating
self.name = name
def match(self, other, result):
if result == self.name:
self.rating += 10
other.rating -= 10
elif result == other.name:
self.rating += 10
other.rating -= 10
elif result == 'Draw':
pass
Funziona come segue:
>>> bob = ChessPlayer('Bob', 1600)
>>> john = ChessPlayer('John', 1900)
>>> bob.match(john, 'Bob')
>>> bob.rating
1610
>>> john.rating
1890
>>> mark = ChessPlayer('Mark', 2100)
>>> mark.match(bob, 'Mark')
>>> mark.rating
2110
>>> bob.rating
1600
>>> mark.match(john, 'Draw')
>>> mark.rating
2110
>>> john.rating
1890