Skip to content

Instantly share code, notes, and snippets.

@adamgajzlerowicz
Last active July 30, 2023 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgajzlerowicz/4db6a0bed7d2c9f7311fedae74f39134 to your computer and use it in GitHub Desktop.
Save adamgajzlerowicz/4db6a0bed7d2c9f7311fedae74f39134 to your computer and use it in GitHub Desktop.
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))
}
@WojtekDomanski
Copy link

Algorytm wygląda logicznie, wartość stałych się zgadza. Jedynie co mnie zastanawia, to punkty za dyskwalifikację w kategorii Open:
5% * 150 = 7.5
a w zawodach liczyliśmy dotąd po 8 pkt.
Jak to będzie działać w Twoim systemie?

Dobrze byłby kod przetestować.

Jakie dalsze kroki?

@adamgajzlerowicz
Copy link
Author

Zmiany sa juz na produkcji

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment