Spaces:
Runtime error
Runtime error
Update elo.py
Browse files
elo.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
winner_old_rating = winner_category_data.get('elo_rating', 1200)
|
9 |
-
loser_old_rating = loser_category_data.get('elo_rating', 1200)
|
10 |
-
winner_games_played = winner_category_data.get('games_played', 0)
|
11 |
-
loser_games_played = loser_category_data.get('games_played', 0)
|
12 |
|
13 |
# Function to determine the K-factor based on games played
|
14 |
def determine_k_factor(games_played):
|
@@ -38,19 +34,8 @@ def update_elo_ratings(ratings_dict, winner, loser, category):
|
|
38 |
# Calculate new ratings
|
39 |
winner_new_rating, loser_new_rating = elo(winner_old_rating, loser_old_rating, k_factor_winner=winner_k_factor, k_factor_loser=loser_k_factor)
|
40 |
|
41 |
-
# Update ratings and games played in the dictionary
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
ratings_dict[winner][category]['elo_rating'] = winner_new_rating
|
47 |
-
ratings_dict[winner][category]['games_played'] = winner_games_played + 1
|
48 |
-
|
49 |
-
if loser not in ratings_dict:
|
50 |
-
ratings_dict[loser] = {}
|
51 |
-
if category not in ratings_dict[loser]:
|
52 |
-
ratings_dict[loser][category] = {}
|
53 |
-
ratings_dict[loser][category]['elo_rating'] = loser_new_rating
|
54 |
-
ratings_dict[loser][category]['games_played'] = loser_games_played + 1
|
55 |
-
|
56 |
-
return ratings_dict
|
|
|
1 |
+
def update_elo_ratings(ratings_dict, winner, loser):
|
2 |
|
3 |
+
# Extract old ratings and games played
|
4 |
+
winner_old_rating = ratings_dict.get(winner, {}).get('elo_rating', 1200)
|
5 |
+
loser_old_rating = ratings_dict.get(loser, {}).get('elo_rating', 1200)
|
6 |
+
winner_games_played = ratings_dict.get(winner, {}).get('games_played', 0)
|
7 |
+
loser_games_played = ratings_dict.get(loser, {}).get('games_played', 0)
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Function to determine the K-factor based on games played
|
10 |
def determine_k_factor(games_played):
|
|
|
34 |
# Calculate new ratings
|
35 |
winner_new_rating, loser_new_rating = elo(winner_old_rating, loser_old_rating, k_factor_winner=winner_k_factor, k_factor_loser=loser_k_factor)
|
36 |
|
37 |
+
# Update ratings and games played in the dictionary
|
38 |
+
ratings_dict[winner] = {'elo_rating': winner_new_rating, 'games_played': winner_games_played + 1}
|
39 |
+
ratings_dict[loser] = {'elo_rating': loser_new_rating, 'games_played': loser_games_played + 1}
|
40 |
+
|
41 |
+
return ratings_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|