Fix half MMS point

This commit is contained in:
Claude Brisson
2023-12-26 11:29:10 +01:00
parent b69b5cc0a6
commit 2629ea9b9d
4 changed files with 17 additions and 9 deletions

View File

@@ -29,11 +29,17 @@ object StandingsHandler: PairgothApiHandler {
return min(max(pairable.rank, tournament.pairing.mmFloor), tournament.pairing.mmBar) + MacMahonSolver.mmsZero return min(max(pairable.rank, tournament.pairing.mmFloor), tournament.pairing.mmBar) + MacMahonSolver.mmsZero
} }
val historyHelper = HistoryHelper(tournament.historyBefore(round)) { // CB avoid code redundancy with solvers
val historyHelper = HistoryHelper(tournament.historyBefore(round + 1)) {
if (tournament.pairing.type == PairingType.SWISS) wins if (tournament.pairing.type == PairingType.SWISS) wins
else tournament.pairables.mapValues { else tournament.pairables.mapValues {
it.value.let { it.value.let {
pairable -> mmBase(pairable) + ( nbW(pairable) ?: 0.0) // TODO take tournament parameter into account pairable ->
mmBase(pairable) +
(nbW(pairable) ?: 0.0) + // TODO take tournament parameter into account
(1..round).map { round ->
if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0 else 1
}.sum() * tournament.pairing.pairingParams.main.mmsValueAbsent
} }
} }
} }

View File

@@ -90,7 +90,7 @@ abstract class BasePairingHelper(
val Pairable.sodos: Double get() = historyHelper.sodos[id] ?: 0.0 val Pairable.sodos: Double get() = historyHelper.sodos[id] ?: 0.0
val Pairable.cums: Double get() = historyHelper.cumScore[id] ?: 0.0 val Pairable.cums: Double get() = historyHelper.cumScore[id] ?: 0.0
fun Pairable.missedRounds(upToRound: Int): Int = (1..upToRound).map { round -> fun Pairable.missedRounds(upToRound: Int): Int = (1..upToRound).map { round ->
if (historyHelper.playersPerRound.getOrNull(round)?.contains(id) == true) 0 else 1 if (historyHelper.playersPerRound.getOrNull(round - 1)?.contains(id) == true) 0 else 1
}.sum() }.sum()
fun Pairable.eval(criterion: Criterion) = evalCriterion(this, criterion) fun Pairable.eval(criterion: Criterion) = evalCriterion(this, criterion)
open fun evalCriterion(pairable: Pairable, criterion: Criterion) = when (criterion) { open fun evalCriterion(pairable: Pairable, criterion: Criterion) = when (criterion) {

View File

@@ -61,13 +61,15 @@ open class HistoryHelper(protected val history: List<List<Game>>, scoresGetter:
} }
// Set of all implied players for each round // Set of all implied players for each round
val playersPerRound = history.map { val playersPerRound: List<Set<ID>> by lazy {
history.map {
it.fold(mutableSetOf<ID>()) { acc, next -> it.fold(mutableSetOf<ID>()) { acc, next ->
acc.add(next.white) acc.add(next.white)
acc.add(next.black) acc.add(next.black)
acc acc
} }
} }
}
val wins: Map<ID, Double> by lazy { val wins: Map<ID, Double> by lazy {
mutableMapOf<ID, Double>().apply { mutableMapOf<ID, Double>().apply {

View File

@@ -69,7 +69,7 @@ MacMahon MacMahon
Main time Temps principal Main time Temps principal
Max time Temps max Max time Temps max
Name Nom Name Nom
Nbw Nbv Nbw NbV
New Tournament Nouveau Tournoi New Tournament Nouveau Tournoi
New tournament Nouveau tournoi New tournament Nouveau tournoi
Next rounds seeding Méthode rondes suivantes Next rounds seeding Méthode rondes suivantes