diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt index 00f1dc9..b664685 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt @@ -29,11 +29,17 @@ object StandingsHandler: PairgothApiHandler { 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 else tournament.pairables.mapValues { 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 } } } 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 76e4f43..cba11c2 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 @@ -90,7 +90,7 @@ abstract class BasePairingHelper( 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): 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() fun Pairable.eval(criterion: Criterion) = evalCriterion(this, criterion) open fun evalCriterion(pairable: Pairable, criterion: Criterion) = when (criterion) { diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt index 44de378..ce9959d 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/HistoryHelper.kt @@ -61,11 +61,13 @@ open class HistoryHelper(protected val history: List>, scoresGetter: } // Set of all implied players for each round - val playersPerRound = history.map { - it.fold(mutableSetOf()) { acc, next -> - acc.add(next.white) - acc.add(next.black) - acc + val playersPerRound: List> by lazy { + history.map { + it.fold(mutableSetOf()) { acc, next -> + acc.add(next.white) + acc.add(next.black) + acc + } } } diff --git a/view-webapp/src/main/webapp/WEB-INF/translations/fr b/view-webapp/src/main/webapp/WEB-INF/translations/fr index 25237ca..77105d0 100644 --- a/view-webapp/src/main/webapp/WEB-INF/translations/fr +++ b/view-webapp/src/main/webapp/WEB-INF/translations/fr @@ -69,7 +69,7 @@ MacMahon MacMahon Main time Temps principal Max time Temps max Name Nom -Nbw Nbv +Nbw NbV New Tournament Nouveau Tournoi New tournament Nouveau tournoi Next rounds seeding Méthode rondes suivantes