fixed solver instantiation for dudd recomputation
This commit is contained in:
@@ -4,9 +4,12 @@ import com.republicate.kson.Json
|
||||
import com.republicate.kson.toJsonArray
|
||||
import kotlinx.datetime.LocalDate
|
||||
import org.jeudego.pairgoth.api.ApiHandler.Companion.badRequest
|
||||
import org.jeudego.pairgoth.pairing.HistoryHelper
|
||||
import org.jeudego.pairgoth.pairing.solver.MacMahonSolver
|
||||
import org.jeudego.pairgoth.pairing.solver.SwissSolver
|
||||
import org.jeudego.pairgoth.store.Store
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
sealed class Tournament <P: Pairable>(
|
||||
@@ -72,11 +75,12 @@ sealed class Tournament <P: Pairable>(
|
||||
// Instantiate solver with game history
|
||||
// TODO cleaner solver instantiation
|
||||
val history = games.map { games -> games.values.toList() }
|
||||
val solver = when (pairing.type) {
|
||||
PairingType.SWISS -> SwissSolver(round, history, pairables.values.toList(), pairing.pairingParams, pairing.placementParams)
|
||||
PairingType.MAC_MAHON -> MacMahonSolver(round, history, pairables.values.toList(), pairing.pairingParams, pairing.placementParams, mmBar = 3, mmFloor = -20)
|
||||
else -> throw Exception("Invalid tournament type")
|
||||
}
|
||||
val solver = if (pairing is Swiss) {
|
||||
SwissSolver(round, history, pairables.values.toList(), pairing.pairingParams, pairing.placementParams)
|
||||
} else if (pairing is MacMahon) {
|
||||
MacMahonSolver(round, history, pairables.values.toList(), pairing.pairingParams, pairing.placementParams, pairing.mmBar, pairing.mmFloor)
|
||||
} else throw Exception("Invalid tournament type")
|
||||
|
||||
// Recomputes DUDD
|
||||
val game = games(round)[gameID]!!
|
||||
val whiteplayer = solver.pairables.find { p-> p.id == game.white }!!
|
||||
|
Reference in New Issue
Block a user