From 43bd7c3dae46bb13ce35d7bb4fe20c837b136d98 Mon Sep 17 00:00:00 2001 From: Quentin Rendu Date: Fri, 29 Dec 2023 11:08:28 +0100 Subject: [PATCH] Remove games against ByePlayer when computing SOSOS and SODOS --- .../jeudego/pairgoth/pairing/HistoryHelper.kt | 18 +++++++++++----- .../pairgoth/pairing/solver/BaseSolver.kt | 21 +++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) 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 a49565e..cd6ca8f 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 @@ -41,7 +41,7 @@ open class HistoryHelper(protected val history: List>, scoresGetter: history.flatten().filter { game -> game.handicap == 0 }.filter { game -> - game.white != 0 + game.white != 0 // Remove games against byePlayer }.flatMap { game -> listOf(Pair(game.white, +1), Pair(game.black, -1)) }.groupingBy { @@ -133,9 +133,13 @@ open class HistoryHelper(protected val history: List>, scoresGetter: // sodos val sodos by lazy { - (history.flatten().map { game -> + (history.flatten().filter { game -> + game.white != 0 // Remove games against byePlayer + }.map { game -> Pair(game.black, if (game.result == Game.Result.BLACK) scores[game.white] ?: 0.0 else 0.0) - } + history.flatten().map { game -> + } + history.flatten().filter { game -> + game.white != 0 // Remove games against byePlayer + }.map { game -> Pair(game.white, if (game.result == Game.Result.WHITE) scores[game.black] ?: 0.0 else 0.0) }).groupingBy { it.first }.fold(0.0) { acc, next -> acc + next.second @@ -144,9 +148,13 @@ open class HistoryHelper(protected val history: List>, scoresGetter: // sosos val sosos by lazy { - (history.flatten().map { game -> + (history.flatten().filter { game -> + game.white != 0 // Remove games against byePlayer + }.map { game -> Pair(game.black, sos[game.white] ?: 0.0) - } + history.flatten().map { game -> + } + history.flatten().filter { game -> + game.white != 0 // Remove games against byePlayer + }.map { game -> Pair(game.white, sos[game.black] ?: 0.0) }).groupingBy { it.first }.fold(0.0) { acc, next -> acc + next.second diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt index bef1c3e..b328a98 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/solver/BaseSolver.kt @@ -119,16 +119,16 @@ sealed class BaseSolver( val DEBUG_EXPORT_WEIGHT = true if (DEBUG_EXPORT_WEIGHT) { - //println("DUDD debug") - //println(nameSortedPairables[2].nameSeed() + " " + nameSortedPairables[6].nameSeed()) - //pairing.main.applyDUDD(nameSortedPairables[2],nameSortedPairables[6], debug=true) - println("Standings debug: place Name group score ranking rating") + println("DUDD debug") + println(nameSortedPairables[4].nameSeed() + " " + nameSortedPairables[25].nameSeed()) + pairing.main.applyDUDD(nameSortedPairables[25],nameSortedPairables[4], debug=true) + println("Standings debug: place Name group score sos sosos ranking rating") for (p in pairingSortedPairables){ - println(p.place.toString() + " " + p.nameSeed() + " " + p.group.toString() + " " + p.main.toString() + " " + p.displayRank() + " " + p.rating) + println(p.place.toString() + " " + p.nameSeed() + " " + p.group.toString() + " " + p.main.toString() + " " + p.sos.toString() + " " + p.sosos.toString() + " " + p.displayRank() + " " + p.rating) } - println("Seeding debug") - pairing.main.applySeeding(nameSortedPairables[20],nameSortedPairables[9], debug=true) - pairing.main.applySeeding(nameSortedPairables[9],nameSortedPairables[20], debug=true) + //println("Seeding debug") + //pairing.main.applySeeding(nameSortedPairables[20],nameSortedPairables[9], debug=true) + //pairing.main.applySeeding(nameSortedPairables[9],nameSortedPairables[20], debug=true) var sumOfWeights = 0.0 println("name place ID colorBal group DUDD vs name place ID colorBal group DUDD") for (it in sorted) { @@ -251,7 +251,7 @@ sealed class BaseSolver( return score } - open fun MainCritParams.applyDUDD(p1: Pairable, p2: Pairable): Double { + open fun MainCritParams.applyDUDD(p1: Pairable, p2: Pairable, debug: Boolean =false): Double { var score = 0.0 // TODO apply Drawn-Up/Drawn-Down if needed @@ -332,8 +332,8 @@ sealed class BaseSolver( score += 4 * duddWeight } - /* if(debug){ + println("Names DU DD "+p1.nameSeed()+" "+p1_DU+" "+p1_DD+" "+p2.nameSeed()+" "+p2_DU+" "+p2_DD) println("Names "+upperSP.nameSeed()+" "+upperSP.group+" "+lowerSP.nameSeed()+" "+lowerSP.group) println("DUDD scenario, GroupDiff = "+scenario.toString()+" "+(upperSP.group-lowerSP.group).toString()) println("DUDD Upper/Lower modes = "+pairing.main.drawUpDownUpperMode.toString()+" "+pairing.main.drawUpDownLowerMode.toString()) @@ -341,7 +341,6 @@ sealed class BaseSolver( println("u/lSPplaceingroup = "+upperSP.placeInGroup.first.toString()+" "+lowerSP.placeInGroup.first.toString()) println("score = " + score.toString()) } - */ }