Last active
July 30, 2023 11:58
-
-
Save adamgajzlerowicz/4db6a0bed7d2c9f7311fedae74f39134 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ParticipantWithRunsAndResults, SingleRunOfParticipant } from '../types/common' | |
import { RunCategory } from '../__types__/graphql' | |
import { isRunFinished } from './utils' | |
const maxPoints: Record<RunCategory, number> = { | |
[RunCategory.MinusA0]: 0, | |
[RunCategory.A0]: 0, | |
[RunCategory.A1]: 100, | |
[RunCategory.A2]: 100, | |
[RunCategory.A3]: 100, | |
[RunCategory.Open]: 150, | |
[RunCategory.ElitaFinals]: 200, | |
[RunCategory.PretendantsFinals]: 200, | |
} | |
const disqualifiedScore = 0.05 | |
export const elitaFinalistsStrategy = ( | |
participant: ParticipantWithRunsAndResults, | |
run: SingleRunOfParticipant, | |
): number | null => { | |
if ([RunCategory.MinusA0, RunCategory.A0].includes(run.category)) { | |
return null | |
} | |
if (!isRunFinished(run)) { | |
return null | |
} | |
if (run.result.didNotRun) { | |
return 0 | |
} | |
if (run.result.wasDisqualified) { | |
return Math.round(disqualifiedScore * maxPoints[run.category]) | |
} | |
const N = run.runners.length | |
const position = run.result.finalPosition | |
if (position === null) { | |
return null | |
} | |
const runScore = (maxPoints[run.category] * (N + 1 - position)) / N | |
// Ensure the run score is at least 10% of max points | |
const minRunScore = 0.1 * maxPoints[run.category] | |
return Math.round(Math.max(runScore, minRunScore)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zmiany sa juz na produkcji