From 6ae5b471218f4261adbabbbef2cef8f342347069 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Wed, 29 May 2024 12:52:42 +0200 Subject: [PATCH] Never take current round into account for unplayed rounds --- .../kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt | 4 ++-- .../org/jeudego/pairgoth/pairing/solver/MacMahonSolver.kt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt index 1ec18a0..e52b502 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt @@ -94,9 +94,9 @@ abstract class BasePairingHelper( val Pairable.sosos: Double get() = historyHelper.sosos[id] ?: 0.0 val Pairable.sodos: Double get() = historyHelper.sodos[id] ?: 0.0 val Pairable.cums: Double get() = historyHelper.cumScore[id] ?: 0.0 - fun Pairable.missedRounds(upToRound: Int, pairing: Set): Int = (1..upToRound).map { round -> + fun Pairable.missedRounds(): Int = (1 until round).map { round -> if (historyHelper.playersPerRound.getOrNull(round - 1) - ?.contains(id) == true || round == upToRound && pairing.contains(id) + ?.contains(id) == true ) 0 else 1 }.sum() diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/MacMahonSolver.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/MacMahonSolver.kt index d360712..fecda24 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/MacMahonSolver.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/MacMahonSolver.kt @@ -19,12 +19,11 @@ class MacMahonSolver(round: Int, override val scores: Map> by lazy { require (mmBar > mmFloor) { "MMFloor is higher than MMBar" } - val pairing = pairables.map { it.id }.toSet() pairablesMap.mapValues { it.value.let { pairable -> val score = roundScore(pairable.mmBase + pairable.nbW + - pairable.missedRounds(round, pairing) * pairingParams.main.mmsValueAbsent) + pairable.missedRounds() * pairingParams.main.mmsValueAbsent) Pair( if (pairingParams.main.sosValueAbsentUseBase) pairable.mmBase else roundScore(pairable.mmBase + round/2),