Spaces:
Sleeping
Sleeping
Commit
Β·
1eb4ddf
1
Parent(s):
01d080e
Adding playoff bonus
Browse files- app.py +7 -5
- leaders/users.json +9 -9
app.py
CHANGED
|
@@ -162,7 +162,7 @@ def submit_prediction(
|
|
| 162 |
|
| 163 |
if bid_points > max_bid_points:
|
| 164 |
st.error(
|
| 165 |
-
f"Oops, your bid is too high! π« Maximum allowed bid is {max_bid_points}
|
| 166 |
)
|
| 167 |
return
|
| 168 |
|
|
@@ -224,7 +224,7 @@ def get_user_total_points(user_name):
|
|
| 224 |
def calculate_min_max_bid_points(user_name):
|
| 225 |
total_points = get_user_total_points(user_name)
|
| 226 |
min_bid_points = math.ceil(total_points * 0.10) # round up
|
| 227 |
-
max_bid_points = math.floor(total_points * 0.50) # round down
|
| 228 |
return int(min_bid_points), int(max_bid_points)
|
| 229 |
|
| 230 |
|
|
@@ -466,6 +466,8 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
|
|
| 466 |
users = load_dataset("Jay-Rajput/DIS_IPL_Leads", split="train")
|
| 467 |
users_df = pd.DataFrame(users)
|
| 468 |
|
|
|
|
|
|
|
| 469 |
# Capture previous leaderboard (top 3 users and their points)
|
| 470 |
prev_scores = [(user, users_df[user][0]['points']) for user in users_df.columns]
|
| 471 |
prev_scores.sort(key=lambda x: x[1], reverse=True)
|
|
@@ -481,7 +483,7 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
|
|
| 481 |
user_points = user_data['points']
|
| 482 |
user_initial_points = user_points
|
| 483 |
|
| 484 |
-
if user_name in
|
| 485 |
prediction = predictions[predictions['user_name'] == user_name].iloc[0]
|
| 486 |
predicted_winner = prediction['predicted_winner']
|
| 487 |
predicted_motm = prediction['predicted_motm']
|
|
@@ -516,13 +518,13 @@ def update_leaderboard_and_outcomes(match_id, winning_team, man_of_the_match, ou
|
|
| 516 |
new_leaderboard.sort(key=lambda x: x[1], reverse=True)
|
| 517 |
third_place_points = new_leaderboard[2][1] if len(new_leaderboard) >= 3 else 0
|
| 518 |
|
| 519 |
-
# Step 3: Redistribute lost points using difference-from-3rd-place logic
|
| 520 |
redistribution_pool = lost_points_by_top3
|
| 521 |
redistribution_weights = {}
|
| 522 |
redistribution_total_weight = 0
|
| 523 |
|
| 524 |
for user, data in user_outcomes.items():
|
| 525 |
-
if user not in top3_usernames:
|
| 526 |
diff_from_3rd = max(third_place_points - data['updated_points'], 0)
|
| 527 |
redistribution_weights[user] = diff_from_3rd
|
| 528 |
redistribution_total_weight += diff_from_3rd
|
|
|
|
| 162 |
|
| 163 |
if bid_points > max_bid_points:
|
| 164 |
st.error(
|
| 165 |
+
f"Oops, your bid is too high! π« Maximum allowed bid is {max_bid_points}."
|
| 166 |
)
|
| 167 |
return
|
| 168 |
|
|
|
|
| 224 |
def calculate_min_max_bid_points(user_name):
|
| 225 |
total_points = get_user_total_points(user_name)
|
| 226 |
min_bid_points = math.ceil(total_points * 0.10) # round up
|
| 227 |
+
max_bid_points = total_points # math.floor(total_points * 0.50) # round down
|
| 228 |
return int(min_bid_points), int(max_bid_points)
|
| 229 |
|
| 230 |
|
|
|
|
| 466 |
users = load_dataset("Jay-Rajput/DIS_IPL_Leads", split="train")
|
| 467 |
users_df = pd.DataFrame(users)
|
| 468 |
|
| 469 |
+
submitted_users = set(predictions['user_name'])
|
| 470 |
+
|
| 471 |
# Capture previous leaderboard (top 3 users and their points)
|
| 472 |
prev_scores = [(user, users_df[user][0]['points']) for user in users_df.columns]
|
| 473 |
prev_scores.sort(key=lambda x: x[1], reverse=True)
|
|
|
|
| 483 |
user_points = user_data['points']
|
| 484 |
user_initial_points = user_points
|
| 485 |
|
| 486 |
+
if user_name in submitted_users:
|
| 487 |
prediction = predictions[predictions['user_name'] == user_name].iloc[0]
|
| 488 |
predicted_winner = prediction['predicted_winner']
|
| 489 |
predicted_motm = prediction['predicted_motm']
|
|
|
|
| 518 |
new_leaderboard.sort(key=lambda x: x[1], reverse=True)
|
| 519 |
third_place_points = new_leaderboard[2][1] if len(new_leaderboard) >= 3 else 0
|
| 520 |
|
| 521 |
+
# Step 3: Redistribute lost points using difference-from-3rd-place logic (only for users who submitted prediction)
|
| 522 |
redistribution_pool = lost_points_by_top3
|
| 523 |
redistribution_weights = {}
|
| 524 |
redistribution_total_weight = 0
|
| 525 |
|
| 526 |
for user, data in user_outcomes.items():
|
| 527 |
+
if user not in top3_usernames and user in submitted_users:
|
| 528 |
diff_from_3rd = max(third_place_points - data['updated_points'], 0)
|
| 529 |
redistribution_weights[user] = diff_from_3rd
|
| 530 |
redistribution_total_weight += diff_from_3rd
|
leaders/users.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
"π΄",
|
| 8 |
"π΄"
|
| 9 |
],
|
| 10 |
-
"points":
|
| 11 |
"redistributed_bonus": 641,
|
| 12 |
"wildcard": [
|
| 13 |
0,
|
|
@@ -55,7 +55,7 @@
|
|
| 55 |
"π΄",
|
| 56 |
"π΄"
|
| 57 |
],
|
| 58 |
-
"points":
|
| 59 |
"redistributed_bonus": 1494,
|
| 60 |
"wildcard": [
|
| 61 |
0,
|
|
@@ -87,7 +87,7 @@
|
|
| 87 |
"π’",
|
| 88 |
"π΄"
|
| 89 |
],
|
| 90 |
-
"points":
|
| 91 |
"redistributed_bonus": 1155,
|
| 92 |
"wildcard": [
|
| 93 |
0,
|
|
@@ -119,7 +119,7 @@
|
|
| 119 |
"βͺ",
|
| 120 |
"βͺ"
|
| 121 |
],
|
| 122 |
-
"points":
|
| 123 |
"redistributed_bonus": 1115,
|
| 124 |
"wildcard": [
|
| 125 |
0,
|
|
@@ -167,7 +167,7 @@
|
|
| 167 |
"βͺ",
|
| 168 |
"βͺ"
|
| 169 |
],
|
| 170 |
-
"points":
|
| 171 |
"redistributed_bonus": 28,
|
| 172 |
"wildcard": [
|
| 173 |
0,
|
|
@@ -183,7 +183,7 @@
|
|
| 183 |
"π’",
|
| 184 |
"π΄"
|
| 185 |
],
|
| 186 |
-
"points":
|
| 187 |
"redistributed_bonus": 0,
|
| 188 |
"wildcard": [
|
| 189 |
0,
|
|
@@ -231,7 +231,7 @@
|
|
| 231 |
"π΄",
|
| 232 |
"π΄"
|
| 233 |
],
|
| 234 |
-
"points":
|
| 235 |
"redistributed_bonus": 486,
|
| 236 |
"wildcard": [
|
| 237 |
0,
|
|
@@ -279,7 +279,7 @@
|
|
| 279 |
"π΄",
|
| 280 |
"π’"
|
| 281 |
],
|
| 282 |
-
"points":
|
| 283 |
"redistributed_bonus": 1218,
|
| 284 |
"wildcard": [
|
| 285 |
0,
|
|
@@ -327,7 +327,7 @@
|
|
| 327 |
"π΄",
|
| 328 |
"π΄"
|
| 329 |
],
|
| 330 |
-
"points":
|
| 331 |
"redistributed_bonus": 568,
|
| 332 |
"wildcard": [
|
| 333 |
0,
|
|
|
|
| 7 |
"π΄",
|
| 8 |
"π΄"
|
| 9 |
],
|
| 10 |
+
"points": 90301,
|
| 11 |
"redistributed_bonus": 641,
|
| 12 |
"wildcard": [
|
| 13 |
0,
|
|
|
|
| 55 |
"π΄",
|
| 56 |
"π΄"
|
| 57 |
],
|
| 58 |
+
"points": 34262,
|
| 59 |
"redistributed_bonus": 1494,
|
| 60 |
"wildcard": [
|
| 61 |
0,
|
|
|
|
| 87 |
"π’",
|
| 88 |
"π΄"
|
| 89 |
],
|
| 90 |
+
"points": 55003,
|
| 91 |
"redistributed_bonus": 1155,
|
| 92 |
"wildcard": [
|
| 93 |
0,
|
|
|
|
| 119 |
"βͺ",
|
| 120 |
"βͺ"
|
| 121 |
],
|
| 122 |
+
"points": 52504,
|
| 123 |
"redistributed_bonus": 1115,
|
| 124 |
"wildcard": [
|
| 125 |
0,
|
|
|
|
| 167 |
"βͺ",
|
| 168 |
"βͺ"
|
| 169 |
],
|
| 170 |
+
"points": 79323,
|
| 171 |
"redistributed_bonus": 28,
|
| 172 |
"wildcard": [
|
| 173 |
0,
|
|
|
|
| 183 |
"π’",
|
| 184 |
"π΄"
|
| 185 |
],
|
| 186 |
+
"points": 199826,
|
| 187 |
"redistributed_bonus": 0,
|
| 188 |
"wildcard": [
|
| 189 |
0,
|
|
|
|
| 231 |
"π΄",
|
| 232 |
"π΄"
|
| 233 |
],
|
| 234 |
+
"points": 80117,
|
| 235 |
"redistributed_bonus": 486,
|
| 236 |
"wildcard": [
|
| 237 |
0,
|
|
|
|
| 279 |
"π΄",
|
| 280 |
"π’"
|
| 281 |
],
|
| 282 |
+
"points": 48605,
|
| 283 |
"redistributed_bonus": 1218,
|
| 284 |
"wildcard": [
|
| 285 |
0,
|
|
|
|
| 327 |
"π΄",
|
| 328 |
"π΄"
|
| 329 |
],
|
| 330 |
+
"points": 73021,
|
| 331 |
"redistributed_bonus": 568,
|
| 332 |
"wildcard": [
|
| 333 |
0,
|