Update secondary weight to match Opengotha v3.52

This commit is contained in:
Quentin Rendu
2024-05-24 22:32:36 +02:00
parent 0796c75fbc
commit bb259494e3
2 changed files with 26 additions and 25 deletions

View File

@@ -410,23 +410,20 @@ sealed class BaseSolver(
open fun SecondaryCritParams.apply(p1: Pairable, p2: Pairable): Double { open fun SecondaryCritParams.apply(p1: Pairable, p2: Pairable): Double {
// Do we apply Secondary Criteria // playersMeetCriteria = 0 : No player is above thresholds -> apply secondary criteria
// secCase = 0 : No player is above thresholds -> apply secondary criteria // playersMeetCriteria = 1 : 1 player is above thresholds -> apply half the weight
// secCase = 1 : At least one player is above thresholds -> do not apply // playersMeetCriteria = 2 : Both players is above thresholds -> apply the full weight
var score = 0.0 var playersMeetCriteria = 0
var secCase = 0
val nbw2Threshold: Int val nbw2Threshold =
if (nbWinsThresholdActive) nbw2Threshold = totalRounds if (nbWinsThresholdActive) totalRounds
else nbw2Threshold = 2 * totalRounds else 2 * totalRounds
if( (2*p1.nbW >= nbw2Threshold) || if (2*p1.nbW >= nbw2Threshold) playersMeetCriteria++
(2*p2.nbW >= nbw2Threshold) ) secCase = 1 if (2*p2.nbW >= nbw2Threshold) playersMeetCriteria++
if (secCase == 0) score = pairing.geo.apply(p1, p2) return 0.5*playersMeetCriteria*pairing.geo.apply(p1, p2)
return score
} }
fun GeographicalParams.apply(p1: Pairable, p2: Pairable): Double { fun GeographicalParams.apply(p1: Pairable, p2: Pairable): Double {

View File

@@ -35,24 +35,28 @@ class MacMahonSolver(round: Int,
override fun SecondaryCritParams.apply(p1: Pairable, p2: Pairable): Double { override fun SecondaryCritParams.apply(p1: Pairable, p2: Pairable): Double {
// Do we apply Secondary Criteria? // playersMeetCriteria = 0 : No player is above thresholds -> apply the full weight
// - no player is above thresholds -> apply secondary criteria // playersMeetCriteria = 1 : 1 player is above thresholds -> apply half the weight
// - at least one player is above thresholds -> do not apply // playersMeetCriteria = 2 : Both players are above thresholds -> do not apply weight
var playersMeetCriteria = 0
val nbw2Threshold = val nbw2Threshold =
if (nbWinsThresholdActive) totalRounds if (nbWinsThresholdActive) totalRounds
else 2 * totalRounds else 2 * totalRounds
val skipSecondary = // Test whether each pairable meets one of the criteria
(2 * p1.nbW >= nbw2Threshold) || // subtract Pairable.MIN_RANK to thresholds to convert ranks to MMS score
(2 * p2.nbW >= nbw2Threshold) || if (2 * p1.nbW >= nbw2Threshold
barThresholdActive && ( || barThresholdActive && (p1.mms >= mmBar - Pairable.MIN_RANK)
(p1.rank + p1.nbW >= mmBar) || || p1.mms >= rankSecThreshold - Pairable.MIN_RANK) playersMeetCriteria++
(p2.rank + p2.nbW >= mmBar)
)
return if (skipSecondary) 0.0 if (2 * p2.nbW >= nbw2Threshold
else pairing.geo.apply(p1, p2) || barThresholdActive && (p2.mms >= mmBar - Pairable.MIN_RANK)
|| p2.mms >= rankSecThreshold - Pairable.MIN_RANK) playersMeetCriteria++
return if (playersMeetCriteria==2) 0.0
else 0.5*(2-playersMeetCriteria)*pairing.geo.apply(p1, p2)
} }
override fun HandicapParams.pseudoRank(pairable: Pairable): Int { override fun HandicapParams.pseudoRank(pairable: Pairable): Int {