Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New curve #40

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions server/util/scores.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const p0 = 0.7
const p1 = 0.96

const c0 = -Math.atanh(p0)
const c1 = Math.atanh(p1)
const a = (x: number): number => (1 - Math.tanh(x)) / 2
const b = (x: number): number => (a((c1 - c0) * x + c0) - a(c1)) / (a(c0) - a(c1))

// rl is min challenge points
// rh is max challenge points
// maxSolves is usually 800 and honestly after that point it doesn't matter too much
// solves is number of solves chall has
//
// formula im using (one curve for hard challs, one curve for easy challs:
// min(max(428 * (0.995) ** solves + 75, 428 * (0.9978) ** solves, 100), 500)
//
// put below into desmos to see curve:
// y_{2}=428\left(.995\right)^{x}+75
// y_{3}=428\left(.9978\right)^{x}
// y=\min\left(\max\left(y_{2},\ y_{3},\ 100\right),\ 500\right)
export const getScore = (rl: number, rh: number, maxSolves: number, solves: number): number => {
const s = Math.max(1, maxSolves)
const f = (x: number): number => rl + (rh - rl) * b(x / s)
return Math.round(Math.max(f(solves), f(s)))
const hardCurve = 428 * (0.995) ** solves + 75;
const easyCurve = 428 * (0.9978) ** solves;
const veryEasyCurve = -0.055 * solves + 150;
return Math.round(Math.min(Math.max(hardCurve, easyCurve, veryEasyCurve, rl), rh));
}