More code cleaning
This commit is contained in:
@@ -34,9 +34,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
|
||||
else ceil(score - epsilon)
|
||||
}
|
||||
|
||||
val historyHelper = HistoryHelper(
|
||||
historyBefore(round + 1),
|
||||
scoresGetter = {
|
||||
val historyHelper = HistoryHelper(historyBefore(round + 1)) {
|
||||
if (pairing.type == PairingType.SWISS) wins.mapValues { Pair(0.0, it.value) }
|
||||
else pairables.mapValues {
|
||||
it.value.let { pairable ->
|
||||
@@ -53,16 +51,7 @@ fun Tournament<*>.getSortedPairables(round: Int, includePreliminary: Boolean = f
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
scoresXGetter = {
|
||||
if (pairing.type == PairingType.SWISS) wins.mapValues { it.value }
|
||||
else pairables.mapValues {
|
||||
it.value.let { pairable ->
|
||||
roundScore(pairable.mmBase() + (nbW(pairable) ?: 0.0))
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
val neededCriteria = ArrayList(pairing.placementParams.criteria)
|
||||
if (!neededCriteria.contains(Criterion.NBW)) neededCriteria.add(Criterion.NBW)
|
||||
if (!neededCriteria.contains(Criterion.RATING)) neededCriteria.add(Criterion.RATING)
|
||||
|
@@ -18,7 +18,7 @@ abstract class BasePairingHelper(
|
||||
if (pairables.first().let { it is TeamTournament.Team && it.teamOfIndividuals }) TeamOfIndividualsHistoryHelper(
|
||||
history
|
||||
) { scores }
|
||||
else HistoryHelper(history, scoresGetter = { scores }, scoresXGetter = { scoresX })
|
||||
else HistoryHelper(history) { scores }
|
||||
|
||||
// Extend pairables with members from all rounds
|
||||
|
||||
|
@@ -6,12 +6,7 @@ import org.jeudego.pairgoth.model.Game.Result.*
|
||||
open class HistoryHelper(
|
||||
protected val history: List<List<Game>>,
|
||||
// scoresGetter() returns Pair(absentSosValueForOthers, score) where score is nbw for Swiss, mms for MM, ...
|
||||
scoresGetter: HistoryHelper.()-> Map<ID, Pair<Double, Double>>,
|
||||
// scoresXGetter(), defined by default as score
|
||||
scoresXGetter: HistoryHelper.()-> Map<ID, Double> = {
|
||||
scoresGetter().mapValues { entry -> entry.value.second
|
||||
}
|
||||
}) {
|
||||
scoresGetter: HistoryHelper.()-> Map<ID, Pair<Double, Double>>) {
|
||||
|
||||
// List of all the pairables ID present in the history
|
||||
val allPairables = history.flatten()
|
||||
@@ -33,7 +28,9 @@ open class HistoryHelper(
|
||||
}
|
||||
|
||||
val scoresX by lazy {
|
||||
scoresXGetter()
|
||||
scoresGetter().mapValues { entry ->
|
||||
entry.value.first + (wins[entry.key] ?: 0.0)
|
||||
}
|
||||
}
|
||||
|
||||
// Generic helper functions
|
||||
|
Reference in New Issue
Block a user