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 ea3f643..ae237d0 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 @@ -29,6 +29,7 @@ sealed class BaseSolver( companion object { val rand = Random(/* seed from properties - TODO */) val DEBUG_EXPORT_WEIGHT = true + var byePlayers: MutableList = mutableListOf() } open fun openGothaWeight(p1: Pairable, p2: Pairable) = @@ -68,6 +69,7 @@ sealed class BaseSolver( var byePlayerIndex = 0 for (p in nameSortedPairables){ weightForBye = p.rank + 2*p.main + if (p in byePlayers) weightForBye += 1000 if (weightForBye <= minWeight){ minWeight = weightForBye chosenByePlayer = p @@ -75,6 +77,7 @@ sealed class BaseSolver( println("choose Bye: " + p.nameSeed() + " " + weightForBye) } println("Bye player : " + chosenByePlayer.nameSeed()) + byePlayers.add(chosenByePlayer) nameSortedPairables.remove(chosenByePlayer) } @@ -83,8 +86,8 @@ sealed class BaseSolver( for (j in i + 1 until nameSortedPairables.size) { val p = nameSortedPairables[i] val q = nameSortedPairables[j] - weight(p, q).let { if (it != Double.NaN) builder.addEdge(p, q, it) } - weight(q, p).let { if (it != Double.NaN) builder.addEdge(q, p, it) } + weight(p, q).let { if (it != Double.NaN) builder.addEdge(p, q, it/1.0) } + weight(q, p).let { if (it != Double.NaN) builder.addEdge(q, p, it/1.0) } if (DEBUG_EXPORT_WEIGHT) { File(WEIGHTS_FILE).appendText("Player1Name="+p.nameSeed()+"\n") diff --git a/api-webapp/src/test/kotlin/PairingTests.kt b/api-webapp/src/test/kotlin/PairingTests.kt index af74a79..6135801 100644 --- a/api-webapp/src/test/kotlin/PairingTests.kt +++ b/api-webapp/src/test/kotlin/PairingTests.kt @@ -272,6 +272,7 @@ class PairingTests: TestBase() { games = TestAPI.get("/api/tour/$id/res/$round").asArray() } else { + //games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array(playersList.filter{it != byePlayerList[round-1]})).asArray() games = TestAPI.post("/api/tour/$id/pair/$round", Json.Array("all")).asArray() logger.info("games for round $round: {}", games.toString())