jdabtieu / CTFOJ

Lightweight CTF judge platform for capture-the-flag (CTF) clubs
GNU Affero General Public License v3.0
10 stars 6 forks source link

[FEATURE] Additional dynamic scoring parameters #213

Open jdabtieu opened 1 year ago

jdabtieu commented 1 year ago

Currently we have max pts, min pts, num users before decay, but we should also have a variable controlling decay rate that can be adjusted based on how many participants are expected

The default (hard coded) is 11, but something like 40 works a lot better for a contest like BxMCTF (500 teams). This should be adjustable

Also, these parameters should be maybe editable mid-contest could cause issues with concurrency.

jdabtieu commented 1 year ago

diff for bxmctf:

diff --git a/src/helpers.py b/src/helpers.py
index 663ccc2..0448291 100644
--- a/src/helpers.py
+++ b/src/helpers.py
@@ -197,10 +197,10 @@ def update_dyn_score(contest_id, problem_id, update_curr_user=True):
         cid=contest_id, pid=problem_id))
     N_min = check[0]["score_min"]
     N_max = check[0]["score_max"]
-    N_users = check[0]["score_users"]
-    d = 11 * math.log(N_max - N_min) + N_users
-    old_points = min(math.ceil(math.e**((d - solves + 1) / 11) + N_min), N_max)
-    new_points = min(math.ceil(math.e**((d - solves) / 11) + N_min), N_max)
+    N_users = 20 # check[0]["score_users"]
+    d = 40 * math.log(N_max - N_min) + N_users
+    old_points = min(math.ceil(math.e**((d - solves + 1) / 40) + N_min), N_max)
+    new_points = min(math.ceil(math.e**((d - solves) / 40) + N_min), N_max)
     point_diff = new_points - old_points

     # Set new point value of problem