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 5f5b7fb..ac741a3 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
@@ -15,6 +15,7 @@ import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.max
import kotlin.math.min
+import kotlin.math.round
// TODO CB avoid code redundancy with solvers
@@ -29,7 +30,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
val epsilon = 0.00001
// Note: this works for now because we only have .0 and .5 fractional parts
return if (pairing.pairingParams.main.roundDownScore) floor(score + epsilon)
- else ceil(score - epsilon)
+ else round(2 * score) / 2
}
if (frozen != null) {
@@ -45,7 +46,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
val score = roundScore(mmBase +
(nbW(pairable) ?: 0.0) +
(1..round).map { round ->
- if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0 else 1
+ if (playersPerRound.getOrNull(round - 1)?.contains(pairable.id) == true) 0.0 else 1.0
}.sum() * pairing.pairingParams.main.mmsValueAbsent)
Pair(
if (pairing.pairingParams.main.sosValueAbsentUseBase) mmBase
@@ -96,7 +97,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
val pairables = pairables.values.filter { includePreliminary || it.final }.map { it.toDetailedJson() }
pairables.forEach { player ->
for (crit in criteria) {
- player[crit.first] = (crit.second[player.getID()] ?: 0.0).toInt()
+ player[crit.first] = crit.second[player.getID()] ?: 0.0
}
player["results"] = Json.MutableArray(List(round) { "0=" })
}
diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt
index 05b47fd..39b2a09 100644
--- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt
+++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/pairing/BasePairingHelper.kt
@@ -48,7 +48,7 @@ abstract class BasePairingHelper(
// Decide each pairable group based on the main criterion
protected val groupsCount get() = 1 + (mainLimits.second - mainLimits.first).toInt()
private val _groups by lazy {
- pairables.associate { pairable -> Pair(pairable.id, pairable.main.toInt()) }
+ pairables.associate { pairable -> Pair(pairable.id, (pairable.main * 2).toInt() / 2) }
}
// place (among sorted pairables)
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 699e388..694972f 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
@@ -480,7 +480,7 @@ sealed class BaseSolver(
val epsilon = 0.00001
// Note: this works for now because we only have .0 and .5 fractional parts
return if (pairing.main.roundDownScore) floor(score + epsilon)
- else ceil(score - epsilon)
+ else round(2 * score) / 2
}
open fun HandicapParams.clamp(input: Int): Int {
diff --git a/view-webapp/src/main/webapp/WEB-INF/tools.xml b/view-webapp/src/main/webapp/WEB-INF/tools.xml
index 6d68015..85aa1d0 100644
--- a/view-webapp/src/main/webapp/WEB-INF/tools.xml
+++ b/view-webapp/src/main/webapp/WEB-INF/tools.xml
@@ -5,6 +5,7 @@
+