Skip to content

Commit 9ffdde9

Browse files
authored
Merge pull request #40 from lactf/new-curve
New curve
2 parents 8989867 + 2c9c0ab commit 9ffdde9

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

server/util/scores.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
const p0 = 0.7
2-
const p1 = 0.96
3-
4-
const c0 = -Math.atanh(p0)
5-
const c1 = Math.atanh(p1)
6-
const a = (x: number): number => (1 - Math.tanh(x)) / 2
7-
const b = (x: number): number => (a((c1 - c0) * x + c0) - a(c1)) / (a(c0) - a(c1))
8-
1+
// rl is min challenge points
2+
// rh is max challenge points
3+
// maxSolves is usually 800 and honestly after that point it doesn't matter too much
4+
// solves is number of solves chall has
5+
//
6+
// formula im using (one curve for hard challs, one curve for easy challs:
7+
// min(max(428 * (0.995) ** solves + 75, 428 * (0.9978) ** solves, 100), 500)
8+
//
9+
// put below into desmos to see curve:
10+
// y_{2}=428\left(.995\right)^{x}+75
11+
// y_{3}=428\left(.9978\right)^{x}
12+
// y=\min\left(\max\left(y_{2},\ y_{3},\ 100\right),\ 500\right)
913
export const getScore = (rl: number, rh: number, maxSolves: number, solves: number): number => {
10-
const s = Math.max(1, maxSolves)
11-
const f = (x: number): number => rl + (rh - rl) * b(x / s)
12-
return Math.round(Math.max(f(solves), f(s)))
14+
const hardCurve = 428 * (0.995) ** solves + 75;
15+
const easyCurve = 428 * (0.9978) ** solves;
16+
const veryEasyCurve = -0.055 * solves + 150;
17+
return Math.round(Math.min(Math.max(hardCurve, easyCurve, veryEasyCurve, rl), rh));
1318
}

0 commit comments

Comments
 (0)