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
}
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
}
}
}

View File

@@ -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) {

View File

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