From 122db9347ad0a7771402c5188f73123f7d746288 Mon Sep 17 00:00:00 2001 From: Quentin Rendu Date: Wed, 29 Nov 2023 11:09:18 +0100 Subject: [PATCH] Correct missing result in round 1 of test 9 --- .../pairgoth/pairing/solver/BaseSolver.kt | 18 ++++++++++++++++-- api-webapp/src/test/kotlin/PairingTests.kt | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) 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 cf7260d..ea3f643 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 @@ -121,6 +121,7 @@ sealed class BaseSolver( if (DEBUG_EXPORT_WEIGHT) { var sumOfWeights = 0.0 + println("name place ID colorBal group DUDD vs name place ID colorBal group DUDD") for (it in sorted) { println(it[0].nameSeed() + " " + it[0].place.toString() + " " + it[0].id.toString() @@ -282,12 +283,16 @@ sealed class BaseSolver( if (scenario != 0 && p2_DD > 0 && p2_DU < p2_DD && p2.group > p1.group) { scenario++ } + val duddWeight: Double = pairing.main.drawUpDownWeight/5.0 - val upperSP = if (p1.group < p2.group) p1 else p2 - val lowerSP = if (p1.group < p2.group) p2 else p1 + val upperSP = if (p1.group < p2.group) p2 else p1 + val lowerSP = if (p1.group < p2.group) p1 else p2 val uSPgroupSize = upperSP.placeInGroup.second val lSPgroupSize = lowerSP.placeInGroup.second + + + if (pairing.main.drawUpDownUpperMode === MainCritParams.DrawUpDown.TOP) { score += duddWeight / 2 * (uSPgroupSize - 1 - upperSP.placeInGroup.first) / uSPgroupSize } else if (pairing.main.drawUpDownUpperMode === MainCritParams.DrawUpDown.MIDDLE) { @@ -313,8 +318,17 @@ sealed class BaseSolver( } else if (scenario == 4) { score += 4 * duddWeight } + + /* println("Names "+upperSP.nameSeed()+" "+lowerSP.nameSeed()) + println("DUDD scenario, GroupDiff = "+scenario.toString()+" "+(upperSP.group-lowerSP.group).toString()) + println("DUDD Upper/Lower modes = "+pairing.main.drawUpDownUpperMode.toString()+" "+pairing.main.drawUpDownLowerMode.toString()) + println("u/lSPgroupsize = "+uSPgroupSize.toString()+" "+lSPgroupSize.toString()) + println("u/lSPplaceingroup = "+upperSP.placeInGroup.first.toString()+" "+lowerSP.placeInGroup.first.toString()) + println("score = " + score.toString())*/ } + + // TODO adapt to Swiss with categories /*// But, if players come from different categories, decrease score(added in 3.11) val catGap: Int = Math.abs(p1.category(gps) - p2.category(gps)) diff --git a/api-webapp/src/test/kotlin/PairingTests.kt b/api-webapp/src/test/kotlin/PairingTests.kt index 180e97b..af74a79 100644 --- a/api-webapp/src/test/kotlin/PairingTests.kt +++ b/api-webapp/src/test/kotlin/PairingTests.kt @@ -282,7 +282,7 @@ class PairingTests: TestBase() { logger.info("games for round $round: {}", games.toString()) firstGameID = (games.getJson(0)!!.asObject()["id"] as Long?)!!.toInt() - for (gameID in firstGameID..firstGameID + 15) { + for (gameID in firstGameID..firstGameID + 16) { resp = TestAPI.put("/api/tour/$id/res/$round", Json.parse("""{"id":$gameID,"result":"b"}""")).asObject() assertTrue(resp.getBoolean("success") == true, "expecting success") }