Mise a jour de la formule de calcul de bye

This commit is contained in:
Theo Barollet
2023-10-24 11:57:30 +02:00
parent 6c3dbd2aee
commit e94ba5614a
2 changed files with 11 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import org.jeudego.pairgoth.store.Store
sealed class Pairable(val id: ID, val name: String, open val rating: Int, open val rank: Int) { sealed class Pairable(val id: ID, val name: String, open val rating: Int, open val rank: Int) {
companion object { companion object {
val MIN_RANK: Int = -30 // 30k val MIN_RANK: Int = -30 // 30k
val MAX_RANK: Int = 20
} }
abstract fun toJson(): Json.Object abstract fun toJson(): Json.Object
abstract val club: String? abstract val club: String?

View File

@@ -40,7 +40,7 @@ sealed class BaseSolver(
open fun weight(p1: Pairable, p2: Pairable) = open fun weight(p1: Pairable, p2: Pairable) =
openGothaWeight(p1, p2) + openGothaWeight(p1, p2) +
pairing.base.applyByeWeight(p1, p2) + //pairing.base.applyByeWeight(p1, p2) +
pairing.handicap.color(p1, p2) pairing.handicap.color(p1, p2)
fun pair(): List<Game> { fun pair(): List<Game> {
@@ -149,7 +149,9 @@ sealed class BaseSolver(
return if (p1.id == ByePlayer.id || p2.id == ByePlayer.id) { return if (p1.id == ByePlayer.id || p2.id == ByePlayer.id) {
val actualPlayer = if (p1.id == ByePlayer.id) p2 else p1 val actualPlayer = if (p1.id == ByePlayer.id) p2 else p1
// TODO maybe use a different formula than opengotha // TODO maybe use a different formula than opengotha
BaseCritParams.MAX_BYE_WEIGHT - (1000 * actualPlayer.nbBye + actualPlayer.rank + 2*actualPlayer.main) val x = (actualPlayer.rank - Pairable.MIN_RANK + actualPlayer.main) / (Pairable.MAX_RANK - Pairable.MIN_RANK + mainLimits.second)
concavityFunction(x, BaseCritParams.MAX_BYE_WEIGHT)
BaseCritParams.MAX_BYE_WEIGHT - (actualPlayer.rank + 2*actualPlayer.main)
} else { } else {
0.0 0.0
} }
@@ -188,8 +190,7 @@ sealed class BaseSolver(
// TODO check category equality if category are used in SwissCat // TODO check category equality if category are used in SwissCat
if (scoreRange!=0){ if (scoreRange!=0){
val x = abs(p1.group - p2.group).toDouble() / scoreRange.toDouble() val x = abs(p1.group - p2.group).toDouble() / scoreRange.toDouble()
val k: Double = pairing.base.nx1 score = concavityFunction(x, scoreWeight)
score = scoreWeight * (1.0 - x) * (1.0 + k * x)
} }
return score return score
@@ -441,6 +442,11 @@ sealed class BaseSolver(
return score return score
} }
fun concavityFunction(x: Double, scale: Double) : Double {
val k = pairing.base.nx1
return scale * (1.0 - x) * (1.0 + k * x)
}
open fun games(black: Pairable, white: Pairable): List<Game> { open fun games(black: Pairable, white: Pairable): List<Game> {
// CB TODO team of individuals pairing // CB TODO team of individuals pairing
return listOf(Game(id = Store.nextGameId, black = black.id, white = white.id, handicap = pairing.handicap.handicap(black, white))) return listOf(Game(id = Store.nextGameId, black = black.id, white = white.id, handicap = pairing.handicap.handicap(black, white)))