Jay-Rajput commited on
Commit
1eb4ddf
Β·
1 Parent(s): 01d080e

Adding playoff bonus

Browse files
Files changed (2) hide show
  1. app.py +7 -5
  2. 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} (50% of your 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 set(predictions['user_name']):
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": 42301,
11
  "redistributed_bonus": 641,
12
  "wildcard": [
13
  0,
@@ -55,7 +55,7 @@
55
  "πŸ”΄",
56
  "πŸ”΄"
57
  ],
58
- "points": 10262,
59
  "redistributed_bonus": 1494,
60
  "wildcard": [
61
  0,
@@ -87,7 +87,7 @@
87
  "🟒",
88
  "πŸ”΄"
89
  ],
90
- "points": 23003,
91
  "redistributed_bonus": 1155,
92
  "wildcard": [
93
  0,
@@ -119,7 +119,7 @@
119
  "βšͺ",
120
  "βšͺ"
121
  ],
122
- "points": 24504,
123
  "redistributed_bonus": 1115,
124
  "wildcard": [
125
  0,
@@ -167,7 +167,7 @@
167
  "βšͺ",
168
  "βšͺ"
169
  ],
170
- "points": 65323,
171
  "redistributed_bonus": 28,
172
  "wildcard": [
173
  0,
@@ -183,7 +183,7 @@
183
  "🟒",
184
  "πŸ”΄"
185
  ],
186
- "points": 175826,
187
  "redistributed_bonus": 0,
188
  "wildcard": [
189
  0,
@@ -231,7 +231,7 @@
231
  "πŸ”΄",
232
  "πŸ”΄"
233
  ],
234
- "points": 48117,
235
  "redistributed_bonus": 486,
236
  "wildcard": [
237
  0,
@@ -279,7 +279,7 @@
279
  "πŸ”΄",
280
  "🟒"
281
  ],
282
- "points": 20605,
283
  "redistributed_bonus": 1218,
284
  "wildcard": [
285
  0,
@@ -327,7 +327,7 @@
327
  "πŸ”΄",
328
  "πŸ”΄"
329
  ],
330
- "points": 45021,
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,