From 412a80f7dd0c4f2df0ae121ac0887b09d56a0d40 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Mon, 11 Mar 2024 06:15:10 +0100 Subject: [PATCH] Option to use baseMMS+round/2 for SOS --- .../kotlin/org/jeudego/pairgoth/api/ApiTools.kt | 14 ++++++++------ .../kotlin/org/jeudego/pairgoth/model/Pairing.kt | 9 ++++++--- .../pairgoth/pairing/solver/MacMahonSolver.kt | 11 +++++++---- .../src/main/webapp/js/tour-information.inc.js | 1 + .../src/main/webapp/tour-parameters.inc.html | 12 ++++++++++++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt index 9cfea98..b79ea72 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/ApiTools.kt @@ -38,13 +38,15 @@ fun Tournament<*>.getSortedPairables(round: Int): List { else pairables.mapValues { it.value.let { pairable -> val mmBase = pairable.mmBase() + val score = roundScore(mmBase + + (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() * pairing.pairingParams.main.mmsValueAbsent) Pair( - mmBase, - roundScore(mmBase + - (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() * pairing.pairingParams.main.mmsValueAbsent) + if (pairing.pairingParams.main.sosValueAbsentUseBase) mmBase + else roundScore(mmBase + round/2), + score ) } } diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairing.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairing.kt index e30b440..047fc9d 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairing.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairing.kt @@ -51,7 +51,8 @@ data class MainCritParams( val additionalPlacementCritSystem1: Criterion = Criterion.RATING, val additionalPlacementCritSystem2: Criterion = Criterion.NONE, val mmsValueAbsent: Double = 0.5, - val roundDownScore: Boolean = true + val roundDownScore: Boolean = true, + val sosValueAbsentUseBase: Boolean = true ) { enum class DrawUpDown { TOP, MIDDLE, BOTTOM } enum class SeedMethod { SPLIT_AND_FOLD, SPLIT_AND_RANDOM, SPLIT_AND_SLIP } @@ -245,7 +246,8 @@ fun MainCritParams.Companion.fromJson(json: Json.Object, localDefault: MainCritP additionalPlacementCritSystem1 = json.getString("firstSeedAddCrit")?.let { Criterion.valueOf(it) } ?: localDefault?.additionalPlacementCritSystem1 ?: default.additionalPlacementCritSystem1, additionalPlacementCritSystem2 = json.getString("secondSeedAddCrit")?.let { Criterion.valueOf(it) } ?: localDefault?.additionalPlacementCritSystem2 ?: default.additionalPlacementCritSystem2, mmsValueAbsent = json.getDouble("mmsValueAbsent") ?: localDefault?.mmsValueAbsent ?: default.mmsValueAbsent, - roundDownScore = json.getBoolean("roundDownScore") ?: localDefault?.roundDownScore ?: default.roundDownScore + roundDownScore = json.getBoolean("roundDownScore") ?: localDefault?.roundDownScore ?: default.roundDownScore, + sosValueAbsentUseBase = json.getBoolean("sosValueAbsentUseBase") ?: localDefault?.sosValueAbsentUseBase ?: default.sosValueAbsentUseBase ) fun MainCritParams.toJson() = Json.Object( @@ -262,7 +264,8 @@ fun MainCritParams.toJson() = Json.Object( "firstSeedAddCrit" to additionalPlacementCritSystem1, "secondSeedAddCrit" to additionalPlacementCritSystem2, "mmsValueAbsent" to mmsValueAbsent, - "roundDownScore" to roundDownScore + "roundDownScore" to roundDownScore, + "sosValueAbsentUseBase" to sosValueAbsentUseBase ) fun SecondaryCritParams.Companion.fromJson(json: Json.Object, localDefault: SecondaryCritParams? = null) = SecondaryCritParams( 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 c613031..519927d 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 @@ -20,11 +20,14 @@ class MacMahonSolver(round: Int, val pairing = pairables.map { it.id }.toSet() pairablesMap.mapValues { it.value.let { pairable -> - Pair( - pairable.mmBase, - roundScore(pairable.mmBase + + val score = roundScore(pairable.mmBase + pairable.nbW + // TODO take tournament parameter into account - pairable.missedRounds(round, pairing) * pairingParams.main.mmsValueAbsent)) + pairable.missedRounds(round, pairing) * pairingParams.main.mmsValueAbsent) + Pair( + if (pairingParams.main.sosValueAbsentUseBase) pairable.mmBase + else roundScore(pairable.mmBase + round/2), + score + ) } } } diff --git a/view-webapp/src/main/webapp/js/tour-information.inc.js b/view-webapp/src/main/webapp/js/tour-information.inc.js index b2a6e34..a7d6e58 100644 --- a/view-webapp/src/main/webapp/js/tour-information.inc.js +++ b/view-webapp/src/main/webapp/js/tour-information.inc.js @@ -216,6 +216,7 @@ onLoad(() => { main: { mmsValueAbsent: form.val('mmsValueAbsent'), roundDownScore: form.val('roundDownScore'), + sosValueAbsentUseBase: form.val('sosValueAbsentUseBase'), firstSeedLastRound: form.val('firstSeedLastRound'), firstSeedAddCrit: form.val('firstSeedAddRating') ? 'RATING' : 'NONE', // TODO use client side boolean firstSeed: form.val('firstSeed'), diff --git a/view-webapp/src/main/webapp/tour-parameters.inc.html b/view-webapp/src/main/webapp/tour-parameters.inc.html index c1bfb7a..7e51b83 100644 --- a/view-webapp/src/main/webapp/tour-parameters.inc.html +++ b/view-webapp/src/main/webapp/tour-parameters.inc.html @@ -36,6 +36,18 @@ +
+
+ +
+
#end
Seeding methods inside groups of same score