Add mmsFloor and mmsBar parameters for initial MMS scores

This commit is contained in:
Claude Brisson
2023-11-05 14:30:01 +01:00
parent 49973bdf23
commit 03845d7fdf
4 changed files with 2100 additions and 1295 deletions

View File

@@ -116,8 +116,16 @@ object OpenGotha {
else -> throw Error("missing byoyomi type")
},
pairing = when (handParams.hdCeiling) {
0 -> Swiss(pairingParams = pairgothPairingParams, placementParams = pairgothPlacementParams)
else -> MacMahon(pairingParams = pairgothPairingParams, placementParams = pairgothPlacementParams)
0 -> Swiss(
pairingParams = pairgothPairingParams,
placementParams = pairgothPlacementParams
)
else -> MacMahon(
pairingParams = pairgothPairingParams,
placementParams = pairgothPlacementParams,
mmsFloor = Pairable.parseRank(genParams.genMMFloor),
mmsBar = Pairable.parseRank(genParams.genMMBar)
)
},
rounds = genParams.numberOfRounds
)
@@ -241,7 +249,15 @@ object OpenGotha {
TimeSystem.TimeSystemType.STANDARD -> "STDBYOYOMI"
TimeSystem.TimeSystemType.CANADIAN -> "CANBYOYOMI"
TimeSystem.TimeSystemType.FISCHER -> "FISCHER"
} }" director="" endDate="${tournament.endDate}" fischerTime="${tournament.timeSystem.increment}" genCountNotPlayedGamesAsHalfPoint="false" genMMBar="9D" genMMFloor="30K" genMMS2ValueAbsent="1" genMMS2ValueBye="2" genMMZero="30K" genNBW2ValueAbsent="0" genNBW2ValueBye="2" genRoundDownNBWMMS="true" komi="${tournament.komi}" location="${tournament.location}" name="${tournament.name}" nbMovesCanTime="${tournament.timeSystem.stones}" numberOfCategories="1" numberOfRounds="${tournament.rounds}" shortName="${tournament.shortName}" size="${tournament.gobanSize}" stdByoYomiTime="${tournament.timeSystem.byoyomi}"/>
} }" director="" endDate="${tournament.endDate}" fischerTime="${tournament.timeSystem.increment}" genCountNotPlayedGamesAsHalfPoint="false" genMMBar="${
displayRank(
if (tournament.pairing is MacMahon) tournament.pairing.mmsBar else 8
).uppercase(Locale.ROOT)
}" genMMFloor="${
displayRank(
if (tournament.pairing is MacMahon) tournament.pairing.mmsFloor else -30
).uppercase(Locale.ROOT)
}" genMMS2ValueAbsent="1" genMMS2ValueBye="2" genMMZero="30K" genNBW2ValueAbsent="0" genNBW2ValueBye="2" genRoundDownNBWMMS="true" komi="${tournament.komi}" location="${tournament.location}" name="${tournament.name}" nbMovesCanTime="${tournament.timeSystem.stones}" numberOfCategories="1" numberOfRounds="${tournament.rounds}" shortName="${tournament.shortName}" size="${tournament.gobanSize}" stdByoYomiTime="${tournament.timeSystem.byoyomi}"/>
<HandicapParameterSet hdBasedOnMMS="${tournament.pairing.pairingParams.handicap.useMMS}" hdCeiling="${tournament.pairing.pairingParams.handicap.ceiling}" hdCorrection="${tournament.pairing.pairingParams.handicap.correction}" hdNoHdRankThreshold="${displayRank(tournament.pairing.pairingParams.handicap.rankThreshold)}"/>
<PlacementParameterSet>
<PlacementCriteria>

View File

@@ -180,11 +180,13 @@ class MacMahon(
),
placementParams: PlacementParams = PlacementParams(
Criterion.NBW, Criterion.SOSW, Criterion.SOSOSW
)
),
var mmsFloor: Int = -20,
var mmsBar: Int = 0
): Pairing(MAC_MAHON, pairingParams, placementParams) {
companion object {}
override fun pair(tournament: Tournament<*>, round: Int, pairables: List<Pairable>): List<Game> {
return MacMahonSolver(round, tournament.historyBefore(round), pairables, pairingParams, placementParams).pair()
return MacMahonSolver(round, tournament.historyBefore(round), pairables, pairingParams, placementParams, mmsFloor, mmsBar).pair()
}
}

View File

@@ -1,12 +1,15 @@
package org.jeudego.pairgoth.pairing.solver
import org.jeudego.pairgoth.model.*
import kotlin.math.max
import kotlin.math.min
class MacMahonSolver(round: Int,
history: List<List<Game>>,
pairables: List<Pairable>,
pairingParams: PairingParams,
placementParams: PlacementParams):
placementParams: PlacementParams,
private val mmsFloor: Int, private val mmsBar: Int):
BaseSolver(round, history, pairables, pairingParams, placementParams) {
override val scores: Map<ID, Double> by lazy {
@@ -16,14 +19,18 @@ class MacMahonSolver(round: Int,
}
}
}
val Pairable.mmBase: Double get() = rank + 30.0 // TODO use params
val Pairable.mmBase: Double get() = min(max(rank, mmsFloor), mmsBar) + mmsZero
val Pairable.mms: Double get() = scores[id] ?: 0.0
// CB TODO - configurable criteria
override val mainLimits get() = Pair(0.0, 100.0) // TODO
override val mainLimits get() = Pair(mmsFloor.toDouble(), 100.0) // TODO ?
override fun evalCriterion(pairable: Pairable, criterion: Criterion) = when (criterion) {
Criterion.MMS -> pairable.mms
else -> super.evalCriterion(pairable, criterion)
}
companion object {
const val mmsZero = 30.0
}
}

File diff suppressed because it is too large Load Diff